1
0

Debuggers: Added commands to investigate item's custom Lua properties.

This commit is contained in:
Mattes D
2016-11-26 20:45:01 +01:00
parent 56f8dedb6b
commit 12071bc51a
3 changed files with 61 additions and 2 deletions

View File

@@ -1031,6 +1031,28 @@ end
function HandleGetPropCmd(a_Split, a_Player)
local item = a_Player:GetInventory():GetEquippedItem()
if not(item.m_DebuggersCustomProp) then
a_Player:SendMessage("The custom property is not set.")
return true
end
local dispValue = string.gsub(item.m_DebuggersCustomProp, ".",
function(a_Char)
if (a_Char < " ") then
return string.byte(a_Char)
end
return a_Char
end
)
a_Player:SendMessage(string.format("The custom property value is %d bytes: %s", string.len(item.m_DebuggersCustomProp), dispValue))
return true
end
function HandleHungerCmd(a_Split, a_Player)
a_Player:SendMessage("FoodLevel: " .. a_Player:GetFoodLevel());
a_Player:SendMessage("FoodSaturationLevel: " .. a_Player:GetFoodSaturationLevel());
@@ -1109,6 +1131,31 @@ end
function HandleSetPropCmd(a_Split, a_Player, a_EntireCmd)
if not(a_Split[2]) then
a_Player:SendMessageFatal("Missing an argument: the property value to set");
return true
end
local valueToSet = a_EntireCmd:match("/setprop%s(.*)")
if not(valueToSet) then
a_Player:SendMessageFatal("Failed to extract the property value to set")
return true
end
valueToSet = valueToSet:gsub("\\([0-9][0-9][0-9])", string.char)
local inv = a_Player:GetInventory()
local slotNum = inv:GetEquippedSlotNum()
local item = inv:GetEquippedItem()
item.m_DebuggersCustomProp = valueToSet
inv:SetHotbarSlot(slotNum, item)
a_Player:SendMessage("Custom property set to " .. valueToSet)
return true
end
function HandleSetLoreCmd(a_Split, a_Player, a_EntireCmd)
if not(a_Split[2]) then
a_Player:SendMessageFatal("Missing an argument: the lore to set");