Re: Loading another script
Posted: Thu Jan 05, 2012 10:24 am
You are honestly a little away from the topic ...
Sorry then, when I saw your diagram/fluxogram with jumps between files and using the typical Basic jumping flow style I thought as your friend you came also from BASIC.yarickyarick wrote:Coffey, I'm used to C #
There is a function of starting another level ... I do not remember exactly, but it seems Program.Start (lol), but to use it first in your Program need to register a couple of lines ...
I was hoping for here, too ...
Code: Select all
if b == 100 then
load_code = love.filesystem.load( "code.lua" ) -- this loads the wanted file
run_code = load_code() -- this run the code in that file
end
I suppose yarickyarick wanted to do that "IF" check once or rarely. But you right Robin I see the danger and your point to avoid reloading again and again same file if that "IF" will be a constant check. That way I could have suggested in the same way you did for the "requires":Robin wrote:It might be better to load that code once, and just call it whenever you need, as I explained a while back in this thread.
Code: Select all
load_code = love.filesystem.load( "code.lua" ) -- this loads the wanted file
--
if b == 100 then
run_code = load_code() -- this run the code in that file
end
If you don't do it each frame, loading code is unlikely to have a large impact on performance, though.coffee wrote:But however, let's imagine too that we have to deal with a large multiple choice "if then load x file else if else if" choices. That way would be a bit unwanted have to pre-load unnecessary files before the IF.