TheCryptek Posted December 15, 2016 Share Posted December 15, 2016 (edited) I was following a tutorial on how to mod, starting something basic. Following the tutorial I decided to extend the code and make a custom item spawner for my solo play through, I finished the code up to what I thought was finished but I get an error I don't understand. Error: 1481760717435 79 java.lang.RuntimeException: at se.krka.kahlua.integration.expose.MethodArguments.assertValid(MethodArguments.java:123) at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:187) at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:182) at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:983) at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163) at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1727) at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1672) at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:53) at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:81) at zombie.Lua.Event.trigger(Event.java:37) at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:83) at zombie.input.GameKeyboard.update(GameKeyboard.java:48) at zombie.GameWindow.logic(GameWindow.java:575) at zombie.GameWindow.run(GameWindow.java:1246) at zombie.GameWindow.maina(GameWindow.java:1022) at zombie.gameStates.MainScreenState.main(MainScreenState.java:179) Code: --[ We will store all global variables in this table TCSpawner = {}; --[ We added the parameter to the function which --[ will be passed to the function as soon as the --[ event fires. function TCSpawner.addItems(_keyPressed) print(_keyPressed); --[ print the pressed key to the console. --[ We Test if the correct key is pressed. if _keyPressed == 79 then local player = getSpecificPlayer(0); --[ Java: get player one local inv = player:getInventory(); --[ Java: access player's inventory --[ Java: add the actual items to the inventory inv:addItem("Base.HammerStone"); inv:addItem("Base.AxeStone"); inv:addItem("Base.Sledgehammer"); inv:addItem("Base.Saw"); inv:addItem("Base.NailsBox"); end if _keyPressed == 80 then local player = getSpecificPlayer(0); local inv = player:getInventory(); inv:addItem("Base.Needle"); inv:addItem("Base.Thread"); end if _keyPressed == 81 then local player = getSpecificPlayer(0); local inv = player:getInventory(); inv:addItem("Base.Duffelbag"); end if _keyPressed == 75 then local player = getSpecificPlayer(0); local inv = player:getInventory(); inv:addItem("Base.Padlock"); inv:addItem("Base.ElectronicsMag4"); end end --[ Hooks --[ This will be fired whenever a key is pressed. Events.OnKeyPressed.Add(TCSpawner.addItems); Any help at all would be apreciated. Edited December 15, 2016 by TheCryptek Mark as solved Link to comment Share on other sites More sharing options...
EnigmaGrey Posted December 15, 2016 Share Posted December 15, 2016 That'd be akin to something like "invalid arguments." There's two very similar functions: addItem, which takes an Inventoryitem, and AddItem which takes a string containing the module and item name (e..g "Base.Apple"). You want the second one. So, inv:AddItem("Base.Apple") TheCryptek 1 Link to comment Share on other sites More sharing options...
TheCryptek Posted December 15, 2016 Author Share Posted December 15, 2016 2 minutes ago, EnigmaGrey said: That'd be akin to something like "invalid arguments." There's two very similar functions: addItem, which takes an Inventoryitem, and AddItem which takes a string containing the module and item name (e..g "Base.Apple"). You want the second one. So, inv:AddItem("Base.Apple") So you are saying change addItem to AddItem? Just want to make sure I am understanding this correctly as I learn Link to comment Share on other sites More sharing options...
EnigmaGrey Posted December 15, 2016 Share Posted December 15, 2016 That's it, yep. You can see it here in the JavaDoc: http://projectzomboid.com/modding/zombie/inventory/ItemContainer.html I'd recommend grabbing something like Notepad++ and using its "find in files" function to find examples of what you're trying to do in the future, as well. Link to comment Share on other sites More sharing options...
TheCryptek Posted December 15, 2016 Author Share Posted December 15, 2016 9 minutes ago, EnigmaGrey said: That's it, yep. You can see it here in the JavaDoc: http://projectzomboid.com/modding/zombie/inventory/ItemContainer.html I'd recommend grabbing something like Notepad++ and using its "find in files" function to find examples of what you're trying to do in the future, as well. I already use Notepad++, it helps me a lot with python, especially with the 'find in files' function Thank you for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now