Flux.Undo class
Part of Flow
An undo queue for every player. An undo entry is a list of callbacks that revert something
a player has done, such as removing an entity they have spawned. It is built in steps:
Flux.Undo:create starts an entry, Flux.Undo:add adds callbacks to it,
Flux.Undo:set_player sets its owner and Flux.Undo:finish puts it on top of the queue of
the owner. Flux.Undo:do_player undoes the most recent entry of a player; Flux calls it on
the server when the client of the player reports that they have pressed their undo key.
Summary
Methods
Methods
Adds a function to call when the current undo entry is undone.
Parameters
- callback Function receives the undo entry (Map), followed by the extra arguments
- ... Vararg extra arguments for the callback
Starts a new undo entry. Add callbacks to it with Flux.Undo#add, assign it to a player and finish it to put it into the undo queue of that player.
Flux.Undo:create('prop', 'Prop')
Flux.Undo:add(function(obj, ent)
if IsValid(ent) then
ent:Remove()
end
end, entity)
Flux.Undo:set_player(owner)
Flux.Undo:finish()
Parameters
- id String ID of the entry, entries can be removed by it
- name String name of the entry
Undoes the most recent entry in the undo queue of a player and removes it from the queue.
Parameters
- owner Player
Calls all of the callbacks of an undo entry.
Parameters
- obj Map undo entry
Puts the current undo entry on top of its player's undo queue. The entry is discarded if it has no valid player.
Returns the undo queue of a player.
Parameters
- owner Player
Returns
- List<Map> undo entries, oldest first
Removes the undo entries with the specified ID from the undo queue of a player.
Parameters
- owner Player
- id String ID the entries were created with
Sets the player that the current undo entry belongs to.
Parameters
- owner Player