Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

Hi,

So I think the issue is having the pf commands in the root of the script instead of inside an event. I think what's happening is that when palettefade runs, it likely refreshes all the stuff in the root level script, which then gets itself into a loop where it's calling itself over and over. I'm not fully sure myself of the logic of when these are called, generally except for like setting constants (like palettes and such) I put all my logic inside events.

If you put the commands inside the "timepass" event, so that they're only called when this event is called, does that help?


Edit: so I did an experiment with the unlocked version of your deck and this seems to fix things. Remove the setpalette and palettefade commands from the root of the script and put them inside "timepass" like this

on timepass do
 t.value:t.value+1
 if t.value=1           
  pf.setpalette[deck morningpalette]
 elseif t.value=2
  pf.palettefade[deck morningpalette noonpalette 60]
 elseif t.value=3
  pf.palettefade[deck noonpalette sunsetpalette 60]
 else
  pf.palettefade[deck sunsetpalette nightpalette 60]
 end
end
(+1)

Yup, i tried doing the same and it worked perfectly, thank you so much! ✿

Also true, having the logic inside an event seems much safer (especially against unintended consequences like the one i had before), i’m relatively new to programming/writing code but i seem to have a real knack for accidentally creating recursions or infinite rerenders :’D

(+3)

Code you add to the deck-level script is run every time any event is processed. Likewise, code in a card or widget script executes whenever an event is sent to that card (or a widget on the card), or an event is sent to that widget, respectively.

If the top-level script is just defining functions (aka event handlers) and constants this is fine and normal. If there's lots of code it can start to chew up a lot of the per-frame execution quota; this is when you might consider moving some scripts into different cards or modules.

There are some situations where more elaborate "bare" code outside event handlers is useful, but Millie is correct: most of the time, most of your code ought to go inside event handlers so that it only has a chance to start doing things when a specific event occurs.

(+2)

Makes perfect sense, thanks for clarifying! My galaxy brain thought “ah i’ll just put that one if-else in the top-level script so it can constantly and automatically check for the time”, but i definitely see how this kind of uncontrolled approach could very easily backfire, i’ll keep it in mind for the future :)