Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swarnimarun
Created June 5, 2019 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swarnimarun/53d1f67e53b000ca069b30f1772aadd3 to your computer and use it in GitHub Desktop.
Save swarnimarun/53d1f67e53b000ca069b30f1772aadd3 to your computer and use it in GitHub Desktop.
Yield GDScript Simple quiz
extends Node
func my_looper():
for x in 4:
yield()
print("I am %sx awesome" % x)
func _ready():
var v = my_looper()
# Question 1: HOW WILL WE CALL ALL THE SUBROUTINES ?
# OPTION 1!
# v.resume()
# v.resume()
# v.resume() ... until all the FunctionState is empty
# OPTION 2!
# v.resume().resume() ... for every FunctionState returned
# OPTION 3!
# v.resume() .. doing it once is enough
extends Node
func my_looper():
for x in 4:
yield()
print("I am %sx awesome" % x)
func _ready():
var v = my_looper()
v.resume().resume().resume().resume() # 4 times for all the executions combined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment