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:
Kartik K. Agaram 2023-11-12 10:38:42 -08:00
parent 34f286270f
commit 442cfcf057
3 changed files with 9 additions and 7 deletions

View File

@ -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

View File

@ -2,16 +2,15 @@ new_definition = function()
if Cursor_node then if Cursor_node then
Cursor_node.show_cursor = false Cursor_node.show_cursor = false
end end
local p = spawn_point()
table.insert(Definitions, { table.insert(Definitions, {
type='text', type='text',
data={''}, data={''},
x=Spawn_point.x, y=Spawn_point.y, x=p.x, y=p.y,
width=600, width=600,
bg=Definition_background_color, bg=Definition_background_color,
key=#Definitions+1, key=#Definitions+1,
}) })
Viewport.x = Spawn_point.x-30
Viewport.y = Spawn_point.y-30
Cursor_node = Definitions[#Definitions] Cursor_node = Definitions[#Definitions]
Cursor_node.show_cursor = true Cursor_node.show_cursor = true
end end

6
0116-spawn_point Normal file
View File

@ -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