Making a day/night cycle help

I'm working on a small adventure game and I would like to add a day and night, I'm not very good at coding, I know I would have to use the invert code but I am unable to get it to switch after a certain amount of time, Any help is appreciated, thanks!

You can use wait to call some code after an amount of time.

One way to make something repeat is to make an event that waits and then calls itself.

on repeat do
    wait 5 then
        call "repeat"
    end
end

This is an example of infinite recursion - you only need to call it once and it will then keep calling itself every 5 seconds.

If you add invert after the wait then you will have some code that inverts the display every 5 seconds, which sounds a bit like what you want - although you'd probably want it to wait for longer than 5 seconds!

This works! thanks so much!

1 Like