I'm having some difficulty instancing a very barebones custom entity class.
So far my steps are:
1. create a new lua script file
2. extend class Entity, have a unique kMapName, call Shared.LinkClassToMap
3. load script in desired vms (server+client)
4. Instance it using Server.CreateEntity(EntityClassName.kMapName) in server vm.
Server.CreateEntity however always returns nil. Debugging doesn't help me as stepping into Server.CreateEntity doesn't work. I suspect I'm missing a step or naming convention required to get this to work.
Am I missing a step? How do I debug this issue?
Class source
So far my steps are:
1. create a new lua script file
2. extend class Entity, have a unique kMapName, call Shared.LinkClassToMap
3. load script in desired vms (server+client)
4. Instance it using Server.CreateEntity(EntityClassName.kMapName) in server vm.
Server.CreateEntity however always returns nil. Debugging doesn't help me as stepping into Server.CreateEntity doesn't work. I suspect I'm missing a step or naming convention required to get this to work.
Am I missing a step? How do I debug this issue?
Class source
Spoiler:
Script.Load("lua/Entity.lua") class 'SWSGameInfo' (Entity) SWSGameInfo.kMapName = "sws_game_info" function GetSwsGameInfoEntity() local entityList = Shared.GetEntitiesWithClassname("SWSGameInfo") if entityList:GetSize() > 0 then return entityList:GetEntityAtIndex(0) end end local networkVars = { isTeamBased = "boolean", } function SWSGameInfo:OnCreate() self.isTeamBased = false end if Server then function SWSGameInfo:SetTeamBased(value) self.isTeamBased = value end end function SWSGameInfo:GetTeamBased() return self.isTeamBased end Shared.LinkClassToMap("SWSGameInfo", SWSGameInfo.kMapName, networkVars)