you can now edit archetype and args of spawns in editor with "t" and "d" when selected, respectively
This commit is contained in:
@@ -22,6 +22,7 @@ end
|
||||
|
||||
function selectSpawns(x,y)
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
local left = spawn.args[1] - Camera.pos.x - offset_x
|
||||
local top = spawn.args[2] - Camera.pos.y - offset_y
|
||||
@@ -54,6 +55,73 @@ function moveSpawns(x,y)
|
||||
end
|
||||
end
|
||||
|
||||
function promptSpawnArchetype()
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt.canceled = true
|
||||
end
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
if spawn.selected then
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
local text = ""
|
||||
for i=1, #spawn.args do
|
||||
if i > 1 then text = text .. ", " end
|
||||
text = text .. tostring(spawn.args[i])
|
||||
end
|
||||
local prompt = Prompt:new({
|
||||
name = "archetype",
|
||||
input = spawn.archetype.type,
|
||||
spawn = spawn,
|
||||
func = function(prompt)
|
||||
local arch = spawn.archetype
|
||||
print("return "..prompt.input)
|
||||
local f = loadstring("return "..prompt.input)
|
||||
if f == nil then
|
||||
spawn.archetype = arch
|
||||
else
|
||||
spawn.archetype = f()
|
||||
end
|
||||
end,
|
||||
})
|
||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
||||
prompt:activate()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function promptSpawnArgs()
|
||||
if Prompt.active_prompt then
|
||||
Prompt.active_prompt.canceled = true
|
||||
end
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
if spawn.selected then
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
local text = ""
|
||||
for i=1, #spawn.args do
|
||||
if i > 1 then text = text .. ", " end
|
||||
text = text .. tostring(spawn.args[i])
|
||||
end
|
||||
local prompt = Prompt:new({
|
||||
name = "args",
|
||||
input = text,
|
||||
func = function(prompt)
|
||||
|
||||
local f = loadstring("return {"..prompt.input.."}")
|
||||
|
||||
if f == nil then
|
||||
spawn.args = arch
|
||||
else
|
||||
spawn.args = f()
|
||||
end
|
||||
end,
|
||||
})
|
||||
prompt.pos.x = spawn.args[1] - Camera.pos.x - offset_x
|
||||
prompt.pos.y = spawn.args[2] - Camera.pos.y - offset_y
|
||||
prompt:activate()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawSpawns()
|
||||
for _, spawn in pairs(LoadedObjects.Spawns) do
|
||||
local offset_x, offset_y = spawn.archetype.display:getCenteredOffset()
|
||||
@@ -63,6 +131,7 @@ function drawSpawns()
|
||||
spawn.args[2] - Camera.pos.y - offset_y
|
||||
)
|
||||
|
||||
|
||||
if spawn.selected then
|
||||
love.graphics.setColor(0,1,1,1)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user