Skip to content

Commit

Permalink
Update init.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Luan Luciano authored Mar 29, 2024
1 parent f986510 commit 2eaf63e
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,51 @@ function GameStore.processHirelingChangeNamePurchase(player, offer, productType,
end
end

local function HandleHirelingSexChange(playerId, offer)
local player = Player(playerId)
if not player then
return
end

local cb = function(playerId, data, hireling)

Check warning on line 1899 in data/modules/scripts/gamestore/init.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue argument 'playerId' on line 1893 Raw Output: data/modules/scripts/gamestore/init.lua:1899:22: shadowing upvalue argument 'playerId' on line 1893
local player = Player(playerId)

Check warning on line 1900 in data/modules/scripts/gamestore/init.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue 'player' on line 1894 Raw Output: data/modules/scripts/gamestore/init.lua:1900:9: shadowing upvalue 'player' on line 1894
if not player then
return
end

if not hireling then
return player:showInfoModal("Error", "Your must select a hireling.")
end

if hireling.active > 0 then
return player:showInfoModal("Error", "Your hireling must be inside his/her lamp.")
end

if not player:makeCoinTransaction(data.offer, hireling:getName()) then
return player:showInfoModal("Error", "Transaction error")
end

local changeTo, sexString, lookType
if hireling.sex == HIRELING_SEX.FEMALE then
changeTo = HIRELING_SEX.MALE
sexString = "male"
lookType = HIRELING_OUTFIT_DEFAULT.male
else
changeTo = HIRELING_SEX.FEMALE
sexString = "female"
lookType = HIRELING_OUTFIT_DEFAULT.female
end

hireling.sex = changeTo
hireling.looktype = lookType

logger.debug("{} sex was changed to {}", hireling:getName(), sexString)
sendUpdatedStoreBalances(playerId)
end

player:sendHirelingSelectionModal("Choose a Hireling", "Select a hireling below", cb, { offer = offer })
end

function GameStore.processHirelingChangeSexPurchase(player, offer)
if player:getClient().version < 1200 then
return error({
Expand Down Expand Up @@ -2196,48 +2241,3 @@ function Player:openStore(serviceName) --exporting the method so other scripts c
addPlayerEvent(sendShowStoreOffers, 50, playerId, category)
end
end

function HandleHirelingSexChange(playerId, offer)
local player = Player(playerId)
if not player then
return
end

local cb = function(playerId, data, hireling)
local player = Player(playerId)
if not player then
return
end

if not hireling then
return player:showInfoModal("Error", "Your must select a hireling.")
end

if hireling.active > 0 then
return player:showInfoModal("Error", "Your hireling must be inside his/her lamp.")
end

if not player:makeCoinTransaction(data.offer, hireling:getName()) then
return player:showInfoModal("Error", "Transaction error")
end

local changeTo, sexString, lookType
if hireling.sex == HIRELING_SEX.FEMALE then
changeTo = HIRELING_SEX.MALE
sexString = "male"
lookType = HIRELING_OUTFIT_DEFAULT.male
else
changeTo = HIRELING_SEX.FEMALE
sexString = "female"
lookType = HIRELING_OUTFIT_DEFAULT.female
end

hireling.sex = changeTo
hireling.looktype = lookType

logger.debug("{} sex was changed to {}", hireling:getName(), sexString)
sendUpdatedStoreBalances(playerId)
end

player:sendHirelingSelectionModal("Choose a Hireling", "Select a hireling below", cb, { offer = offer })
end

0 comments on commit 2eaf63e

Please sign in to comment.