forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

include in lua

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Aug 23, 2005 3:34 am    Post subject: include in lua Reply with quote

i read the following:
The require Function
i am not sure if it is what i am searching for...
i guess it executes the lua file as it is required.

what i am asking is it possible to use another lua file (same as in php, java or c/c++ by include?)
so that i can use functions from this file when i want?

greets
LuMo, who is totally new to lua
Back to top
View user's profile Send private message Visit poster's website
Benihana



Joined: 31 Jul 2005
Posts: 12

PostPosted: Tue Aug 23, 2005 4:22 am    Post subject: Reply with quote

You have probably figured it out by now, but:

"...require does the same job as dofile, but with two important differences. First, require searches for the file in a path; second, require controls whether a file has already been run to avoid duplicating the work." - Programming in Lua

So basically use dofile unless you need to search for the file dynamically and you want to load the code several times.

Not sure why you would want to do this...I really would recommend sticking to one file. Do you have some Lua Libraries you are developing?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Aug 23, 2005 4:29 am    Post subject: Reply with quote

nah, i just write on one little game
but code grows when you get into details
code has now 1200 lines (with comments)

and i am used to have no files larger than max 500 lines
so i get lost in the huge amount...

greets
Back to top
View user's profile Send private message Visit poster's website
Benihana



Joined: 31 Jul 2005
Posts: 12

PostPosted: Tue Aug 23, 2005 4:50 am    Post subject: Reply with quote

You can always use a comment line with asterisks across it, or some other deliniater. If I have reusable code I keep it seperate from the games code by doing such. Also, I HOPE you are using a Lua dev...there are a few out there. I use find a lot...would be nice to have a IDE with a little search box at the bottom like Firefox.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group