Page 1 of 1

Display damage in unitdef description?

Posted: 12 Nov 2013, 00:29
by Forboding Angel
Is there a way that I can display a unit's damage and reloadrate in the description of that unit luamagiccally? Atm I am doing it by hand, and it's a pita.

Re: Display damage in unitdef description?

Posted: 12 Nov 2013, 00:40
by smoth
yeah. see healthbar rip that off plug it into the info box.

Re: Display damage in unitdef description?

Posted: 12 Nov 2013, 00:52
by zwzsg
See kp_tooltip.lua ?

Image

Re: Display damage in unitdef description?

Posted: 12 Nov 2013, 01:28
by Forboding Angel
So it can't be put INTO the description, only put adjacent to where the description is displayed.

Bit more complicated than I hoped for, but meh, I'll live.

Thanks guys

Re: Display damage in unitdef description?

Posted: 12 Nov 2013, 12:43
by knorke
Do you mean the engine tooltip or a widget tooltip like in KP or zK?
For widgets obvious way is to edit the widget that it gets another field where it shows DPS and not use unitdef description.

There was no mentioning of widget so I will just babble on about engine tooltip. (the /tooltip one)

The supersimple way like:

Code: Select all

unitdef = 
{
unitname = "Tank",
weapondef = {
damage = 150,
},
description = "Deals " .. weapondef.damage .. " damage per shot",
}
does IIRC not work in Lua.

But this should work:

Code: Select all

unitdef = 
{
unitname = "Tank",
weapondef = {
damage = 150,
},
}
unitdef.description = "Deals " .. unitdef.weapondef.damage .. " damage per shot"
(This just to show principle, instead of just damage there would be formula to calculate real DPS from burstrate, number of projectiles etc and a loop for multiple weapons)

Even better is imo to have the description generation in _post.lua, especially if you have many other things in description.
Something like that:
description = [[Tank Destroyer Light, 25% Damage vs Buildings• Can fire while underwater Requires +5 Power]],
could/should be automatically generated imo.

Re: Display damage in unitdef description?

Posted: 13 Nov 2013, 00:46
by Forboding Angel
^^ this, is exactly what I was looking for :-) Thanks