115 posts
Posted 25 July 2015 - 04:55 AM
I'm working on a platformer. And I tried using parallel.waitForAll for the collision (Otherloop()) + moving (Mainloop())
And it doesn't seem to work, it's about bed time for me, so I won't be able to respond to you all, but here's the code:
http://pastebin.com/ueZqGpBGPlease help! (It's 12:00 over here)
Edited on 25 July 2015 - 03:02 AM
86 posts
Posted 25 July 2015 - 05:51 AM
You're calling the function by using Gameloop() you need to pass the function iteslf by just using the name Gameloop
957 posts
Location
Web Development
Posted 25 July 2015 - 07:17 AM
You're calling the function by using Gameloop() you need to pass the function iteslf by just using the name Gameloop
To expand on that a bit:
local function testFunc()
print("test")
end
type( testFunc ) --#> function
type( testFunc() ) --#> nil (It doesn't return anything, if it returned something, obviously this would give you that type)
The parallel API needs the FUNCTION value, so it can run the function itself.
Edited on 25 July 2015 - 05:18 AM
7083 posts
Location
Tasmania (AU)
Posted 25 July 2015 - 08:23 AM
You've also got your Gameloop / Otherloop functions calling themselves recursively. Use "while" loops instead.
http://lua-users.org/wiki/ControlStructureTutorial
115 posts
Posted 25 July 2015 - 01:40 PM
You've also got your Gameloop / Otherloop functions calling themselves recursively. Use "while" loops instead.
http://lua-users.org...ructureTutorial
I know what while loops are, I just challenged myself by making a video game without using any loops.
Platformer it is!
Also, thanks to everyone who told me how I messed up :P/>
Edited on 25 July 2015 - 11:44 AM
1426 posts
Location
Does anyone put something serious here?
Posted 25 July 2015 - 01:57 PM
I know what while loops are, I just challenged myself by making a video game without using any loops.
Platformer it is!
You'll probably want to use
tail calls:
-- Produces a stack overflow - too many nested functions
local function foo()
-- do something ...
foo()
end
-- Works fine
local function foo()
--do something
return foo()
end