Code: Select all
n = {}
prt = "hello"
n[1] = Function() DebugPrint(prt) EndFunction
prt = "world"
n[2] = Function() DebugPrint(prt) EndFunction
n[1]()
n[2]()
Code: Select all
n = {}
prt = "hello"
n[1] = Function() DebugPrint(prt) EndFunction
prt = "world"
n[2] = Function() DebugPrint(prt) EndFunction
n[1]()
n[2]()
Code: Select all
n = {}
Local prt = "hello"
n[1] = Function() DebugPrint(prt) EndFunction
Local prt = "world"
n[2] = Function() DebugPrint(prt) EndFunction
n[1]()
n[2]()
Code: Select all
for n = 5 to 1 step-1
if n=5
endfunc = function() OneToUseAfterLastStep endfunction
else
endfunc = function() CreateNextStep(n, n+1, EndFunc) endfunction
endif
next
CreateNextStep(n, n+1, EndFunc)
Code: Select all
CreateNextStep(1, 2, EndFunc(with step 2 args)
CreateNextSTep(2, 3, EndFunc(with step 3 args)
CreateNextStep(3, 4, EndFunc(with step 4 args)
CreateNextStep(4, 5, EndFunc(with last step args)
Code: Select all
If taskfinished=true
self.EndFunc()
@AndreasBugala wrote: ↑Mon Dec 21, 2020 5:24 pm hmm.. This is interesting. I didnt expect this to work just by changing them to local, but it does:
Is this really a safe way to do it, or is there a chance that garbage collecting will remove n[1] prt state away?Code: Select all
n = {} Local prt = "hello" n[1] = Function() DebugPrint(prt) EndFunction Local prt = "world" n[2] = Function() DebugPrint(prt) EndFunction n[1]() n[2]()
For it seems strange to me that putting them both to local makes it work, but using only one local declaration doesn't make it work.
Trust me, it's a nightmare! If you want to use OOP, why not just make move function for a single move step? If your unit moves five times, you just call it five times? Plain and simple, easy to follow and debug, If needed.
Handle movement one step at a time, you can animate during render loop! Keep it simple!Bugala wrote: ↑Sun Dec 27, 2020 4:27 pm Easy so far, but problem comes that I cant initiate each step at same time, or even one after another, but things happen first.
Like when that one movement is happening, there is moving animation. And problem with that is that once again the moving animation is not happening alone, but all other things need to be happening at same time too. Like other animations in that game need to be working at the same time.