Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

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!
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.
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.
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

I think you're talking about require.
Ellohir
Party member
Posts: 235
Joined: Sat Oct 22, 2011 11:12 pm

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
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

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 ...
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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.
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

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?
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

Code: Select all

if blabla = 123
then
require script.lua
end
You can do this?
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 ...
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

I think I understand your question.

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`
If that is what you are asking, then yes.
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact: