SenL Posted January 3, 2016 Share Posted January 3, 2016 (edited) Hi, I started playing again and my mod "Groot" crashes on 1st day of summer because the character sheds random item each day of summer. It used to work many months ago. Below is the error log and below that is the code snippet. Can anyone help?Thanks. Error log:../mods/workshop-391743403/scripts/prefabs/gggroot.lua:446 in (upvalue) DropAnI[00:09:08]: [string "scripts/entityscript.lua"]:985: assertion failed!LUA ERROR stack traceback: =[C]:-1 in (global) assert © <-1--1> scripts/entityscript.lua:985 in (method) GetPosition (Lua) <981-987> ../mods/workshop-391743403/scripts/prefabs/gggroot.lua:446 in (upvalue) DropAnItem (Lua) <444-448> ../mods/workshop-391743403/scripts/prefabs/gggroot.lua:466 in (upvalue) DropItems (Lua) <450-468> ../mods/workshop-391743403/scripts/prefabs/gggroot.lua:472 in (upvalue) groot_shed (Lua) <470-473> ../mods/workshop-391743403/scripts/prefabs/gggroot.lua:538 in (local) fn (Lua) <536-540> scripts/entityscript.lua:962 in (method) PushEvent (Lua) <956-979> scripts/components/seasons.lua:248 in (local) fn (Lua) <240-253> scripts/entityscript.lua:962 in (method) PushEvent (Lua) <956-979> scripts/mainfunctions.lua:295 in () ? (Lua) <292-297> [00:09:34]: Force aborting... Snippet inside gggroot.lua:...local function DropAnItem(inst, prefab) local itemtoshed = SpawnPrefab(prefab)local pos = inst:GetPosition() itemtoshed.Transform:SetPosition(pos.x + math.random()*2 - 1, 1, pos.z + math.random()*2 - 1)end local function DropItems(inst, itemname)local itemtoshed, howmanytodrop if itemname == "cutgrass" thenhowmanytodrop = 3elseif itemname == "twigs" thenhowmanytodrop = 3elseif itemname == "log" thenhowmanytodrop = 1elseif itemname == "petals" thenhowmanytodrop = 2else --unhandledhowmanytodrop = 1end for i=1,howmanytodrop doDropAnItem(inst, itemname)endend local function groot_shed(inst)local shed_drops = {"cutgrass", "twigs", "log", "petals"} inst:DoTaskInTime(1, DropItems(inst, shed_drops[math.random(#shed_drops)]))end ... local master_postinit = function(inst) ... TheWorld:ListenForEvent("seasontick", function(world) if world.state.issummer then groot_shed(inst) end end) ... Edited January 3, 2016 by SenL Link to comment https://forums.kleientertainment.com/forums/topic/61836-assertion-failed-on-getposition/ Share on other sites More sharing options...
SenL Posted January 4, 2016 Author Share Posted January 4, 2016 Fixed.I copied pigking.lua local function DropAnItem(inst, prefab) local itemtoshed = SpawnPrefab(prefab)local pos = Vector3(inst.Transform:GetWorldPosition()) itemtoshed.Transform:SetPosition(pos.x + math.random()*2 - 1, 1, pos.z + math.random()*2 - 1)end If not correct, please let me know.Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/61836-assertion-failed-on-getposition/#findComment-705053 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