Using 2 .Lua's together

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Using 2 .Lua's together

Post by haxx_blaster »

If i do a (dofile "game.lua") can i from that Game.Lua get etc "Base" from the lua i came from?
Between index.lua and game.lua

I really need help with this, either i am stuck. :P
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

How hard would that be to find out ??

You might need a startup program that is never revisited to set initial
values of variables, load pics, etc so they don't happen again, but
after that I don't see why you can't jump from one file to another.

The only problem I have found is that the file is loaded from memory
stick each time, even if it has already been loaded to RAM.
This will cause things to slow down while moving from one file to another.

Traditionaly, new data is loaded between levels of a game.
Art.
CaptainChickenpants
Posts: 5
Joined: Wed Feb 01, 2006 2:29 am

Post by CaptainChickenpants »

Dofile isn't the only method for running other scripts.
http://www.lua.org/pil/8.html

CC
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Post by haxx_blaster »

Art wrote:How hard would that be to find out ??

You might need a startup program that is never revisited to set initial
values of variables, load pics, etc so they don't happen again, but
after that I don't see why you can't jump from one file to another.

The only problem I have found is that the file is loaded from memory
stick each time, even if it has already been loaded to RAM.
This will cause things to slow down while moving from one file to another.

Traditionaly, new data is loaded between levels of a game.
Art.
I have tryed to change "BGSound" to "BGSound2" from Menu.lua when "BGSound" is loaded from Game.lua And i diden't work at all.
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Post by haxx_blaster »

I got it to work with another lua file, i will do it throught 3 lua files then.
fattymc03
Posts: 18
Joined: Sat Feb 11, 2006 12:22 am

Post by fattymc03 »

you want to use: require "filename.lua" at the top of your program

that kinda creates a package. you'll be able to access anything in filename.lua from whatever file you put that line in
Post Reply