Sanchez Posted August 4, 2018 Share Posted August 4, 2018 (edited) Hello, can someone help with item spawn script please? I need to spawn items on the ground with exact coordinates once per day. I tried different variants of this, but it won't work: function Spawn(square) square:AddWorldInventoryItem("Base.Stone", 10000, 10000, 0); end Events.EveryDays.Add(Spawn); Most errors look like: java.lang.RuntimeException: attempted index: AddWorldInventoryItem of non-table: null I'am weak in scripting, and can't make it work, please help! Edited August 4, 2018 by Sanchez Link to comment Share on other sites More sharing options...
Fenris_Wolf Posted August 4, 2018 Share Posted August 4, 2018 1 hour ago, Sanchez said: attempted index: AddWorldInventoryItem of non-table: null The problem here looks to be your not passing a proper IsoGridSquare object into your function. Calling your function like that through the EveryDays event will not pass your 'square' variable into the function. local x, y, z = 0, 0, 0 -- change to where you want to spawn local function Spawn() local square = getCell():getOrCreateGridSquare(x, y, z) if not square then return end square:AddWorldInventoryItem("Base.Stone", 0, 0, 0) end Events.EveryDays.Add(Spawn) Tradus 1 Link to comment Share on other sites More sharing options...
Sanchez Posted August 4, 2018 Author Share Posted August 4, 2018 Wow, thanks a lot! 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