Girder limit distance

10 replies [Last post]
Haled
User offline. Last seen 9 years 15 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 23 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

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 23 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

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 23 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

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 29 weeks 3 days ago. Offline
Joined: 2012-06-20
Posts: 1304

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

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

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 29 weeks 3 days ago. Offline
Joined: 2012-06-20
Posts: 1304

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

nemo
nemo's picture
User offline. Last seen 23 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

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 3 weeks 6 days ago. Offline
Joined: 2009-07-18
Posts: 563

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 23 weeks 4 days ago. Offline
Joined: 2009-01-28
Posts: 1861

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 9 years 15 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

User login

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