Websyn Posted March 29, 2017 Share Posted March 29, 2017 Hello, I am a Chinese, I am a rookie, my English is very poor, even needed translation tools, so everyone please forgive my Chinglish.When I transplant Don't Starve MOD encountered a problem , This mod is : http://steamcommunity.com/sharedfiles/filedetails/?id=692094647 Error report is the : [string "../mods/egg/modmain.lua"]:98: attempt to index local 'player' (a nil value) LUA ERROR stack traceback: ../mods/egg/modmain.lua(98,1) =(tail call) ? =[C] in function 'xpcall' scripts/mods.lua(131,1) scripts/mods.lua(714,1) in function 'SimPostInit' scripts/gamelogic.lua(693,1) in function 'DoInitGame' scripts/gamelogic.lua(794,1) in function 'cb' scripts/saveindex.lua(285,1) =[C] in function 'GetPersistentString' scripts/saveindex.lua(267,1) in function 'GetSaveDataFile' scripts/saveindex.lua(293,1) in function 'GetSaveData' This is the code snippet on the player : AddSimPostInit(function(player) GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.TUNING.TD_GRID, function() if not player.lolopengrid and not GLOBAL.IsPaused() and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then local dist = 4 local num = 10 local px = player:GetPosition().x local pz = player:GetPosition().z local dx = math.floor(px / dist) * dist + dist / 2 local dx2 = dx + dist local dz = math.floor(pz / dist) * dist + dist / 2 local dz2 = dz + dist local finx = dx if math.abs(px - dx2) < math.abs(px - dx) then finx = dx2 end local finz = dz if math.abs(pz - dz2) < math.abs(pz - dz) then finz = dz2 end for x = finx - num * dist, finx + num * dist, dist do for z = finz - num * dist, finz + num * dist, dist do local fx = GLOBAL.SpawnPrefab('gridplacer') if fx and fx.AnimState then fx.AnimState:SetLayer(_G.LAYER_BACKGROUND) fx.AnimState:SetSortOrder(3) end if x == finx and z == finz then fx.AnimState:SetMultColour(0, 0, 1, 1) elseif (x == finx or z == finz) and (math.abs(x - finx) <= 5 * dist and math.abs(z - finz) <= 5 * dist) then fx.AnimState:SetMultColour(0, 1, 0, .8) else fx.AnimState:SetMultColour(1, 0, 0, .5) end fx:AddTag("gridplacer") fx.Transform:SetPosition(Vector3(x, 0, z):Get()) end end player.lolopengrid = true elseif player.lolopengrid and not GLOBAL.IsPaused() and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not GLOBAL.TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then local x, y, z = player:GetPosition():Get() local ents = GLOBAL.TheSim:FindEntities(x, y, z, 10000, { "gridplacer" }) for k, v in pairs(ents) do v:Remove() end player.lolopengrid = false end end) player:AddComponent("actionqueuer") player.components.actionqueuer:SetSelectionBoxModifier(SELECTION_BOX_MODIFIER) player.components.actionqueuer:SetCherryPickingModifier(CHERRY_PICKING_MODIFIER) local pc = player.components.playercontroller if pc then pc.OnControl = (function() local OnControl = pc.OnControl return function(self, ...) if not (SELECTION_BOX_MODIFIER and _G.TheInput:IsKeyDown(SELECTION_BOX_MODIFIER)) and not (CHERRY_PICKING_MODIFIER and _G.TheInput:IsKeyDown(CHERRY_PICKING_MODIFIER)) then return OnControl(self, ...) end end end)() pc.OnUpdate = (function() local OnUpdate = pc.OnUpdate return function(self, dt) local was_directwalking = self.directwalking local was_dragging = self.draggingonground OnUpdate(self, dt) if (not was_directwalking and self.directwalking) or (not was_dragging and self.draggingonground) then self.inst:PushEvent("playercontroller_move") end end end)() pc.DoActionTd1madaoOld = pc.DoAction pc.DoAction = (function() local DoAction = pc.DoAction return function(self, bufaction, ...) if bufaction then self.inst:PushEvent("playercontroller_move") end return DoAction(self, bufaction, ...) end end)() end local loco = player.components.locomotor if loco then loco.PushAction = (function() local PushAction = loco.PushAction return function(self, bufaction, ...) self.inst:PushEvent("locomotor_pushaction", { action = bufaction }) return PushAction(self, bufaction, ...) end end)() end end) Thank you so much for your help !! Link to comment https://forums.kleientertainment.com/forums/topic/77025-about-migrating-ds-mod-problem/ 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