DPS widget?
Moderator: Moderators
DPS widget?
We still have this thing but it still only shows damage taken not damage dealt. Was there ever a version made that showed damage dealt?
Re: DPS widget?
Gadget-only, if you want to see damage to opponents. You could use a Widget to do the actual display, ofc.
- TheFatController
- Balanced Annihilation Developer
- Posts: 1177
- Joined: 10 Dec 2006, 18:46
Re: DPS widget?
I was thinking of making a gadget version for Spring Skirmish at some point with a tiny dummy widget that just turns it on and off, but if someone else wants to write it that'd be cool 

Re: DPS widget?
Well, basically... all we need is to put a Spring.SendLuaUIMsg() in a UnitDamaged loop, and pass it to unsynced.
Only problem is, we need to send several variables over as one string.
Anybody have utility code for parsing a string where data is delimited by commas available?
IDK how to do that, off-hand, otherwise this is really easy and I'd be happy to write the display part. The other route is to use a Widget to merely tell LuaRules to quit displaying this data to a given Team, I suppose, but that is a lot messier and might cause problems.
Only problem is, we need to send several variables over as one string.
Anybody have utility code for parsing a string where data is delimited by commas available?
IDK how to do that, off-hand, otherwise this is really easy and I'd be happy to write the display part. The other route is to use a Widget to merely tell LuaRules to quit displaying this data to a given Team, I suppose, but that is a lot messier and might cause problems.
Re: DPS widget?
Code: Select all
-- Compatibility: Lua-5.1
function split(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
Code: Select all
split('foo/bar/baz/test','/')
--> {'foo','bar','baz','test'}
split('/foo/bar/baz/test','/')
--> {'foo','bar','baz','test'}
split('/foo/bar/baz/test/','/')
--> {'foo','bar','baz','test'}
split('/foo/bar//baz/test///','/')
--> {'foo','bar','','baz','test','',''}
split('//foo////bar/baz///test///','/+')
--> {'foo','bar','baz','test'}
split('foo','/+')
--> {'foo'}
split('','/+')
--> {}
split('foo','') -- opps! infinite loop!
Re: DPS widget?
OK, so I can send "unitID/damage", etc., and parse it out that way? Excellent.
Lemme look at the issue of security for a minute (kinda skipped that, sigh) and I'll bang something out.
Lemme look at the issue of security for a minute (kinda skipped that, sigh) and I'll bang something out.
Re: DPS widget?
Why not just use:
Code: Select all
--//unsynced (this is missing the synced->unsynced wrapper!)
function gadget:UnitDamaged(...)
if (Script.LuaUI.UnitDamaged) then
Script.LuaUI.UnitDamaged(...)
end
end
Re: DPS widget?
IDK what that, "Script." means, for one thing. Does that mean "check to see if that LuaUI is running"?
Almost done with the Gadget-only version, it's displaying and stuff. Haven't worried about paralyzer yet.
Almost done with the Gadget-only version, it's displaying and stuff. Haven't worried about paralyzer yet.
Re: DPS widget?
Here's an all-Gadget version. Very simple but it works.
<snipped, this was badly-written junk anyhow>
I am still pondering how to deal with it securely on the other side of the Widget aisle. If I just send a message with the "a" parameter, that should work I guess.
But, now that I have it working all-Gadget, I'm more tempted to just write a "turn off this feature locally" Widget, frankly.
<snipped, this was badly-written junk anyhow>
I am still pondering how to deal with it securely on the other side of the Widget aisle. If I just send a message with the "a" parameter, that should work I guess.
But, now that I have it working all-Gadget, I'm more tempted to just write a "turn off this feature locally" Widget, frankly.
Last edited by Argh on 30 Oct 2009, 09:55, edited 1 time in total.
Re: DPS widget?
Makes an unsynced gadget calls a function that is in a widget.Argh wrote:IDK what that, "Script." means, for one thing.
The extra "if" in jK exemple is because of course you should check that this function exists before calling it.
Re: DPS widget?
Ok, so:
...calls the function fooBar in a Widget? Okie doke. Does Script.LuaRules.fooBar work, or is that one-way only?
Code: Select all
if (Script.LuaUI.fooBar) then
Script.LuaUI.fooBar(...)
end
- TheFatController
- Balanced Annihilation Developer
- Posts: 1177
- Joined: 10 Dec 2006, 18:46
Re: DPS widget?
I've run a quick test and it seems quite a lot more CPU intensive than my original widget, there should be some way of just importing that code into unsynced
Re: DPS widget?
Yeah, there are two big no-nos in that initial version: it's allowing multiple table entries per UnitID, which means rapid-fire weapons cause huge pain, and it was doing updates inefficiently. Sorry, orkish get-it-dun code and all that. This should be a considerable improvement:
<snipped, to shorten thread>
<snipped, to shorten thread>
Re: DPS widget?
OK, here's a Gadget that uses a Widget to control output. I need a brave couple of people to test it with a modified BA/CA or something, to make sure that the security part works OK.
It shows your damage in white, all other damage is in yellow. It fades and moves (and it could be made even fancier, but the main thing's to make it all work right).
Smoth, you asked for it, so I volunteer you to test data security. Things you should see:
1. If the other player attacks a third party (Gaia, say), you should see nothing. That is not a bug.
2. If you turn your display off, the other player should still see a display.
Let me know what bugs if any are found. It works in Stock World Builder, but I have no idea if the multiplayer aspect and security works right or not.
It shows your damage in white, all other damage is in yellow. It fades and moves (and it could be made even fancier, but the main thing's to make it all work right).
Smoth, you asked for it, so I volunteer you to test data security. Things you should see:
1. If the other player attacks a third party (Gaia, say), you should see nothing. That is not a bug.
2. If you turn your display off, the other player should still see a display.
Let me know what bugs if any are found. It works in Stock World Builder, but I have no idea if the multiplayer aspect and security works right or not.
- Attachments
-
- dps_ControlWidget.lua
- (443 Bytes) Downloaded 24 times
-
- dps_Gadget.lua
- (2.93 KiB) Downloaded 26 times
Re: DPS widget?
Sooo... does it work for MP? Is it still inefficient? Any other goofs, wishlist things, etc., or am I done with this one?
Re: DPS widget?
<bumpity>
Hey Smoth... you asked for it, please test it in MP and report back...
Hey Smoth... you asked for it, please test it in MP and report back...