I played with LuaJ a bit today and found out it has some very powerful tools for calling Java functions straight from the lua. I started out with a lua file that’s something simple like this:
function Main(GameTools, WorldTools, HUDTools, PlayerTools)
print('Hello World from lua file! Player Name: ' .. PlayerTools:getName())
end
And it successfully printed:
Hello World from lua file! Player Name: Cody
I wanted to see how far down I could take the rabbit hole and ended up trying this:
function Main(GameTools, WorldTools, HUDTools, PlayerTools)
print('Hello World from lua file! First Item in Player Inventory: ' .. PlayerTools:getPlayer():getInventory():get(0):getName())
end
And holy hell, it printed out this:
Hello World from lua file! First Item in Player Inventory: Old Hover-Bike
It went all the way down into the EntityPlayer, down it his Inventory, and then got an Item out if its ArrayList and was able to successfully call getName(). That’s pretty much exactly what I was looking for in my mod support functionality. Of course, I’ll probably abstract and limit what the lua file can call so that the modders can’t go too far down the rabbit hole and accidentally break something, but it’s still cool that it has that potential.
I’ll have to keep reading up to make sure the lua support can’t be used maliciously though. I haven’t used lua since my teenage source modding days, so I can’t really remember what kind of functionality it has.
@nsigma
I’m not really a stickler on protecting my code, but it’s definitely about protecting the users from douchebags who will hide viruses in their mods. The Java VM is pretty powerful so I imagine giving full control over to the modder could end up being pretty dangerous.