Page 1 of 1
GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 09:57
by 9heart
Hi
Code: Select all
function script.HitByWeapon(x,z,weaponDef,damage)
local hitPiece = Spring.GetUnitLastAttackedPiece(unitID) or ""
Spring.echo(hitPiece) -- base,turret,etc
Explode(hitPiece, SFX.EXPLODE)
give error: bad argument #1 to 'Explode' (number expected, got string)
halp
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:00
by jK
9heart wrote:or ""
is wrong
Also "
(number expected, got string)" says that very specific.
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:11
by 9heart
jK wrote:9heart wrote:or ""
is wrong
Also "
(number expected, got string)" says that very specific.
i see other units in mods using Explode(pieceName, type) and they are always passing a string (body, turret,etc) as argument. unless there is some trickery that convert piecename into piecenumber?
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:16
by smoth
They are not strings pieces are numbers bro.
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:19
by 9heart
smoth wrote:They are not strings pieces are numbers bro.
Spring.GetUnitLastAttackedPiece
( number unitID ) -> nil |
string pieceName, number gameframe
local base = piece "base"
local body = piece "body"
local turret = piece "turret"
local gun = piece "gun"
local flare = piece "flare"
someone explain how "flare" is evaluated as number?
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:25
by smoth
= piece "flare"
Returns the piece number
It is really piece("flare)
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:38
by 9heart
ok thanks.
Re: GetUnitLastAttackedPiece
Posted: 07 Mar 2014, 10:55
by smoth
Loaded question
Efficiency depends on use.
Get over using tables it is not that big deal