Module CorsixTH.CorsixTH.Lua.entities.humanoids.vip

]]

Functions

Vip:Vip (...) A `Vip` who is in the hospital to evaluate the hospital and produce a report.
Vip:goHome () VIP while on premises--]]function Vip:tickDay() -- for the vip if self.waiting then self.waiting = self.waiting - 1 if self.waiting == 0 then if #self.world.rooms == 0 then -- No rooms have been built yet self:goHome() end self:getNextRoom() self.waiting = nil end end if not self.going_home then self.world:findObjectNear(self, "litter", 8, function(x, y) local litter = self.world:getObject(x, y, "litter") if not litter then return end

local alreadyFound = false for i=1, (self.num_vomit_noninducing + self.num_vomit_inducing) do if self.found_vomit[i] == litter then alreadyFound = true break end end

self.found_vomit[(self.num_vomit_noninducing + self.num_vomit_inducing + 1)] = litter

if not alreadyFound then if litter:anyLitter() then self.num_vomit_noninducing = self.num_vomit_noninducing + 1 else self.num_vomit_inducing = self.num_vomit_inducing + 1 end end end) end return Humanoid.tickDay(self) end

function Vip:getNextRoom() -- Find out the next room to visit.



Functions

Vip:Vip (...)
A `Vip` who is in the hospital to evaluate the hospital and produce a report.

Parameters:

  • ...
Vip:goHome ()
VIP while on premises--]]function Vip:tickDay() -- for the vip if self.waiting then self.waiting = self.waiting - 1 if self.waiting == 0 then if #self.world.rooms == 0 then -- No rooms have been built yet self:goHome() end self:getNextRoom() self.waiting = nil end end if not self.going_home then self.world:findObjectNear(self, "litter", 8, function(x, y) local litter = self.world:getObject(x, y, "litter") if not litter then return end

local alreadyFound = false for i=1, (self.num_vomit_noninducing + self.num_vomit_inducing) do if self.found_vomit[i] == litter then alreadyFound = true break end end

self.found_vomit[(self.num_vomit_noninducing + self.num_vomit_inducing + 1)] = litter

if not alreadyFound then if litter:anyLitter() then self.num_vomit_noninducing = self.num_vomit_noninducing + 1 else self.num_vomit_inducing = self.num_vomit_inducing + 1 end end end) end return Humanoid.tickDay(self) end

function Vip:getNextRoom() -- Find out the next room to visit. self.next_room_no, self.next_room = next(self.world.rooms, self.next_room_no) if self.next_room == nil then return self:setNextAction(VipGoToNextRoomAction()) end -- Always visit the first room. if self.num_visited_rooms > 0 then local roll_to_visit = math.random(0, self.room_visit_chance) -- Run a loop until roll_to_visit passes, or we hit a room the VIP must visit while roll_to_visit ~= self.room_visit_chance and not self.next_room.room_info.vip_must_visit do self.next_room_no, self.next_room = next(self.world.rooms, self.next_room_no) -- get new room if self.next_room == nil then -- We ran out of rooms, time to leave break end roll_to_visit = math.random(0, self.room_visit_chance) end end -- Make sure room is active. If not, always visit the next available room. while self.next_room and not self.next_room.is_active do self.next_room_no, self.next_room = next(self.world.rooms, self.next_room_no) end self:setNextAction(VipGoToNextRoomAction()) end

-- display the VIP name in the info box function Vip:updateDynamicInfo(action_string) -- luacheck: ignore 212 keep args from parent class self:setDynamicInfo('text', {self.name}) end

generated by LDoc TESTING Last updated 2015-01-01 12:00:00