MapEditor helpers

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

MapEditor helpers

Since 0.1.4. Client Lua helpers inside the map_editor resource only, not engine globals available to every resource.

Defined in map_editor/client/scene.lua. Use while the editor is active and ready. Generic gamemode scripts should use WorldObjects.request instead. These helpers update the editor document/history only after native acknowledgement.

Helper Contract
MapEditor.CreateObject(meshPath, transform) Returns a reserved string ID or false if rejected locally. The ID is not confirmation that native creation succeeded. Defaults: position/rotation zero, scale 1, visible, unlocked, collision enabled. Optional table overrides defined object fields; preserve generated IDs and valid schema. Mesh must be in the editor catalog.
MapEditor.DeleteObject(id) Returns request acceptance as boolean. Unknown/locked instances, busy/loading or uncertain native state reject. No other resource or original world actor can be deleted.
MapEditor.SetTransform(id, transform) Boolean request acceptance. Partial table of x/y/z, pitch/yaw/roll, sx/sy/sz; omitted fields retain the current document values. Unlike the native update command, this helper fills the complete state. Unknown or locked instances reject.
MapEditor.GetObjects() Deep-copy table keyed by object ID of current editor document records. Not a live engine query. Changing the returned copy does not change the scene; failed-to-render records retained after load can also appear here.

Positions use metres, rotations degrees, scale is a multiplier. Creation/deletion/transform functions are asynchronous; do not chain dependent operations on a newly reserved ID before native completion. Editor UI status and its serialized operation flow report results. The helpers have no independent exported callback parameter.

There are no separate engine MapEditor.SetPosition/SetRotation/SetScale/CloneObject functions. Use SetTransform within the editor, its Duplicate action for GUI duplication, or explicit WorldObjects commands with your own document state in another resource. See Map editor for controls, save/load and limitations.