Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getstorage talkaction #3200

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions data-otservbr-global/npc/thorgrin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ end

-- Travel
local function addTravelKeyword(keyword, cost, destination, text, action, discount)
local travelKeyword = keywordHandler:addKeyword({ keyword }, StdModule.say, { npcHandler = npcHandler, text = text or "Do you seek a ride to " .. keyword:titleCase() .. " for |TRAVELCOST|?", cost = cost, discount = discount or "postman" })
travelKeyword:addChildKeyword({ "yes" }, StdModule.travel, { npcHandler = npcHandler, premium = false, cost = cost, discount = discount or "postman", destination = destination, text = "Full steam ahead!" }, nil, action)
travelKeyword:addChildKeyword({ "no" }, StdModule.say, { npcHandler = npcHandler, text = "Then not", reset = true })
local travelKeyword = keywordHandler:addKeyword({ keyword }, StdModule.say, { npcHandler = npcHandler, text = text or "Do you seek a ride to " .. keyword:titleCase() .. " for |TRAVELCOST|?", cost = cost, discount = discount or "postman" })
travelKeyword:addChildKeyword({ "yes" }, StdModule.travel, { npcHandler = npcHandler, premium = false, cost = cost, discount = discount or "postman", destination = destination, text = "Full steam ahead!" }, nil, action)
travelKeyword:addChildKeyword({ "no" }, StdModule.say, { npcHandler = npcHandler, text = "Then not", reset = true })
end

addTravelKeyword("kazordoon", 210, Position(32659, 31957, 15))
Expand Down
7 changes: 3 additions & 4 deletions data/scripts/talkactions/god/manage_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ function Player.getStorageValueTalkaction(self, param)
return true
end

split[2] = split[2]:trimSpace()
storageStringToVar = loadstring("return " .. split[2])()

-- Try to convert the second parameter to a number. If it's not a number, treat it as a storage name
local storageKey = tonumber(split[2])
if storageKey == nil then
-- Get the key for this storage name
local storageName = tostring(split[2])
local storageValue = target:getStorageValueByName(storageName)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageName .. " from player " .. split[1] .. " is: " .. storageValue .. ".")
local storageValue = target:getStorageValue(storageStringToVar)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. split[2] .. " from player " .. split[1] .. " is: " .. storageValue .. ".")
else
local storageValue = target:getStorageValue(storageKey)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageKey .. " from player " .. split[1] .. " is: " .. storageValue .. ".")
Expand Down