Hi, guys!
I'm from Ukraine, so don `t know English, I will rely on its leash basic knowledge of the language ... Immediately ask forgiveness for the poor knowledge of English ...
I'm 15 years old and my name is Yaroslav!
Now to business ...
I started razrabatovat their first game at Love (Previously, he worked only for Basic and C like) and collided with a problem that occurs in support of several scripts, is not very convenient to load a script from a file into a file and there propisovat believe that all zanogo ... I do not see the difference between downloading the file and write the code directly into the main script ...
I think it would be much more convenient to write this function love.run.script ("script.lua") and it made a transition to another script, you will agree it's much easier ... though not in all cases, but most ...
I and many will be very happy if you do it.
Thanks in advance!
PS I wish you happiness, joy and all the Keep it in the new year and may have already passed your Christmas to you all!
Sincerely, Yaroslav.
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:
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Loading another script
I think you're talking about require.
Re: Loading another script
Wait, you can use require to jump to a file and later come back? In the middle of any function?
Sounds like a GOTO. Which is definately not classy, but sometimes useful xD
Sounds like a GOTO. Which is definately not classy, but sometimes useful xD
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
I would be interested to see it in Love, but not in direct Lua ...
By the way obviously looked at what you showed me a leash require loading the script file, but I tell you about the transition between the scripts ...
By the way obviously looked at what you showed me a leash require loading the script file, but I tell you about the transition between the scripts ...
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Loading another script
It loads and runs the file, because that how an interpreter works, everything on the top level will be executed (but more importantly, functions will be defined).
Also, this works for love as well, lua's require supports adding searchers, and that's exactly what we've done.
Also, this works for love as well, lua's require supports adding searchers, and that's exactly what we've done.
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
Hmm ...
Well then I apologize ... My friend just told me that there is a leash one way, so that complex + Question: If you put the expression in the events provided (the one in the "if" after "then"), it also runs another script? Without error?
Well then I apologize ... My friend just told me that there is a leash one way, so that complex + Question: If you put the expression in the events provided (the one in the "if" after "then"), it also runs another script? Without error?
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
Code: Select all
if blabla = 123
then
require script.lua
end
this will allow me to immediately perform all the functions of the script, without the functions of this script?
Ie how to transition from one file to the second ...
bottles as a transition between levels in the game ...
__________________________________
And I apologize that there was no these 3 days ...
Just did not have access to your site, because of its provider ...
Re: Loading another script
I think I understand your question.
If that is what you are asking, then yes.
Code: Select all
-- File script.lua
local function A(n)
return n * n
end
local function B(n)
return A(5) + n
end
return B(7)
Code: Select all
-- In main.lua
if varA == 100 then
varB = require "script"
end
-
- Prole
- Posts: 15
- Joined: Fri Dec 30, 2011 9:48 pm
- Contact:
Re: Loading another script
I did not understand a bit and then n * n, VarB and the like ...
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests