1
\$\begingroup\$

So, I want it to be very easy to create all the entities of my game and for other people to come in and do the same. I was thinking I could just let the users/myself create an XML sheet the stores all the properties of each block (Like a Terraria or Minecraft voxel) and add Lua scripts that are referenced in the XML for additional functionality of any of the blocks.

I'm starting to think It would just be easier to let the user create a JAR file full of classes for each block. And then that JAR file could easily be used to get all the blocks. It'd just be interesting to reference all the blocks by a block id without storing all the classes by ID. Or I could give each class a static id. But that's not important.

Okay, so my short question is what are the pros and cons of storing all the the different types of blocks as classes versus in an XML sheet with Lua for additional functionality?

UPDATE: I will probably go for the only use Lua approach. I found about it just recently and it appears like it could be the best method as of right now for me!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ If I were to MOD your game, I'd prefer it was as simple as possible. Editing some XMLs and having a reference of all the Lua scripts I can call sounds just about right. \$\endgroup\$
    – user15805
    Commented Sep 5, 2013 at 12:12
  • \$\begingroup\$ Would you like elaborating? Your feedback as it is now is useful but I'd like more insight :) \$\endgroup\$ Commented Sep 5, 2013 at 12:24

2 Answers 2

2
\$\begingroup\$

The first thing to do here is consider yourself. You, just like your end users, will want to add functionality to blocks. So, think how you would most like to add the functionality. Most likely, if you find it simple and efficient, then the modders will too.

JAR Files

  • Pros

    • More possibilities for functionality.
    • Linking in of 3rd party libraries.
    • Lots of tools (potentially debugging).
    • Compiler (can flag errors before you run the application).
    • Possibility to link in 3rd party libraries.
  • Cons

    • More complex (less accessible to the layman).
    • Security concerns.
    • System API needs to be clean and well documented.

LUA

  • Pros

    • Easier for the layman.
    • More control over potential functionality.
    • Less security concerns.
    • Forces mod code to be in a human readable format (users can read and extend mods they like).
    • Can be easily reloaded at runtime.
    • Option to provide an in game command line environment for writing/testing scripts during gameplay.
  • Cons

    • Limited extensibility compared to JAR files (fewer possibilities for functionality).
    • No compiler checking for errors.

Note

If you add functionality by writing straight to your code base then you may simply want to consider just going open source. If you do go open source then user's won't be able to pick and choose the mods they want or share them as easily, but you may also find that the community is willing to help further develop your game in more ways than you currently have in mind.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks so much. I'll definitely have some thinking to do :P \$\endgroup\$ Commented Sep 5, 2013 at 18:15
  • \$\begingroup\$ What security concerns do you feel that there are? \$\endgroup\$ Commented Sep 22, 2013 at 2:51
  • \$\begingroup\$ @TheNickmaster21 - simply that a modder could add any functionality they want. So they could easily hide any kind of malicious functionality in there. Scripting languages are typically within a sandbox and so offer less risk. That being said, there may be concerns with LUA specifically as well, but I don't know enough to make a definitive comment. \$\endgroup\$ Commented Sep 26, 2013 at 9:46
  • \$\begingroup\$ Well adding Lua is a pain with Java. Adding JavaScript is built in but still more difficult than just allowing JARs. I decided to just go with the JAR approach considering this is meant to be an engine of sorts. I really don't care how malicious a user makes their code; I'm only responsible for the code I gave them. And I'll have to make that clear. \$\endgroup\$ Commented Sep 26, 2013 at 11:19
0
\$\begingroup\$

First of all, your focus should probably be elsewhere. Have you ever made a game that attracted just a modest user base before? If not simply making a game that people want to play in the first place is a plenty steep goal.

Supporting good moddability is hard and time consuming. It takes some experience that you probably don't have and require a more frameworkish structure.

For all the good things there is to say about planning ahead and doing things right from the beginning, you easily risk such concerns getting in the way of actually making a game.

Go with the easiest solution. For all the cases where that leads you to go back and redesign there will be many more where you avoided needless extra work. With time you should learn to spot the cases where a more elaborate approach is required.

The Java classes offer by far the easiest option to implement, and while some XML files may be easier to edit you have to offer some pretty elaborate bindings in order to make that LUA script anywhere near as flexible as an option for modifying the native Java code.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .