• ENT:KeyValue saying that the keyvalues have a nil value
    0 replies, posted
[lua] AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function ENT:Initialize() floorCurrent = 0 floorTo = 0 end //function TravelDelay(floorCurrent, floorTo) // return ((floorTo-floorCurrent)*self:getKeyValue(elevator, "movedistance"))/self:getKeyValue(elevator, "speed") //end //KeyValues function ENT:KeyValue(key, value) if key == "doorprefix" then doorPrefix = value end if key == "elevatorname" then elevator = ents.FindByName(value)[1] end if key == "movedelay" then moveDelay = value end end //Input function ENT:AcceptInput( name, activator, caller, data ) print("current: "..floorCurrent) print("to: "..floorTo) print("using: "..elevator) if (name == "goto") then if (floorCurrent!=floorTo) then floorCurrentDoor = ents.FindByName(DoorFloorCurrent(floorCurrent))[1] floorCurrentDoor:Fire("SetAnimation", "close", 0) elevator:Fire("SetPosition", floorTo, moveDelay) end end if (name == "updatefloor") then UpdateFloor(floorCurrent, floorTo) end end function UpdateFloor(current, to) self.floorCurrent = current self.floorTo = to end function DoorFloorCurrent(floor) doorName = doorPrefix..floor return doorName end function ENT:OnRemove() end[/lua] [code][lua\entities\elevator_controller\init.lua:36] attempt to concatenate global 'elevator' (a nil value)[/code] It's kinda got me stuck and I don't know what I've done wrong to cause it. Can anyone please shed some light on the situation?
Sorry, you need to Log In to post a reply to this thread.