Skip to content
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
498228c
Update login.lua
LeoTKBR Oct 4, 2023
e492edf
Create autosync.yml
LeoTKBR Nov 1, 2023
b312e75
Update autosync.yml
LeoTKBR Nov 1, 2023
13c7799
Update autosync.yml
LeoTKBR Nov 1, 2023
abcc3a2
Update autosync.yml
LeoTKBR Nov 1, 2023
a383e95
Update autosync.yml
LeoTKBR Nov 1, 2023
e0b9d70
Update autosync.yml
LeoTKBR Nov 1, 2023
467fe4e
Update autosync.yml
LeoTKBR Nov 1, 2023
ae7e3ec
Update autosync.yml
LeoTKBR Nov 1, 2023
40f9d9e
Update autosync.yml
LeoTKBR Nov 1, 2023
430c489
Update autosync.yml
LeoTKBR Nov 1, 2023
965160d
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 4, 2023
708239f
Update autosync.yml
LeoTKBR Nov 4, 2023
203fa21
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 4, 2023
6927683
Merge branch 'main' of https://github.com/LeoTKBR/canary
LeoTKBR Nov 5, 2023
6dbe8ea
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 7, 2023
bfaef08
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 9, 2023
eabbcc5
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 16, 2023
61541d4
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 19, 2023
82c3ebf
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 23, 2023
67f7a9a
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 30, 2023
65f4896
Merge branch 'opentibiabr:main' into main
LeoTKBR Dec 5, 2023
45c764f
Merge branch 'opentibiabr:main' into main
LeoTKBR Sep 17, 2024
9c2f4db
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 7, 2024
d35e4a8
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 21, 2024
691870f
Merge branch 'opentibiabr:main' into main
LeoTKBR Nov 22, 2024
325a906
Merge branch 'opentibiabr:main' into main
LeoTKBR Mar 28, 2025
29bc04c
#Remove autosync
LeoTKBR Mar 28, 2025
d1222fc
talkaction-manage-kv
LeoTKBR Apr 23, 2025
ce6c10a
Lua code format - (Stylua)
github-actions[bot] Apr 23, 2025
4537391
Update manage_kv.lua
LeoTKBR Apr 25, 2025
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
95 changes: 88 additions & 7 deletions data/scripts/talkactions/god/manage_kv.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,106 @@
local get = TalkAction("/getkv")

function get.onSay(player, words, param)
local value = kv.get(param)
local key, playerName = string.splitFirst(param, ",")
if not playerName then
playerName = player:getName()
end

local targetPlayer = Player(playerName)
if not targetPlayer then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. playerName .. " not found.")
return
end

local value = targetPlayer:kv():get(key)
if value then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. param .. "]: " .. PrettyString(value))
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. key .. "] for " .. playerName .. ": " .. PrettyString(value))
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Key " .. param .. " not found.")
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Key " .. key .. " not found for " .. playerName .. ".")
end
end

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

local getAllKV = TalkAction("/getallkv")

function getAllKV.onSay(player, words, param)
local playerName = param
if not playerName or playerName == "" then
playerName = player:getName()
end

local targetPlayer = Player(playerName)
if not targetPlayer then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. playerName .. " not found.")
return
end

local kv = targetPlayer:kv()
if not kv then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Error: target player does not have a KV instance.")
return
end

local found = false
local keys = kv:keys()
if not keys then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No keys found.")
return
end

for _, key in ipairs(keys) do
local value = kv:get(key)
if type(value) == "number" and value >= 0 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. key .. "] = " .. PrettyString(value))
found = true
end
end

if not found then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "No KV found with value >= 0 for " .. playerName .. ".")
end
end

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

local set = TalkAction("/setkv")

function set.onSay(player, words, param)
local key, value = string.splitFirst(param, ",") -- With a space some KV's are not able to be edited due to spaces within the key names, changed to a comma (,) to overcome this issue
value = load("return " .. value)()
kv.set(key, value)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. key .. "] = " .. PrettyString(value))
local key, rest = string.splitFirst(param, ",")
if not key or not rest then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Usage: /setkv <key>,<value>[,<playerName>]")
return false
end

local value, playerName = string.splitFirst(rest, ",")
local targetPlayer = player
if playerName then
local creature = Creature(playerName)
if creature and creature:isPlayer() then
targetPlayer = creature:getPlayer()
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player '" .. playerName .. "' not found or is not a valid player.")
return false
end
end
local success, parsedValue = pcall(load("return " .. value))
if not success then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid value format.")
return false
end
local kv = targetPlayer:kv()
if not kv then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Error: target player does not have a KV instance.")
return false
end
kv:set(key, parsedValue)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "KV: [" .. key .. "] = " .. PrettyString(parsedValue) .. " set for " .. targetPlayer:getName())
return true
end

set:separator(" ")
Expand Down