if FirstLoad then -- settings taken into account by SelectRoomComponents & PlaceRoomGuides statements, if specified ExtrasGenParams = { North = true, South = true, East = true, West = true } end function GenExtras(id, initial_selection, seed) SuspendPassEdits("GenExtras") XEditorUndo:BeginOp{ name = id } ExtrasGenPrgs[id](seed, initial_selection) XEditorUndo:EndOp() ResumePassEdits("GenExtras") end DefineClass.ExtrasGen = { __parents = { "PrgPreset" }, properties = { { id = "Params", editor = false }, { id = "ToolbarSection", editor = "combo", default = "", items = function(self) return PresetsPropCombo("ExtrasGen", "ToolbarSection", "") end, }, { id = "Shortcut", editor = "shortcut", default = "", }, { id = "Shortcut2", editor = "shortcut", default = "", }, { id = "RequiresClass", editor = "choice", default = "", items = { "", "Slab", "EditorLineGuide", "Room" }, }, { id = "RequiresGuideType", editor = "choice", default = "", items = { "", "Horizontal", "Vertical" }, }, }, EditorMenubarName = "ExtrasGen Presets", EditorMenubar = "Map", EditorShortcut = "Ctrl-Alt-G", EditorIcon = "CommonAssets/UI/Icons/atom molecule science.png", Params = { "initial_selection" }, StatementTags = { "Basics", "Objects", "ExtrasGen" }, FuncTable = "ExtrasGenPrgs", GlobalMap = "ExtrasGenPresets", } function ExtrasGen:GenerateCodeAtFunctionStart(code) code:append("\tinitial_selection = initial_selection or editor.GetSel()\n") PrgPreset.GenerateCodeAtFunctionStart(self, code) end function ExtrasGen.FindPrgStatement(id_or_self, classes, prop_id, value, fn) local ret = false local prg = IsKindOf(id_or_self, "ExtrasGen") and id_or_self or ExtrasGenPresets[id_or_self] if prg then prg:ForEachSubObject("PrgStatement", function(obj) if IsKindOfClasses(obj, unpack_params(classes)) and (not prop_id or obj[prop_id] == value) and (not fn or fn(obj)) then ret = true end end) end return ret end function OnMsg.ShortcutsReloaded() local directions = { "North", "South", "East", "West" } local LayDecalsAlongGuide = { "LayDecalsAlongGuide" } local PlaceRoomGuides = { "PlaceRoomGuides" } local function check_relation(prg1, prg2) if prg1.ToolbarSection == "Room" or prg2.ToolbarSection == "Room" then return false end return prg1:FindPrgStatement(LayDecalsAlongGuide) and prg2:FindPrgStatement(PlaceRoomGuides, "Direction", "Inwards (wall)") or prg1.RequiresGuideType == "Horizontal" and prg2:FindPrgStatement(PlaceRoomGuides, "Direction", "Outwards (room)") or prg1.RequiresGuideType == "Vertical" and prg2:FindPrgStatement(PlaceRoomGuides, "Horizontal", false, function(obj) return obj.PlaceOn:starts_with("Wall") end) end ForEachPreset("ExtrasGen", function(prg) if prg.ToolbarSection ~= "" then XAction:new({ ActionId = prg.id, ActionName = prg.Shortcut ~= "" and prg.id.."