Auto First Build Facing
Moderator: Moderators
Auto First Build Facing
So that Build Facing default is less stupid than always south.
Instruction: copy into \LuaUI\Widgets
Edit: Version before that edit was very broken
Instruction: copy into \LuaUI\Widgets
Edit: Version before that edit was very broken
- Attachments
-
- autofirstbuildfacing.lua
- (1.56 KiB) Downloaded 45 times
Re: Auto First Build Facing
Simple but useful, nice job.
Re: Auto First Build Facing
simpler, faster, stronger, shorter, better:
- Attachments
-
- autofirstbuildfacing.lua
- (1007 Bytes) Downloaded 44 times
Re: Auto First Build Facing
could u modify ur lua in that way that u could turn the building by holding e.g. alt+mousewheel up/down?zwzsg wrote:simpler, faster, stronger, shorter, better:
Re: Auto First Build Facing
You should be able to do that in uikeys.txt, and it's unrelated to this widget.
Re: Auto First Build Facing
Cool, I wanted something like that. Good job.
It would be nice if there was an arrow pointing out every time you build a building that produces units to make it more hands down obvious where it's facing.
It would be nice if there was an arrow pointing out every time you build a building that produces units to make it more hands down obvious where it's facing.
Re: Auto First Build Facing
manolo_ wrote:could u modify ur lua in that way that u could turn the building by holding e.g. alt+mousewheel up/down?
Personnaly I have edited my uikeys.txt to add:lurker wrote:You should be able to do that in uikeys.txt
Code: Select all
bind numpad2 buildfacing south
bind numpad4 buildfacing west
bind numpad6 buildfacing east
bind numpad8 buildfacing north
Code: Select all
bind [ buildfacing inc
bind Shift+[ buildfacing inc
bind ] buildfacing dec
bind Shift+] buildfacing dec
Editing uikeys.txt yourself is probably easier and more convenient than asking for Lua Widget. But of course I could wrap up those configuration commands into a lua widget. However, I did not find any "key" for mousewheelup and mousewheeldown.
Indeed it is unrelated. I assumed that [ and ] to turn building was common knownledge. My widget is to remove the hassle of pressing them at each start of the game.lurker wrote:and it's unrelated to this widget.
Re: Auto First Build Facing
I was under the impression scrolling tended to map to mouse 4 and 5, but perhaps not or perhaps only on some setups.
Re: Auto First Build Facing
thx, but i wanted something like that, hold shift+mouse wheel down --> building heading to east, hold shift+mouse wheel down building heading to north, hold shift+mouse wheel down building heading to west, hold shift+mouse wheel up building heading to back to north,.... im not sure if its possible with uikeys.txt
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Auto First Build Facing
Z, I could really use this, but tbh what I need is for the commander to be facing in the correct direction when he spawns (The commander is a factory in this case). Is that doable?
Re: Auto First Build Facing
it is doable with a gadget. IIRC IW already has one.
Re: Auto First Build Facing
Kernel Panic has had something to make the homebases face the center of the map since.. even before Lua! Then it was improved a bit with Lua, which result in now having an ugly half cob half Lua code that I wouldn't recommend copying.
Re: Auto First Build Facing
The gadget I wrote (it was something like a week before this widget iirc) is basically the same process in gadget form. The major difference is that you have to respawn the commander unit to change its direction.
I haven't had this approach cause any problems with any other gadgets/widgets except for select & center widgets, which need to be delayed a couple frames to work properly.
If you can wait about 8-10 hours until I get home, I'll go ahead and release it; it's not terribly advanced code, especially when zwzsg's widget could just as easily be adapted. Hell, maybe there's a better way to do it than the way I used, but afaik you can't change the buildfacing of a building after it's been spawned.
I haven't had this approach cause any problems with any other gadgets/widgets except for select & center widgets, which need to be delayed a couple frames to work properly.
If you can wait about 8-10 hours until I get home, I'll go ahead and release it; it's not terribly advanced code, especially when zwzsg's widget could just as easily be adapted. Hell, maybe there's a better way to do it than the way I used, but afaik you can't change the buildfacing of a building after it's been spawned.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Auto First Build Facing
Yeah I can wait, no rush. And yeah, turrning after spawn would be bad, cause then the yardmap would be lolforked.
Re: Auto First Build Facing
Code: Select all
function gadget:GetInfo()
return {
name = "HQ Heading",
desc = "Sets the heading of the Imperial HQ based on nearest map edge",
author = "Gnome",
date = "October 2008",
license = "PD",
layer = -5,
enabled = true -- loaded by default?
}
end
if (gadgetHandler:IsSyncedCode()) then
function gadget:GameFrame(n)
if(n == 1) then
local mapx = Game.mapX * 512
local mapz = Game.mapY * 512
for _,uid in ipairs(Spring.GetAllUnits()) do
local udid = Spring.GetUnitDefID(uid)
if(UnitDefs[udid].name == "imp_commander") then
local x,y,z = Spring.GetUnitBasePosition(uid)
local team = Spring.GetUnitTeam(uid)
local heading = "south"
if(x > mapx / 2) then --unit is in the east side
if(z > mapz / 2) then --unit is in the south east
if(mapx - x < mapz - z) then heading = "west"
else heading = "north" end
else --unit is in the north east
if(mapx - x < z) then heading = "west"
else heading = "south" end
end
else --unit is in the west side
if(z > mapz / 2) then --unit is in the south west
if(x < mapz - z) then heading = "east"
else heading = "north" end
else --unit is in the north west
if(x < z) then heading = "east"
else heading = "south" end
end
end
Spring.CreateUnit("imp_commander",x,y,z,heading,team)
Spring.DestroyUnit(uid,false,true)
end
end
gadgetHandler:RemoveGadget()
end
end
end
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Auto First Build Facing
Woot! Works perfectly , Thanks Gnome!
Re: Auto First Build Facing
suggestion: sorry in the wrong widget
Last edited by manolo_ on 21 Aug 2009, 21:51, edited 1 time in total.
Re: Auto First Build Facing
Suggestion: the widget should shut itself off after it's been run once, no reason it should keep running.
Re: Auto First Build Facing
It's not and cannot be a widget!
Also, what do you think gadgetHandler:RemoveGadget() is for?
Edit: Oh sorry, you meant mine, not Gnome's.
Well, the one in my third post has: widgetHandler:RemoveWidget() Maybe you were tricked by how it has to remain active until you attempt to place one building? That was because I can't change buildfacing when not in buildplacing mode.
Also, what do you think gadgetHandler:RemoveGadget() is for?
Edit: Oh sorry, you meant mine, not Gnome's.
Well, the one in my third post has: widgetHandler:RemoveWidget() Maybe you were tricked by how it has to remain active until you attempt to place one building? That was because I can't change buildfacing when not in buildplacing mode.
Re: Auto First Build Facing
Yep, I was tricked