Skip to content

Commit

Permalink
simple test Talkations. delete when finished
Browse files Browse the repository at this point in the history
  • Loading branch information
kokekanon committed Nov 6, 2024
1 parent 0ff915e commit f538950
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions data/scripts/talkactions/gm/delete_test_otcr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
local talkAction = TalkAction("!testOTCR")

local options = {
["Creature"] = {{
name = "set attach Effect 7",
action = function(player)
player:attachEffectById(7)
end
}, {
name = "get all attach Effect",
action = function(player)
local effects = player:getAttachedEffects()
if #effects > 0 then
local effectsString = "your AE are: " .. table.concat(effects, ", ")
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, effectsString)
else
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "you do not have any AE.")
end

end
}, {
name = "detach Effect 7",
action = function(player)
player:detachEffectById(7)
end
}, {
name = "set Shader player",
action = function(player)
player:setShader("Outfit - Rainbow")
end
}, {
name = "no shader player",
action = function(player)
player:setShader("")
end
}, {
name = "get Shader player",
action = function(player)
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getShader())
end
}},
["Map"] = {{
name = "set Shader Map",
action = function(player)
player:setMapShader("Map - Party")
end
}, {
name = "no shader Map",
action = function(player)
player:setMapShader("")
end
}, {
name = "get Shader Map",
action = function(player)
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, player:getMapShader())
end
}},
["Item"] = {{
name = "Shader",
action = function(player)
local item = player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
item:setShader("Map - Party")
player:sendTextMessage(MESSAGE_GAMEMASTER_CONSOLE, "item have shader : ".. item:getShader())
end
}}
}

function talkAction.onSay(player, words, param, type)
local modalWindow = ModalWindow({
title = "Fast Test",
message = "Choose one of the following options:"
})

for category, subOptions in pairs(options) do
modalWindow:addChoice(category, function(player, button, choice)

Check warning on line 75 in data/scripts/talkactions/gm/delete_test_otcr.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue argument 'player' on line 68 Raw Output: data/scripts/talkactions/gm/delete_test_otcr.lua:75:50: shadowing upvalue argument 'player' on line 68
local subModalWindow = ModalWindow({
title = "Select a Sub-Option",
message = "Choose one of the following sub-options for " .. category .. ":"
})

for _, subOption in ipairs(subOptions) do
subModalWindow:addChoice(subOption.name, function(player, button, choice)

Check warning on line 82 in data/scripts/talkactions/gm/delete_test_otcr.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue argument 'player' on line 75 Raw Output: data/scripts/talkactions/gm/delete_test_otcr.lua:82:67: shadowing upvalue argument 'player' on line 75

Check warning on line 82 in data/scripts/talkactions/gm/delete_test_otcr.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue argument 'button' on line 75 Raw Output: data/scripts/talkactions/gm/delete_test_otcr.lua:82:75: shadowing upvalue argument 'button' on line 75

Check warning on line 82 in data/scripts/talkactions/gm/delete_test_otcr.lua

View workflow job for this annotation

GitHub Actions / luacheck

[luacheck] reported by reviewdog 🐶 shadowing upvalue argument 'choice' on line 75 Raw Output: data/scripts/talkactions/gm/delete_test_otcr.lua:82:83: shadowing upvalue argument 'choice' on line 75
if button.name == "OK" then
subOption.action(player)
end
end)
end

subModalWindow:addButton("OK")
subModalWindow:addButton("Cancel")
subModalWindow:sendToPlayer(player)
end)
end

modalWindow:addButton("OK")
modalWindow:addButton("Cancel")
modalWindow:sendToPlayer(player)
return false
end

talkAction:groupType("gamemaster")
talkAction:separator(" ")
talkAction:register()

0 comments on commit f538950

Please sign in to comment.