Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lua, Java and headaches

Started by Amarth Oct 30, 2006 at 4:23 PM 1 replies 2.5k views
Original Post
Amarth
Amarth
Hello all. I got some questions about integrating Lua and Java with (surprise) LuaJava. I think I kind of got how it works theoretically, but I might be doing things wrong, feel free to point me to the right way. I think my questions are not bounded by Java, so feel free to answer if you're using C++ or something, I'll be able to translate :). First of all, I have the idea that the scripting should allow for lots of modification, but it should be hard to break the game by changing the scripting. Thus, I have implemented most of the important stuff (init, game loop, ...) in Java. Am I right in that decision? The problem I'm facing now is on how to share stuff towards Lua. Let's say, when I start a new level, I want to call a Lua script to generate that level. How do I pass in the necessary objects from Java? I've been looking at the stack, but I don't really see how to access it in Lua (I feel like some sort of important point about Lua is swooshing far over my head, though). Or should I make sure to construct the Java objects in Lua - moving most of the code to Lua instead of Java, and making my program prone to breakage from inexperienced level developers? Or should I use loads of static methods (like with factories and singletons) - those seem easy to call from Lua, but it kind of defeats the purpose of having an object oriented design. Perhaps I'm just searching for all sorts of advice you people can give me about Lua, I don't really know. I feel a bit lost :). All the guides and tutorials and manuals seem to do the basic stuff, and I really don't have an overview of how it all works together... I hope someone can help me move a bit onward. Thanks! -Amarth
OrangyTang
OrangyTang
Quote:
Original post by Amarth
I have the idea that the scripting should allow for lots of modification, but it should be hard to break the game by changing the scripting.

Hmm... I'm not too sure about that. Sure it shouldn't be possible to crash the app due to scripting (as the app should be doing error checking and the like). But you're never going to be able to take a badly written script and magically make it work.

IMHO the most important benifits of scripting is faster development time and greater flexibility.
Amarth
Amarth
Well, yeah, that's kind of what I meant. A program can't keep a script from going into a very long or even endless loop, that would violate basic computability theory :).

Faster development time, well... It's not really feeling like it. But flexibility, yes, THAT's what I'm doing it for :). To allow others to change parts of the game without needing to set up a complex development environment, mostly.

I find it pretty hard to put the line between where the program ends and the scripting starts, and I don't really manage to get this done in a nice way... It's got ugly all over it. Are there examples of not-too-complex games out there that are worth studying? I can't seem to find them...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.