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

Adds a function to call when the current undo entry is undone.
Starts a new undo entry.
Undoes the most recent entry in the undo queue of a player and removes it from the queue.
Calls all of the callbacks of an undo entry.
finish()shared
Puts the current undo entry on top of its player's undo queue.
Returns the undo queue of a player.
Removes the undo entries with the specified ID from the undo queue of a player.
Sets the player that the current undo entry belongs to.

Methods

Flux.Undo:add(callback, ...)

shared packages/flow/lib/sh_undo.lua:39

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

Flux.Undo:create(id, name)

shared packages/flow/lib/sh_undo.lua:27

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

Flux.Undo:do_player(owner)

shared packages/flow/lib/sh_undo.lua:97

Undoes the most recent entry in the undo queue of a player and removes it from the queue.

Parameters

  • owner Player

Flux.Undo:execute(obj)

shared packages/flow/lib/sh_undo.lua:83

Calls all of the callbacks of an undo entry.

Parameters

  • obj Map undo entry

Flux.Undo:finish()

shared packages/flow/lib/sh_undo.lua:53

Puts the current undo entry on top of its player's undo queue. The entry is discarded if it has no valid player.

Flux.Undo:get_player(owner)

shared packages/flow/lib/sh_undo.lua:108

Returns the undo queue of a player.

Parameters

  • owner Player

Returns

  • List<Map> undo entries, oldest first

Flux.Undo:remove(owner, id)

shared packages/flow/lib/sh_undo.lua:69

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

Flux.Undo:set_player(owner)

shared packages/flow/lib/sh_undo.lua:47

Sets the player that the current undo entry belongs to.

Parameters

  • owner Player

Defined in