Created
May 30, 2025 18:20
-
-
Save Achie72/adf31b2178ed57fb5cd18502e55ff64e to your computer and use it in GitHub Desktop.
Having a pool of upcoming items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made for devlog about Daily Verse: https://ko-fi.com/post/Daily-Verse-2-PPJJGG-4--Gridwork-and-leftover-P5P71FR30J