Skip to content

Commit

Permalink
feat: talkaction to test
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Sep 19, 2024
1 parent d65ce9e commit b30f99e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions data/scripts/talkactions/god/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,36 @@ end
testLog:separator(" ")
testLog:groupType("god")
testLog:register()


local containerTalkAction = TalkAction("!testcontainer")

function containerTalkAction.onSay(player, words, param)
local container = player:getSlotItem(CONST_SLOT_BACKPACK)
if not container then
player:sendCancelMessage("Your backpack does not contain a valid container.")
logger.error("[!container] - Player: {} has a backpack without a valid container.", player:getName())
return true
end

local items = container:getItems(true)
local totalItems = 0
for i, item in pairs(items) do
if item then
local itemName = item:getName()

Check warning on line 56 in data/scripts/talkactions/god/test.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] data/scripts/talkactions/god/test.lua#L56

line contains only whitespace
Raw output
data/scripts/talkactions/god/test.lua:56:1: line contains only whitespace
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Found item: " .. itemName)
item:remove()
end
-- Increment the item counter
totalItems = totalItems + 1
end

Check warning on line 63 in data/scripts/talkactions/god/test.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] data/scripts/talkactions/god/test.lua#L63

line contains only whitespace
Raw output
data/scripts/talkactions/god/test.lua:63:1: line contains only whitespace
logger.error("[!container] - Player: {} executed the '!container' command. Total items found: {}.", player:getName(), totalItems)

return true
end

containerTalkAction:separator(" ")
containerTalkAction:groupType("god")
containerTalkAction:register()

0 comments on commit b30f99e

Please sign in to comment.