AmadanNaBriona
April 2nd, 2020, 21:11
I have assigned a "Leader" button to CT entries. Clicking it designates that character as the leader of their faction ("friend", "foe", "neutral", etc.)
Only one character can be the leader of a faction. If I click a leader button, I want anyone in that faction who was previously the leader to be removed as leader.
I can set the value for a faction's leader in the DB and remove the previous leader. However, how can I uncheck the button of the previous leader on the CT?
function onLeaderChanged()
local nodeRecord = getDatabaseNode();
local bLeader = leader.getValue();
-- can only be one leader
if bLeader then
DB.setValue(nodeRecord, "leader", "boolean", true);
local sFaction = DB.getValue(nodeRecord, "friendfoe", "");
for _,v in pairs(CombatManager.getCombatantNodes()) do
if DB.getValue(v, "friendfoe", "") == sFaction then
if nodeRecord ~= v then
DB.setValue(v, "leader", "boolean", false);
-- NEED CODE HERE - I want to toggle the "leader" button for v
end
end
end
end
Debug.chat(nodeRecord,bLeader,sClass,sFaction);
end
Only one character can be the leader of a faction. If I click a leader button, I want anyone in that faction who was previously the leader to be removed as leader.
I can set the value for a faction's leader in the DB and remove the previous leader. However, how can I uncheck the button of the previous leader on the CT?
function onLeaderChanged()
local nodeRecord = getDatabaseNode();
local bLeader = leader.getValue();
-- can only be one leader
if bLeader then
DB.setValue(nodeRecord, "leader", "boolean", true);
local sFaction = DB.getValue(nodeRecord, "friendfoe", "");
for _,v in pairs(CombatManager.getCombatantNodes()) do
if DB.getValue(v, "friendfoe", "") == sFaction then
if nodeRecord ~= v then
DB.setValue(v, "leader", "boolean", false);
-- NEED CODE HERE - I want to toggle the "leader" button for v
end
end
end
end
Debug.chat(nodeRecord,bLeader,sClass,sFaction);
end