Wait ticks freeze the main loop
Moderators: marionline, SDHawk
Wait ticks freeze the main loop
This is in regards to the Zelda-like. I'm having difficulty coming up with a way to have player actions that don't totally freeze up the main "while true do" loop, so that other things can happen, e.g. a script for an enemy taking damage and being knocked back when the sword slice hits them.
Should I just use wait ticks for one thing, like player actions, then jury rig 'fake' wait ticks by using 1 tick long timers for everything else?
Should I just use wait ticks for one thing, like player actions, then jury rig 'fake' wait ticks by using 1 tick long timers for everything else?
Look into using timers and timer loops (where a set timer() in a script calls that script at the end). If the processes you're trying to do are too complex to use timers, I'm not sure about other solutions.
You shouldn't have to use wait commands other than your wait(1) at the end of each while loop and during cutscenes/textbox scenes. From my experience, using timers takes a lot of planning, at least compared to waits, if you want it to work right on the first try. It ends up being worth it, however. Timers allow the working scripts to essentially take care of themselves.
EDIT: Actually, have you looked at scripts for other OHR zelda-likes? I know there are some out there. I'd check out how they do it before trying anything yourself.
You shouldn't have to use wait commands other than your wait(1) at the end of each while loop and during cutscenes/textbox scenes. From my experience, using timers takes a lot of planning, at least compared to waits, if you want it to work right on the first try. It ends up being worth it, however. Timers allow the working scripts to essentially take care of themselves.
EDIT: Actually, have you looked at scripts for other OHR zelda-likes? I know there are some out there. I'd check out how they do it before trying anything yourself.
Last edited by kylekrack on Fri Nov 18, 2016 10:15 pm, edited 1 time in total.
My pronouns are they/them
Ps. I love my wife
Ps. I love my wife
- Spoonweaver
- Liquid Metal King Slime
- Posts: 6466
- Joined: Mon Dec 08, 2008 7:07 am
- Contact:
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
For example, suppose you make NPC extra value 1 be an ID number indicating what kind of animation the monster is doing, like 1=attacking, 2=hurt
Then make NPC extra value 2 be which step of the animation that the monster is currently on
So each tick you would check each monster, and update their sprite according to those values.
(I do an even more elaborate version of that sort of thing in many of my games. If you want to see full-on fake-object-oriented-scripting, check out my scripts for Don't Eat Soap or Vorpal Florist)
Then make NPC extra value 2 be which step of the animation that the monster is currently on
So each tick you would check each monster, and update their sprite according to those values.
(I do an even more elaborate version of that sort of thing in many of my games. If you want to see full-on fake-object-oriented-scripting, check out my scripts for Don't Eat Soap or Vorpal Florist)
- Spoonweaver
- Liquid Metal King Slime
- Posts: 6466
- Joined: Mon Dec 08, 2008 7:07 am
- Contact:
The script you posted before for the camera scrolling is very easy to convert to timers. You just split it into two scripts: the setup part, which calls:
However, in a zelda-like it's likely that you'll want to have multiple other things happening at the same time, so will end up needing to do things as other people have suggested. (Script multitasking can't come quickly enough!)
Code: Select all
script, eachtick screen edge check, begin
screen edge check
set timer(0,0,1,@eachtick screen edge check) #change id
end
Last edited by TMC on Sat Nov 19, 2016 12:05 am, edited 1 time in total.
Trying to use timers became a hideous mess really fast and none of it worked, so now I'm going to try (i.e. struggle) to work with values per tick.
I'm working on some pseudocode to try to get an understanding of how to manage values per tick/frame, if someone could give feedback on IRC later tonight I'd appreciate it.
I'm working on some pseudocode to try to get an understanding of how to manage values per tick/frame, if someone could give feedback on IRC later tonight I'd appreciate it.