Skip to content

Commit

Permalink
fix: hirelings spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Apr 16, 2024
1 parent f2112fa commit d626d59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ local hirelingLamp = Action()

function hirelingLamp.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local spawnPosition = player:getPosition()
local hireling_id = item:getCustomAttribute("Hireling")
local hirelingId = item:getCustomAttribute("Hireling")
local house = spawnPosition and spawnPosition:getTile() and spawnPosition:getTile():getHouse() or nil

if not house then
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:sendTextMessage(MESSAGE_FAILURE, "You may use this only inside a house.")
Expand All @@ -22,10 +23,10 @@ function hirelingLamp.onUse(player, item, fromPosition, target, toPosition, isHo
return false
end

local hireling = getHirelingById(hireling_id)
local hireling = getHirelingById(hirelingId)
if not hireling then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There was an error creating the hireling and it has been deleted, please, contact server admin.")
logger.warn("[hirelingLamp.onUse] Player {} is using hireling with id {} not exist in the database", player:getName(), hireling_id)
logger.warn("[hirelingLamp.onUse] Player {} is using hireling with id {} not exist in the database", player:getName(), hirelingId)
logger.error("Deleted the lamp")
item:remove(1)
return true
Expand Down

0 comments on commit d626d59

Please sign in to comment.