Garry's Mod

Garry's Mod

Momo's Map Manipulation Tool
 This topic has been pinned, so it's probably important
Cédric GÉRILLE [GiletJaune]  [developer] 4 Mar, 2020 @ 1:06pm
Events "map_manipulation_tool:moveEntitiesToLua:....."
Event "map_manipulation_tool:moveEntitiesToLua:moveToLua"
The button Remove many entities & put them into a Lua file runs the event "map_manipulation_tool:moveEntitiesToLua:moveToLua" for every entity in the LUMP_ENTITIES. The default decision is to move only entities that seem safe to be re-created with Lua code. That is, entities of known safe classes, entities with a class name starting with item_, npc_ and weapon_ and entities with a model that is not empty or built-in (starting with an asterisk *).
A hook can be created like this:
hook.Add( "map_manipulation_tool:moveEntitiesToLua:moveToLua", "My hook", function( mapOriginalName, classname, model, moveToLuaByDefault, entityKeyValues, targetname ) -- mapOriginalName: original map file name without extension; example: "gm_construct" -- classname: entity class name; example: "prop_door_rotating" -- model: entity model (nil if the entity class does not have this property); example "model/player.mdl" -- moveToLuaByDefault: default decision; example: true -- entityKeyValues: the table returned by util.KeyValuesToTablePreserveOrder( keyvals, false, true ) -- targetname: name of the entity in Hammer Editor (nil if unset) -- Return true to move the entity to Lua. -- Return false to keep the entity in the map file. -- Return nothing to maintain the default decision. end )
Event "map_manipulation_tool:moveEntitiesToLua:respawned"
The button Remove many entities & put them into a Lua file runs the event "map_manipulation_tool:moveEntitiesToLua:respawned" for every entity in the LUMP_ENTITIES that is not moved into Lua. The default decision is to Spawn() again only entities that supposedly may need to be respawned because they may depend on entities that were not created yet during in-lump entities creation. For now the involved classes are: func_areaportalwindow, point_template, and those starting with filter_, func_ and logic_.
A hook can be created like this:
hook.Add( "map_manipulation_tool:moveEntitiesToLua:respawned", "My hook", function( mapOriginalName, classname, targetname, respawnedByDefault, entityKeyValues ) -- mapOriginalName: original map file name without extension; example: "gm_construct" -- classname: entity class name; example: "prop_door_rotating" -- targetname: name of the entity in Hammer Editor (nil if unset) -- respawnedByDefault: default decision; example: true -- entityKeyValues: the table returned by util.KeyValuesToTablePreserveOrder( keyvals, false, true ) -- Return true to Spawn() again the entity. -- Return false to avoid Spawn()ing again the entity. -- Return nothing to maintain the default decision. end )
Last edited by Cédric GÉRILLE [GiletJaune]; 17 Nov, 2020 @ 7:07am