Andmann Posted August 4, 2016 Share Posted August 4, 2016 (edited) Wow I'm a big bad idiot... ts.portal[x] = x I assigned the value of x as key instead of "x"... of course when I then use an undefined key id get a nil result D: I was restructuring my code and turned lots of single variables into tables. basically nothing has really changed in the codes logic except for how we store out values. And boy! I am having a really bad time right now >_> cause the log keeps telling me, that a table, which is supposed to hold coordinates is in fact nil... now I don't know how the hell this can be happening q.q but check this out: i filtered the server log for the important lines Spoiler [00:00:11]: [Debug] portal(-90,0,-34) [00:00:11]: [Debug] base1(-468,0,219) [00:00:11]: [Debug] base2(80,0,-543) [00:00:11]: Sim paused [00:00:42]: Resuming user: session/6E66248BBE2FFFD6/KU_eLFAMso2_ [00:06:28]: Spawn request: wilson from andmann [00:06:28]: [DEBUG] checkworld true [00:06:28]: [DEBUG] checking what to do with new player [00:06:28]: true [00:06:28]: [string "../mods/workshop-737054453/scripts/componen..."]:173: calling 'SetPosition' on bad self (number expected, got nil) LUA ERROR stack traceback: =[C]:-1 in (method) SetPosition (C) <-1--1> ../mods/workshop-737054453/scripts/components/teamsurvival.lua:173 in (method) TeleportEvent (Lua) <170-176> self = status = lobby game = false inst = 100021 - world (valid:true) teamcomp = standard eventeams = false bases = table: 1F04BF38 lobbysize = 4 portal = table: 1F04C230 inst = 112186 - (valid:true) x = nil y = nil z = nil ../mods/workshop-737054453/modmain.lua:84 in (local) fn (Lua) <77-90> inst = 100021 - world (valid:true) player = 112186 - (valid:true) ts = table: 1A23D8E8 scripts/entityscript.lua:972 in (method) PushEvent (Lua) <959-986> self (valid:true) = GUID = 100021 inlimbo = false Pathfinder = Pathfinder (1A1F4E50) worldstatewatching = table: 1A21C468 prefabswapstatus = table: 1985CD80 worldprefab = forest ismastershard = true shard = 100025 - shard_network (valid:true) OnRemoveEntity = function - scripts/prefabs/world.lua:236 pendingtasks = table: 1A21D8E0 hideminimap = false state = table: 1A216BF8 spawntime = 0 Transform = Transform (1A1F4E10) generated = table: 1984DB80 event_listening = table: 1A216AB8 actioncomponents = table: 1A216108 lower_components_shadow = table: 1A215B90 entity = Entity (19B11100) prefab = world updatecomponents = table: 1A21DA70 Map = Map (1A1F4EB0) watchingcycles = true net = 100024 - forest_network (valid:true) persists = false meta = table: 1984DB30 GroundCreep = GroundCreep (1A1F4ED0) event_listeners = table: 1A216A68 minimap = 100022 - minimap (valid:true) PostInit = function - scripts/prefabs/world.lua:214 ismastersim = true name = MISSING NAME WaveComponent = WaveComponent (1A1F5A50) replica = table: 1A216518 topology = table: 1985FE90 components = table: 1A215C30 SoundEmitter = SoundEmitter (1A1F5570) event = ms_playerspawn data = 112186 - (valid:true) listeners = table: 1A23DA28 tocall = table: 1EBD45E0 i = 1 fn = function - ../mods/workshop-737054453/modmain.lua:77 scripts/prefabs/player_common.lua:1841 in (field) fn (Lua) <1536-1844> inst = 112186 - (valid:true) scripts/mainfunctions.lua:146 in () ? (Lua) <135-177> name = wilson prefab = Prefab wilson - [00:06:28]: [string "../mods/workshop-737054453/scripts/componen..."]:173: calling 'SetPosition' on bad self (number expected, got nil) LUA ERROR stack traceback: =[C]:-1 in (method) SetPosition (C) <-1--1> ../mods/workshop-737054453/scripts/components/teamsurvival.lua:173 in (method) TeleportEvent (Lua) <170-176> ../mods/workshop-737054453/modmain.lua:84 in (local) fn (Lua) <77-90> scripts/entityscript.lua:972 in (method) PushEvent (Lua) <959-986> scripts/prefabs/player_common.lua:1841 in (field) fn (Lua) <1536-1844> scripts/mainfunctions.lua:146 in () ? (Lua) <135-177> so from the log I can tell, that the coordinates I at first assign are structured just fine. Yet when CheckNewPlayer calls for ts.portal the data is suddenly gone... while copy pasting this I noticed that the sim was still paused when calling the table? I'm not sure if that is the case and if that would be problematic. the relevant code lines of modmain: especially ListenForEvent("ms_playerspawn") might be noteworthy Spoiler -- world instance local function CheckNewPlayer(inst, player) print("[DEBUG] checkworld "..tostring(inst == GLOBAL.TheWorld)) if inst ~= nil and inst.ismastersim then local ts = inst.components.teamsurvival print("[DEBUG] checking what to do with new player") if ts:GoToLobby(player) then print(tostring(ts.portal[x] == nil))--.." = "..ts.portal[x]..","..ts.portal[y]..","..ts.portal[y]) ts:TeleportEvent(player, ts.portal[x], ts.portal[y], ts.portal[z]) CheckLobby(inst) else ts:SetTeams() end end end AddPrefabPostInit("world", function(inst) if inst and inst.ismastersim then inst:AddComponent("teamsurvival") --TheWorld:PushEvent("ms_playerspawn", inst) for reference inst:ListenForEvent("ms_playerspawn", CheckNewPlayer) end end) AddPrefabPostInit("multiplayer_portal", function(inst) if GLOBAL.TheWorld.ismastersim then inst:DoTaskInTime(0, function() local ts = GLOBAL.TheWorld.components.teamsurvival local portal = inst:GetPosition() local x,y,z=portal:Get() --self.portal =--{x=0,y=0,z=0} --self.bases =--{{x=0,y=0,z=0},{x=0,y=0,z=0}} ts.portal = {} ts.portal[x] = x ts.portal[y] = y ts.portal[z] = z print("[Debug] portal("..ts.portal[x]..","..ts.portal[y]..","..ts.portal[z]..")") end) end end) the relevant parts of the teamsurvival component Spoiler local teamsurvival = Class(function(self, inst) self.inst = inst self.portal={}--{x=0,y=0,z=0} self.bases ={}--{{x=0,y=0,z=0},{x=0,y=0,z=0}} -- general stats self.lobbysize = 6 self.eventeams = false self.teamcomp = "standard" self.game = false end) function teamsurvival:OnSave() return { portal = self.portal, bases = self.bases, status = self.status, game = self.game, } end function teamsurvival:OnLoad(data) self.portal = data and data.portal or {} self.bases = data and data.bases or {} self.status = data and data.status or "lobby" self.game = data and data.game or false end function teamsurvival:TeleportEvent(inst, x, y, z) if inst.status ~= nil then --repeat inst.Transform:SetPosition(x, y, z) --until inst:GetPosition() == {x,y,z} end end return teamsurvival Edited August 4, 2016 by Andmann Solved: Im a big bad idiot D: 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