Running a LUA script through C/C++, how do i do it?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Running a LUA script through C/C++, how do i do it?

Post by sg57 »

i made my credits for my game in LUA for ease and now i wnat to run them through C/C++ without having to redo them in c/c++, so is there osme .elf file or something that i could put with the eboot and call some function for it to load it?, i know its possible becuase of the Lua Player, so what would i do?
MikeDX
Posts: 30
Joined: Wed Oct 19, 2005 9:24 am

Post by MikeDX »

well you could always just execute luaplayer + your script from your main eboot.... and have your script exit cleanly
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

what? i have my credits named credits.lua and in my menu, theres a credits button, so i want my credits to load when pressing X on crdits, so what woudl i do there?

and how could i combine luaplayer with ym mine? they dont give out source code?
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

You can't do it. Or at least, not easily. C++ can't run lua scripts, the only thing you can do is run other programs. Lua Player can run lua scripts(!) so from C++ you need to start the Lua Player program and arrange for Lua Player to execute your credits.lua file, and then for the credits to exit neatly and go back to your C++ program.
1) That's difficult.
2) It might never work cleanly.
3) It'll be slow to launch.

Better either to write the credits in C++, or port the rest of the game to Lua.

Jim
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

alright, i guess il port em, this will be difficult...
charliex
Posts: 16
Joined: Thu Jan 26, 2006 4:03 pm

Post by charliex »

C++ can execute lua scripts, or lua functions, dependant on how luaplayer implemented its psp side of things, you should just be able to include their lua lib equivalent and the liblua and use lua_dofile to parse it

heres a simple example of loading and executing lua from C++

http://tonyandpaige.com/tutorials/lua2.html


presumably luaplayer adds a bunch of PSP glue code, these will need to be included, hopefully its a lua lib.
Post Reply