Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

yarickyarick wrote:I did not understand a bit and then n * n, VarB and the like ...
function A(n) just multiplies n by itself (n^2).
function B(n) calls function A with 5 (which returns 25) and adds n to it.
The return B(7) is called whenever you attempt to load the script.

So if "blabla == 100" then call the script and get the value of B(7)...in our case: 25 + 7 = 32.

I know a lot of people on here are from Europe. I'm surprised there isn't another Ukrainian here to help you out with the translation.
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

So, I think to answer your original question if you did something like:

Code: Select all

-- In file script.lua
function callFunctions()
A()
B()
C()
D()
end

function A()
-- stuff
end

function B()
-- stuff
end

function C()
-- stuff
end

function D()
-- stuff
end

return callFunctions()
Then in main.lua you did:

Code: Select all

if blabla == 100 then
require "script.lua"
end
You could run a bunch of other functions just by loading another script.
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

MarekkPie wrote:
yarickyarick wrote:I did not understand a bit and then n * n, VarB and the like ...
function A(n) just multiplies n by itself (n^2).
function B(n) calls function A with 5 (which returns 25) and adds n to it.
The return B(7) is called whenever you attempt to load the script.

So if "blabla == 100" then call the script and get the value of B(7)...in our case: 25 + 7 = 32.

MarekkPie wrote:So, I think to answer your original question if you did something like:

Code: Select all

-- In file script.lua
function callFunctions()
A()
B()
C()
D()
end

function A()
-- stuff
end

function B()
-- stuff
end

function C()
-- stuff
end

function D()
-- stuff
end

return callFunctions()
Then in main.lua you did:

Code: Select all

if blabla == 100 then
require "script.lua"
end
You could run a bunch of other functions just by loading another script.
Well, I talk to many European languages ​​...
But the English language I have never succumbed to ... to my surprise, English and Russian language almost identical, but the Ukrainian language (As for me a simplified version of the Russian language for Europeans ...) just did is very different from English ... And especially in your language does not give me time continuum of words
You have too many ...
Past from the future ...
Past from present, and so on ...

even as examples of the similarity of Russian and English:

December = Декабрь(Deckabr)
November = Ноябрь(Noyabr)
January = Январь(Janvar)
And so on ...

Well, I can hardly be so ...
I have many advanced features introduced ...
This is simply not normal mentally ... as for me just a computer can not survive every second check, for example, or clicked in some of those coordinates, and so on ...
If you click it private, a heavy load on the application after which the average PC will not sustain the load and simply shut down or burn out (Well, if you click "with the speed of light" and possibly burn Comp)
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Yeah, I've heard the "tenses" (I think you called it the time continuum of words) is what confuses non-English speakers.

To eat, in all the tenses I can think of right now (it's 2 AM here):

He has eaten... (also already done)
He will have eaten... (referring to some time in the future AFTER he is done)
He had eaten... (referring to the time in the past after he was done)
He eats... (is doing it now)
He will eat... (referring to some time in the future BEFORE he is done)

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

A better solution is:

Code: Select all

--main.lua:
require 'script'

-- ....
if b == 100 then
someFunction()
end

Code: Select all

--script.lua
function someFunction()
--- put the script here
end
This way, the script is reusable. If you have other functions in script.lua, but them above or under someFunction(), not inside of it.
yarickyarick
Prole
Posts: 15
Joined: Fri Dec 30, 2011 9:48 pm
Contact:

The hierarchy of the fact that I want to create one ...
Иерархия.png (13.69 KiB) Viewed 1353 times
Please do contact me in Skype, ICQ, jabber or Agent (Though he hardly you have, since the program greate Russian developer company mail.ru) to explain in detail I could the problem and complete source code as something that is impossible for me in this case ...
My skype: g.man024
My ICQ: 643754338
My Agent: yarickyarick@mail.ru
My jabber: yarickyarick@jabber.ru
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

nevon wrote:I think you're talking about require.
require() caches its result, so if you do:

Code: Select all

require('file.lua')
require('file.lua')

then the file will be read only once. This is on purpose, because require() is usually used to load pieces of code (like classes).

If you really want to make sure the file is read in every time, you should use dofile().
But that would be bad design, as other pointed out, it is better to read all files once as needed (to define some functions), and then execute different functions according to the game logic.

I think you are looking for a GameState solution: http://love2d.org/forums/viewtopic.php? ... =gamestate
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

miko wrote: you should use dofile().
Well no, couldn't be more wrong. love.filesystem.load is what is to be used, not dofile.
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

bartbes wrote:
miko wrote: you should use dofile().
Well no, couldn't be more wrong. love.filesystem.load is what is to be used, not dofile.
Oh, right, dofile() would be for plain lua.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm