Okamikurainya Posted September 13, 2019 Share Posted September 13, 2019 As an experiment on my way to something more in depth, I tried: local function addItems() local player = getSpecificPlayer(0); -- Java: get player one local inv = player:getInventory(); -- Java: access player inv -- Java: add the actual items to the inventory inv:AddItem("Base.Axe"); inv:AddItem("Base.RippedSheets"); inv:AddItem("camping.TentPeg"); end Events.OnCreatePlayer.Add(addItems); It worked exactly as I expected... But after I reloaded the game (without changing anything) it is now throwing up: SEVERE: Error found in LUA file: C:/Users/(snip)/Zomboid/mods/OccupationalItemsOnSpawn/media/lua/client/AddItems.lua java.lang.ArrayIndexOutOfBoundsException: 65022 It worked fine the first time, it's literally just a copy paste of Robomat's tutorial. What could have caused it to stop working if I didn't change anything? (All other mods are disabled, so totally vanilla minus this) Any help is appreciated on my way to figuring this stuff out! Link to comment Share on other sites More sharing options...
Maris Posted October 25, 2019 Share Posted October 25, 2019 (edited) local function addItems(id) local player = getSpecificPlayer(id); -- Java: get player which is just created local inv = player:getInventory(); -- Java: access player inv -- Java: add the actual items to the inventory inv:AddItem("Base.Axe"); inv:AddItem("Base.RippedSheets"); inv:AddItem("camping.TentPeg"); end Events.OnCreatePlayer.Add(addItems); OR local function addItems(id, player) if not player then return end -- just for sure local inv = player:getInventory(); -- Java: access player inv -- Java: add the actual items to the inventory inv:AddItem("Base.Axe"); inv:AddItem("Base.RippedSheets"); inv:AddItem("camping.TentPeg"); end Events.OnCreatePlayer.Add(addItems); Edited October 25, 2019 by Maris Okamikurainya 1 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