Closed Sendaford closed 4 years ago
Thank you for your interest :)
Sorry, that there is no handy way to read / have a documentation for the functions available. We are working on that, but are super limited in time at the moment due to various reasons. For now the most complete documentation can be found in the documentation that is attached to each function in the source code (You can for example use Githubs search and find the function / the definition of that function and there you can also find some documentation).
So for your specific case, i looked it up, and found that we do not have a function with your signature (with only a role argument). The function is defined here: https://github.com/TTT-2/TTT2/blob/c49cd970f1a6a89118acb1411e3cac503b546919/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua#L219
and its first parameter has to be the player and the second one should be the role you want to access the shop from. While looking this up, i noticed, that we really have to clean this file up too after our UI Rework and am putting that on our TODO list. (eg. dunno why you would need a player to get the equipment, except when modified like it is when using the random shop)
If you got any other issues / comments / ideas for improvement / questions regarding anything, feel free to ask. We are happy to help you get that to work, as long as our spare time allows it. Otherwise i can always recommend joining our Discord, where you also may ask questions and get much more responses from various other people that might also be happy to help ;)
Hi, thanks for the quick reply. It helped me a lot.
Seems like I was working with TTT instead of TTT2. Silly me. https://github.com/Pustekuchen98/TTT/blob/ed55c561dd4bd043dd9e235049f65f42391e4ee6/gamemode/cl_equip.lua#L10
For now, I'll try to use the given method with three parameters from https://github.com/TTT-2/TTT2/blob/c49cd970f1a6a89118acb1411e3cac503b546919/gamemodes/terrortown/gamemode/shared/sh_equip_items.lua#L219 and will report later on it.
Btw. great work with TTT2, I really enjoy it.
Hey again, I managed to alter icons displayed in the traitor shop using following code:
if SERVER then return end
local a = GetEquipmentForRole(LocalPlayer(), ROLE_TRAITOR, false)
for k,v in pairs(a) do
if v and v.CanBuy then
local icon = "materials/vgui/ttt/icons/" .. v.id .. ".png"
if(file.Exists(icon, "GAME")) then
print("Found and replaced: " .. v.id)
v.material = icon
v.ttt2_cached_material = icon
end
end
end
So it works perfectly with three params. Thanks again.
Summary
I'm not able to use the GetEquipmentForRole(role) method in my addon. It probably refers to an "old" lua file from TTT1. See error below.
Version
Description
Error in console while trying to call GetEquipmentForRole(ROLE_TRAITOR) from cl_equip.lua in an addon's lua file. Tried to call it in different scopes/events/hooks...
Console output:
To reproduce
Steps to reproduce the behaviour:
Expected behaviour
I expect the method to return a table with all buyable items for the specified role, to be able to edit item names and icons.
Additional context
Tried to implement a copy of this function in the addon's lua file. It returned the desired but I was not able to edit their metadata (name, icon, type, desc, ...)