Girder limit distance

10 replies [Last post]
Haled
User offline. Last seen 4 years 2 weeks ago. Offline
Joined: 2015-08-26
Posts: 2

Hello.
I'm new to the forum and I recently discovered Hedgewars.
Sorry for the language but I'm Italian and I do not possess a good command of English so I use Google traslator. Smile
SORRY ... I hope to convey the message.
anyway...
I'm planning new missions of various kinds but I have some question about the script lua. (because I'm not good with scripts)
I wanted to know if I can remove the distance limit in place the girder.
I would like to create a maze and the player's goal is to reach the end of the path and try to hinder others on their path by placing girder. Each player has his own path and those who collect the cash at the end of its path wins. The player, however, MUST BE ABLE TO PLACE the girder across the screen, as happens nell'HedgeEditor or Construction Mode.
Can someone please help me?
I await your response ...
Hello guys...

nemo
nemo's picture
User offline. Last seen 1 hour 14 min ago. Offline
Joined: 2009-01-28
Posts: 1720

You could do that with a lua script easily enough, just like in construction mode. It would even be a fairly small lua script. Drop by irc://irc.freenode.net/hedgewars for help ( use the Live Chat link at the top of the site if you don't have an IRC client already, or try https://addons.mozilla.org/en-US/firefox/addon/chatzilla/ in which case the link above would send you straight there.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

nemo
nemo's picture
User offline. Last seen 1 hour 14 min ago. Offline
Joined: 2009-01-28
Posts: 1720

FWIW, based on IRC discussion, think we are going to let lua define girder placement distance in a configurable gear value in .22, since the approach construction mode uses is a wee bit convoluted. That is, it has to figure out that one has a girder active, keep track of user actions that change the rotation, and use that to spawn a girder sprite when targetting is triggered. Props to mikade for going to the trouble, but, yeah, a bit of a pain ☺

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

nemo
nemo's picture
User offline. Last seen 1 hour 14 min ago. Offline
Joined: 2009-01-28
Posts: 1720

Update.
IMO the approach in Construction mode is not really needed.
To recapitulate comments in chat, I *think* this would work...
local myGirder
function onGearAdd(gear)
if GetGearType(gear) == gtGirder then
myGirder = gear
end
end

function onHogAttack(wep)
if wep == amGirder then
x,y = GetGearTarget(myGirder)
PlaceGirder(x, y, GetState(myGirder))
DeleteGear(myGirder)
end
end

This should probably work. Totally untested.

*edit, fixed typo*

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 4 hours 11 min ago. Offline
Joined: 2012-06-20
Posts: 1089

Nemo's code almost works, but it is “GetState” instead of “GetGearState”. The basic idea of nemo is correct. I have used this skeleton to add this functionality to my Game Hacks script, but I added some tweaks.

My Game Hacks script (http://www.hedgewars.org/node/6279) now also includes a parameter where you can increase the girder placement range or disable the limit completely.

Read the code from line 1107 (in version 7).
The “lastConstruction” variable is just written to whenever a gtGirder or gtRubber is created.

However, I have run into problems with placing rubber, because the only way to place rubber with Lua is with PlaceSprite (there is no PlaceRubber), but unlike PlaceGirder, this ignores the land so it would be perfectly possible to place rubber inside land!
Sad Smiley
So I have disabled the range modifier for rubber for now.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

sheepluva
sheepluva's picture
User offline. Last seen 2 weeks 6 days ago. Offline
Joined: 2009-07-18
Posts: 531

related note:

The next version of Hedgewars (0.9.22) will have a call called SetMaxBuildDistance.

e.g. use SetMaxBuildDistance(1000) to allow placing Girder/etc. within a 1000 pixels radius of the Hedgehog.

Use SetMaxBuildDistance(0) to have no limit and allow placing anywhere.

If you want to reset the build distance to the default value, just call the function without any parameter: SetMaxBuildDistance()

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

Wuzzy
Wuzzy's picture
User offline. Last seen 4 hours 11 min ago. Offline
Joined: 2012-06-20
Posts: 1089

Nice!
Don't forget to update Construction Mode and HedgeEditor, respectively.

If you insist, I could do it for you.

Hi, I am a Hedgewars developer. Smile I accept personal donations in bitcoin. Heart 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

nemo
nemo's picture
User offline. Last seen 1 hour 14 min ago. Offline
Joined: 2009-01-28
Posts: 1720

sheepluva allegedly wrote:

related note:

The next version of Hedgewars (0.9.22) will have a call called SetMaxBuildDistance.

e.g. use SetMaxBuildDistance(1000) to allow placing Girder/etc. within a 1000 pixels radius of the Hedgehog.

Use SetMaxBuildDistance(0) to have no limit and allow placing anywhere.

If you want to reset the build distance to the default value, just call the function without any parameter: SetMaxBuildDistance()

Do we need a call like this? This sort of fine-grained thing seems like something we could simply use the Radius parameter on the gear to set.

That allows lua more flexibility no? Like expanding radius in certain circumstances or for certain crate selections or distinguishing between rubber and girder ranges.

And we already let lua mess with a bunch of gear parameters for various effects. This seems no different.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

sheepluva
sheepluva's picture
User offline. Last seen 2 weeks 6 days ago. Offline
Joined: 2009-07-18
Posts: 531

nemo allegedly wrote:

Do we need a call like this? This sort of fine-grained thing seems like something we could simply use the Radius parameter on the gear to set.

That allows lua more flexibility no? Like expanding radius in certain circumstances or for certain crate selections or distinguishing between rubber and girder ranges.

And we already let lua mess with a bunch of gear parameters for various effects. This seems no different.

Hm, you have a point there.

Although it wouldn't allow for more flexibility (you can still do the exact thing you described either way with no additional effort).

The global way at least saves Lua from having to check ammo type on every weapon change and having to set radius each and every time something that can be built is selected.

Also scripts would have to be changed if new buildable ammo is added.

Wait wait wait wait wait... there is no gear at that point when placing... just ammo type... what radius to begin with?

If you want to check range only after - the available construction range couldn't be displayed to the player by engine.
Then even more LUA code would be necessary to do that.

  sheepluva <- me  my code stats -> 
a Hedgewars Developer


   <- where I'm from  what I speak -> 

nemo
nemo's picture
User offline. Last seen 1 hour 14 min ago. Offline
Joined: 2009-01-28
Posts: 1720

Radius in onGearAdd, not onHogAttack

And was mostly just that "letting lua twiddle w/ gear values" is how we normally handle messing w/ weps

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Haled
User offline. Last seen 4 years 2 weeks ago. Offline
Joined: 2015-08-26
Posts: 2

Thanks guys , really thank you for everything !!
Now I can finish my degree ... as soon as I can I 'll show you some work if you like .
Anyway thanks again ... you are great Smile

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]