Skip to content

Commit

Permalink
Allow loading scripts which generate blueprints.
Browse files Browse the repository at this point in the history
  • Loading branch information
justarandomgeek committed Jun 17, 2016
1 parent c1cbfbc commit bb680de
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion control.lua
Expand Up @@ -438,6 +438,9 @@ function createNewBlueprintWindow(gui, blueprintName)

flow = frame.add({type="flow", name="blueprintNewFixFlow", direction="horizontal"})
flow.add({type="checkbox", name="fixPositions", caption="fix positions", state = true})

flow = frame.add({type="flow", name="blueprintNewUnsafeFlow", direction="horizontal"})
flow.add({type="checkbox", name="unsafe", caption="allow scripts (unsafe!)", state = false})

flow = frame.add({type="flow", name="blueprintNewButtonFlow", direction="horizontal"})
flow.add({type="button", name="blueprintNewCancel", caption={"btn-cancel"}})
Expand Down Expand Up @@ -684,7 +687,12 @@ local function on_gui_click(event)
else
-- read pasted string
if string.starts_with(importString, "do local") then
blueprintData = BlueprintString.load(importString)
local unsafe = event.element.parent.parent.blueprintNewUnsafeFlow.unsafe.state
if unsafe then
blueprintData = loadstring(importString)()
else
blueprintData = BlueprintString.load(importString)
end
if blueprintData then
blueprintData = deserializeBlueprintData(blueprintData)
end
Expand Down

0 comments on commit bb680de

Please sign in to comment.