Skip to content

Instantly share code, notes, and snippets.

@Achie72
Created May 30, 2025 18:20
Show Gist options
  • Save Achie72/adf31b2178ed57fb5cd18502e55ff64e to your computer and use it in GitHub Desktop.
Save Achie72/adf31b2178ed57fb5cd18502e55ff64e to your computer and use it in GitHub Desktop.
Having a pool of upcoming items
if btnp(4) then
local index = cursor.y*10+cursor.x
-- placing something will have to consider if it is an empty spot
-- and if we still have something to place (in hand is > 0 in id)
if (space_map[index] == vacant) and (in_hand_object != 0) then
-- if so place it
space_map[cursor.y*10+cursor.x] = in_hand_object
-- set our hand to "empty"
in_hand_object = 0
-- only add objecst to hand if we still have them in pool
-- if so, take out the first and add it to hand
if #upcoming_items > 0 then
in_hand_object = deli(upcoming_items, 1)
end
-- only add objecst to the upcoming pool if we still have some left
if items_left > 0 then
-- add a random item to there
add(upcoming_items, rnd({1,2,3,4,5,6}))
--decrease what is left
items_left -= 1
end
end
end
@Achie72
Copy link
Author

Achie72 commented May 30, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment