Log In  


Cart #bidefuraki-0 | 2022-05-29 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Why?

I bought pico 8 a while ago and have never really messed around with it all that much, finally I decided that I wanted to try something so I made this game :D

Programming challenges

The programming went fairly smoothly, however there were some interesting issues that I had to think of solutions for. The issue that immediately comes to mind is when trying to remove something from a object in a for loop, this seems straight forward but when you try, the for loop then tries to go to a removed value and the program gives you an error. I was able to deal with this by creating another object and storing all of the indexes of the object that had to be removed inside of it, once the first for loop had ran that added the indexes I ran another for loop that looped through the object of indexes and removed them from the original object

--the object
object = {
   thingo = {
      should_be_deleted=true
   }
}

--loop that adds indexes
_d = {}
for i=1,#object,1
do
   if object[i].should_be_deleted==true then
      add(_d, i)
   end
end

--loop that deletes from object
for i=1,#_d,1
do
   del(object, object[_d[i]])
end



[Please log in to post a comment]