Page 1 of 1

Include enquiry...

Posted: Thu Oct 09, 2008 9:58 pm
by DarkP
Can I actually do like this?

main code

Code: Select all

[bla bla bla]

if (class == MELEE) then
   include("melee.lua");
elseif (class == RANGED) then
   include("ranged.lua");
end

[bla bla bla]

function main()
   while(1) do
      mainloop()
   end
end
While the mainloop function resides in both melee.lua and ranged.lua? So different mainloop can be created for each class...

melee.lua & ranged.lua

Code: Select all

function mainloop()
    [bla bla bla]
end

Re: Include enquiry...

Posted: Thu Oct 09, 2008 10:06 pm
by Administrator
Yes. Lua can be strange when it comes to prototyping functions, so I would suggest NOT creating a default mainloop() and to do exactly like in your own example.