Girder limit distance

10 replies [Last post]
Haled
User offline. Last seen 8 years 29 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 12 hours 33 min 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 12 hours 33 min 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 12 hours 33 min 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 3 days 16 hours ago. Offline
Joined: 2012-06-20
Posts: 1301
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 1 day 11 hours ago. Offline
Joined: 2009-07-18
Posts: 561
related note: The next version of Hedgewars (0.9.22) will have a call called [b][code]SetMaxBuildDistance[/code][/b]. e.g. use [code]SetMaxBuildDistance(1000)[/code] to allow placing Girder/etc. within a 1000 pixels radius of the Hedgehog. Use [b][code]SetMaxBuildDistance(0)[/code][/b] to have no limit and [b]allow placing anywhere[/b]. If you want to reset the build distance to the default value, just call the function without any parameter: [code]SetMaxBuildDistance()[/code]
  [url=/user/3290][color=white][b]sheepluva[/b][/color][/url][color=#90BA5D] <- me[float=right]  [/float][float=right][url=https://www.openhub.net/accounts/80048][img]https://www.openhub.net/accounts/80048/widgets/account_tiny.gif[/img][/url][/float][float=right]my code stats -> [/float][/color] [i][color=#6080C0][size=8]a[size=4] [/size][/size][/color][color=yellow]Hedgewars Developer[/color][/i] [center][float=left]  [/float][float=left][url=https://twitter.com/sheepytweety][img]/images/twitter.png[/img][/url][/float] [url=/privatemsg/new/3290][color=#C0C0C0]click here to message me[/color][/url][/center] [color=#90BA5D][float=left]  [/float][float=left][url=https://en.wikipedia.org/wiki/Austria][img]/images/Flags/austria.png[/img][/url][/float][float=left] <- where I'm from[/float][float=right]  [/float][float=right][img]/images/Flags/united_kingdom.png[/img][/float][float=right][img]/images/Flags/germany.png[/img][/float][float=right]what I speak -> [/float][/color]
Wuzzy
Wuzzy's picture
User offline. Last seen 3 days 16 hours ago. Offline
Joined: 2012-06-20
Posts: 1301
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 12 hours 33 min ago. Offline
Joined: 2009-01-28
Posts: 1861
[quote=sheepluva] related note: The next version of Hedgewars (0.9.22) will have a call called [b][code]SetMaxBuildDistance[/code][/b]. e.g. use [code]SetMaxBuildDistance(1000)[/code] to allow placing Girder/etc. within a 1000 pixels radius of the Hedgehog. Use [b][code]SetMaxBuildDistance(0)[/code][/b] to have no limit and [b]allow placing anywhere[/b]. If you want to reset the build distance to the default value, just call the function without any parameter: [code]SetMaxBuildDistance()[/code] [/quote] 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 1 day 11 hours ago. Offline
Joined: 2009-07-18
Posts: 561
[quote=nemo] 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. [/quote] 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.
  [url=/user/3290][color=white][b]sheepluva[/b][/color][/url][color=#90BA5D] <- me[float=right]  [/float][float=right][url=https://www.openhub.net/accounts/80048][img]https://www.openhub.net/accounts/80048/widgets/account_tiny.gif[/img][/url][/float][float=right]my code stats -> [/float][/color] [i][color=#6080C0][size=8]a[size=4] [/size][/size][/color][color=yellow]Hedgewars Developer[/color][/i] [center][float=left]  [/float][float=left][url=https://twitter.com/sheepytweety][img]/images/twitter.png[/img][/url][/float] [url=/privatemsg/new/3290][color=#C0C0C0]click here to message me[/color][/url][/center] [color=#90BA5D][float=left]  [/float][float=left][url=https://en.wikipedia.org/wiki/Austria][img]/images/Flags/austria.png[/img][/url][/float][float=left] <- where I'm from[/float][float=right]  [/float][float=right][img]/images/Flags/united_kingdom.png[/img][/float][float=right][img]/images/Flags/germany.png[/img][/float][float=right]what I speak -> [/float][/color]
nemo
nemo's picture
User offline. Last seen 12 hours 33 min 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 8 years 29 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-2023 Hedgewars Project. All rights reserved. [ contact ]