PDA

View Full Version : Clear the Combat Tracker



tokkibell
June 30th, 2007, 17:14
Is there a command I'm missing that clears out the combat tracker. The click remove gets annoying should I end up with a large list of opponents.

Alternately, if there is not, any ideas on how to script this?

joshuha
June 30th, 2007, 21:55
Would a slash function like "/cleartracker" work for you? Do you want it to delete everyone or just all non-PCs?

tokkibell
July 1st, 2007, 16:49
A slash function would be perfect, and either of those two options works. I can see the advantages to both ways.

joshuha
July 1st, 2007, 20:27
Ok try this.

Add this function in chatmanager.lua, I added mine right above the onInit function.



function clearTracker(params)
ct = Interface.openWindow("combattracker","");
for k, v in ipairs(ct.list.getWindows()) do
if params == "all" then
v.close();
elseif v.charactertype ~= "pc" then
v.close();
end
end
end


Then to register it as a slashhandler add this line to the function onInit() below the other slashhandler registrations.



registerSlashHandler("/cleartracker", clearTracker);



Then it should work. If you do "/cleartracker" it will leave the PCs in there and if you do "/cleartracker all" it should remove all the entries.

Hamish
July 1st, 2007, 21:40
Thanks Joshuha, another great one for my ruleset.
I'm starting an archive.... any more scripts you can share with us? Dunno if you have a documented archive.....

joshuha
July 1st, 2007, 23:53
Thanks Joshuha, another great one for my ruleset.
I'm starting an archive.... any more scripts you can share with us? Dunno if you have a documented archive.....

Hmm no archive but thats a good idea. I have mentioned before we should get a seperate sub-forum here for scripting and someone who can moderate it and sticky useful scripts.

tokkibell
July 2nd, 2007, 08:05
I'm actually doing a bit of a repository using Subversion on my laptop. I don't really have the time to manage something like that publicly (in truth, I don't have the time to manage it for myself or run my game, but I decided to give up sleep years ago), but it would be a great option for developing personal code branches for different rulesets and then quickly implementing changes to the original code and being able to easily adapt the customizations.

Just a thought.

Valarian
July 2nd, 2007, 08:32
You aren't the only one using Subversion. I'm also using it to keep track of my ruleset changes and versions.

bonzai95
July 21st, 2007, 05:55
Added a couple lines to handle removing dead NPCs and dead players.

"/cleartracker dead" clears out NPCs who have Wounds >= HP

"/cleartracker alldead" clears out all entries who have Wounds >= HP


-- clear out the tracker
function clearTracker(params)
ct = Interface.openWindow("combattracker","");
for k, v in ipairs(ct.list.getWindows()) do
if params == "all" then
v.close();
elseif params == "dead" then
if v.wounds.getValue() >= v.hp.getValue() and v.charactertype ~= "pc" then
v.close();
end
elseif params == "alldead" then
if v.wounds.getValue() >= v.hp.getValue() then
v.close();
end
elseif v.charactertype ~= "pc" then
v.close();
end
end
end

If you happen to start wounds = HP and then count down to 0 you can change the

>= v.hp.getvalue()

to

<= 0

and it should work

bonzai

thrylax
July 23rd, 2007, 19:14
I just made a post about a community open source type d20 ruleset. Maybe we can all get together and get one started. Have a look.
https://www.fantasygrounds.com/forums/showthread.php?t=6848

ChemicalAgent
December 22nd, 2008, 23:54
Thanks for the code guys, but I have a question. Whenever I add it to chatmanager.lua I get the following error when I try to call it using the chat window.

Script Error: [string "scripts/chatmanager.lua"]:71: attempt to index global 'ct' (a nil value)

Any ideas on how to fix it?

hgordillo
February 3rd, 2009, 16:57
Same here..maybe an FG update breaks this script?