I'm a Lua noob and have been messing with BrainDamage's script with the aforementioned name to not only stop move orders but also build orders outside a certain area on my map. Stopping move, attack etc. works but do you guys have any suggestions how to stop construction? It seems to me that I could prevent stuff from being built even though they would still be in the queue, if placed on buildable locations and that might annoy players. For instance, if a radar can be placed in the middle of a queue and the queue completes without it being built, it certainly sucks.
Ideally, such a script would not only prevent queueing of orders like that but it would even show the area as unbuildable when pressing F2 but that might be too much to ask. It amazes me that this functionality hasn't been implemented through the typemap but until it is, this sort of lua script could do the trick. My solution with the current version of the map has been to make the terrain "spiky" so that nothing can be built and that works fine but doesn't look pretty.
Since I'm new to Lua and spring, no answer can be too detailed or explicit :)
better unit_prevent_outsides_orders.lua needed
Moderator: Moderators
Re: better unit_prevent_outsides_orders.lua needed
Um, just get the value of the typemap. If X, then allow the command, if Y, then fail the command. If you return false, a build order will not be added to the queue. No need for spiky stuff, you just need to set up your typemaps appropriately.
Re: better unit_prevent_outsides_orders.lua needed
What is wrong with preventing them the same way you prevented move/attack etc? All build commands have a negative command ID / all negative command ID's are builds (afaik)
-
- Posts: 7
- Joined: 28 Dec 2009, 03:42
Re: better unit_prevent_outsides_orders.lua needed
I didn't know how to filter build commands until you said that about negative IDs so thanks!
Now that I think about it, I don't know if there's any reason not to prevent all commands outside the playing area but now the code prevents construction as well as movement outside so gameplay is what I want it to be.
But since you know this stuff I follow up by asking if there's a way to get the ideal solution: Currently the area is mostly green when you press F2 and have selected a building. Is there any way to make it show up red like any other unbuildable area then?

But since you know this stuff I follow up by asking if there's a way to get the ideal solution: Currently the area is mostly green when you press F2 and have selected a building. Is there any way to make it show up red like any other unbuildable area then?
Re: better unit_prevent_outsides_orders.lua needed
Yeah, make its typemap 0 0 0 0 then it should be red.
-
- Posts: 7
- Joined: 28 Dec 2009, 03:42
Re: better unit_prevent_outsides_orders.lua needed
Won't that only make it show red because it's impassable for all cons except aircons? And only aircons could reach the area in question if the gadget didn't prevent it.
-
- Posts: 7
- Joined: 28 Dec 2009, 03:42
Re: better unit_prevent_outsides_orders.lua needed
Argh, how do I get the typemap value?
And is there any simple way to make building preview screens red when you have one selected and hover the mouse over the "forbidden" area? Then the only confusing thing would be F2, when used with an aircon and LOS to the forbidden area.
And is there any simple way to make building preview screens red when you have one selected and hover the mouse over the "forbidden" area? Then the only confusing thing would be F2, when used with an aircon and LOS to the forbidden area.
Re: better unit_prevent_outsides_orders.lua needed
Code: Select all
local type = Spring.GetGroundInfo(x,z)