|
|
|
 |
Reply From: |
Zylann |
Using two match
one after the other should work fine. Something is probably wrong in the code you hinted in #match and do stuff
, would be interesting to see it.
Hmm, I think I’m seeing the issue in my code, but I don’t know the work around.
Essentially it’s this:
var a
var b
_process(delta):
_myfunction(delta)
_myfunction(delta):
match a:
"yes":
#do something
if circumstances_met:
return
#do more things
"no":
#do something
if circumstances_met:
return
#do more things
match b:
"yes":
#do something
if circumstances_met:
return
#do more things
"no":
#do something
if circumstances_met:
return
#do more things
I think the return
on the first match
is causing it not to run the second match
.
Then… don’t return? Use an else
if you don’t want to run the #do more things
Zylann | 2020-04-02 22:32
I’m using the return to keep _process from accessing those things. Making it so it accesses it only once:
Sample code:
if p1_action1 == true:
return
p1_action1 = true
yield(get_tree().create_timer(sec),"timeout")
p1_pos = $Player1.transform
p1_cmd1 = "clear"
t = 0.0
p1_action1 = false
if dodge == true:
dodge = false
Unless there is a better way of doing this?
edit To be clear, I need _process for part of the function and need it to be a one shot for the other.
This?
if p1_action1 == true:
return
else:
p1_action1 = true
yield(get_tree().create_timer(sec),"timeout")
p1_pos = $Player1.transform
p1_cmd1 = "clear"
t = 0.0
p1_action1 = false
if dodge == true:
dodge = false
An alternative is to put each match in a function and call them both in _process
, so you can use return
to go back to _process
. match
has little to do with all this, really, you could even have used an if
to check a
abd b
Zylann | 2020-04-02 22:40
Adding else:
makes the function do the same thing. Because although I’m having the 2nd half called once, the first half I need to remain being called, since it’s moving the player. The return
part of it, is simply a lock to make sure it only accesses the whole function once on the first go, the yield
makes it wait till the movement is done, then it sets all the necessary variables.
I do have them in separate functions right now, but it causes this issue with one playing a frame earlier than the other (I know it’s only a frame, but it’s making other issues). If I can get them both in the same function, then it’ll play at the same time.

Hey Zylann, I’ll figure out a work around. Ultimately you solved the initial answer and helped me see that the issue isn’t with match
, but my own script. Thanks for trying to go above and beyond.