lua scripting -- onHogAttack(ammoType)
Hey, its been a while since I posted here...
First off, since I didn't get the chance to say it yet, thanks to all the devs for cranking out the latest version of Hedgewars... and yes, I am a bit late.
According to the LuaAPI at: https://code.google.com/p/hedgewars/wiki/LuaAPI#onHogAttack%28ammoType%29
onHogAttack(ammoType)This function is called when you press the attack key. Beginning with 0.9.21, the parameter ammoType is provided. It contains the ammo type of the weapon used for the attack.
However, it seems like the check for the ammo type occurs AFTER the weapon is used, so if you only have one ammo for the weapon used then ammoType returns "amNothing".
That doesn't really seem intentional...
If anyone can think of a workaround I could use in the mean time that would be appreciated. I basically want to check to see if ammoType is one of the elements in an array (specifically all the weapons and utilities that end the turn).
Thanks in advance!
Welcome back pal ^^
And huh, interesting, I shall look into it later today
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
I wrote a fix that should go into next release.
For now you can probably work around it by caching the result of GetCurAmmoType() e.g. whenever onSetWeapon() is called or something.
Then use that cached value when handling onHogAttack().
The argument "AmmoType" for onHogAttack() is rather new anyway, so there might be existing scripts working using a workaround similar to the one above.
sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
As sheepluva says, thats what you have to do
try this:
If everything is right, then hog once attack, he/she/it will say a number, or a value starting with 'am'.
Good Luck
oh hi