Loading another script
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
You are honestly a little away from the topic ...
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
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 ...
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 ...
Re: Loading another script
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 ...
Anyway back to topic, imho I don't think that the "require" is what you looking for but more something like is used for loading and execute pieces of code where data must be loaded in program. I would it do this way:
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
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
Coffey, if needed, try =)
And now completed yet editor of the character: 3
And now completed yet editor of the character: 3
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Loading another script
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.
Help us help you: attach a .love.
Re: Loading another script
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Loading another script
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.
Compared to images and sounds, for instance.
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 7 guests