spawn nodes randomly within the current viewport
This was so easy! I should have done this months ago! So much slogging new nodes across the work surface.
This commit is contained in:
parent
34f286270f
commit
442cfcf057
|
@ -1,3 +0,0 @@
|
|||
Spawn_point = {x=0, y=0}
|
||||
-- idea: command to move the spawn point around
|
||||
-- but we don't have a command palette yet
|
|
@ -2,16 +2,15 @@ new_definition = function()
|
|||
if Cursor_node then
|
||||
Cursor_node.show_cursor = false
|
||||
end
|
||||
local p = spawn_point()
|
||||
table.insert(Definitions, {
|
||||
type='text',
|
||||
data={''},
|
||||
x=Spawn_point.x, y=Spawn_point.y,
|
||||
x=p.x, y=p.y,
|
||||
width=600,
|
||||
bg=Definition_background_color,
|
||||
key=#Definitions+1,
|
||||
})
|
||||
Viewport.x = Spawn_point.x-30
|
||||
Viewport.y = Spawn_point.y-30
|
||||
Cursor_node = Definitions[#Definitions]
|
||||
Cursor_node.show_cursor = true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
spawn_point = function()
|
||||
return {
|
||||
x = math.random(Viewport.x, Viewport.x+Viewport.w),
|
||||
y = math.random(Viewport.y, Viewport.y+Viewport.h),
|
||||
}
|
||||
end
|
Loading…
Reference in New Issue