(RESOLVED) What is the proper way to find out when a girder has been placed?
Tue, 2013-12-31 01:35
Okay, here is a Lua question:
How do I properly find out when a girder (or rubber) has been placed by the player?
Here are some ways which do not work:
- Using onHogAttack: Useless, it also gets called if a placement attempt has failed (for example on an invalid position).
- Using onGearAdd: Also gets called when placement has failed.
- Observing the number of girders in inventory for changes: Does not work if the player has infinite girders.
Hi, I am a Hedgewars developer.
If it helps i could offer you my girder script that places girders randomly.
Link : http://pastebin.com/EKt32BYs
I don't think it will help though, BTW randomly placed objects don't go through maps, Don't believe me? Set the girder place function to onTick.
{} {}
\___/ - Happy
That doesn’t help at all. I don’t want to place girders, I want to find out when a girder has been placed.
Hi, I am a Hedgewars developer.
It took my a long while to figure it out (it annoyed me that I couldn't figure it out, and so the I kept coming back to it ) and I finally came up with a hack which works.
http://pastebin.mozilla.org/3922099
The only little problem is that, when you have infinite girders and you place one correctly, the top of the screen will mention that you have 98 girders left, although you actually have infinite girders remaining. It's a little annoying, but eh, it's not really a big deal. :P
I hope it helps, though there really should be a better way of going about it.
For your 98 error, Maybe something along the lines of if ammo girder = 98 then change the displayed string to Infinite
I don't know, I'm just being my normal "Based on theroy" self again...
{} {}
\___/ - Happy
With next release (0.9.21 or something),
these should work:
frameIdx
is given so that you can figure out the used orientation based on the girder's sprite texture:Note: Columns go before rows
So the
frameIdx
for the image above goes like:0 3 6 1 4 7 2 5
so a
frameIdx
of 0 would indicate a short horizontal girder, aframeIdx
of 6 a long vertical one.sheepluva <- me my code stats ->
a Hedgewars Developer
click here to message me
<- where I'm from what I speak ->
Thank you, sheepluva. I have tested onGirderPlacement and onRubberPlacement and both work as intended. This old problem has now finally resolved.
In case you wondered, here is what I needed this for:
http://www.hedgewars.org/node/5615?page=0#comment-29932
This strategy script is now working, but not without some weird hacks.
Hi, I am a Hedgewars developer.