Placing a building outside of the construction yard.

Placing a building outside of the construction yard.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Smeg
Posts: 5
Joined: 16 Aug 2012, 22:11

Placing a building outside of the construction yard.

Post by Smeg »

Hi all,

I have a construction yard which is capable of building both buildings and mobile units. Mobile units are working fine, but when i build the bulding it builds it inside the construction yard and when it is finished it obviously just stays there.

I would like it so i am asked to place the new bulding in a area on the map before construction. Much like how command and conquer do things.

Can someone point me in the right direction?

UnitDef and Script attached.

Many Thanks

Smeg
Attachments
cyardscript.lua
Script of cyard
(2.84 KiB) Downloaded 14 times
cyard.lua
UnitDef (So far)
(1.49 KiB) Downloaded 8 times
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Placing a building outside of the construction yard.

Post by FLOZi »

Having both in one unit isn't really possible (unless you are ok with having the mobiles also 'placed' on the map, rather than automatically out of the factory - then it is trivial), here's a quick mindfart that might work:

1. Have your current unit as it is, this will build mobiles
2. have an invisible second unit which builds the structures
3. Have a gadget (or just the unit #1 script!) spawn unit #2 whenever unit#1 is created, make it invisible and always selected whenever its corresponding #1 is selected (selection will require an additional gadget to the script)

Might need some extra trickery or adjustments but this is an approach that should work.
User avatar
Smeg
Posts: 5
Joined: 16 Aug 2012, 22:11

Re: Placing a building outside of the construction yard.

Post by Smeg »

That's a shame!

How about making the factory a mobile unit, driving it into place and then setting it in place forever with the aid of a button option? can unitDef's be changed like this or are they always static? Or again will i have to do something funky in code to say something like has the 'set forever button' been pressed? if yes unit cannot move. Just a mindfart also.

I do like your idea though, I'm sure once i have more experience i might try something like this. I'm trying to not get bogged down with such things so early into trying this out, but i will have to cross these at some point, I'd probably learn more trying something like this.

Thanks for the quick response again.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Placing a building outside of the construction yard.

Post by FLOZi »

Smeg wrote:How about making the factory a mobile unit, driving it into place and then setting it in place forever with the aid of a button option? can unitDef's be changed like this or are they always static? Or again will i have to do something funky in code to say something like has the 'set forever button' been pressed? if yes unit cannot move. Just a mindfart also.
UnitDefs can't be changed on the fly (only during loading) but you can do several things to stop a unit from moving (eg. switch for a static unit, enable MoveCtrl, set maximum speed to 0 etc) and tying it to a button is easy.

A mobile unit with 0 max speed would be able to build both units and structures but would require the player to 'place' both types on the map, rather than having factory-like construction for the mobiles.
I do like your idea though, I'm sure once i have more experience i might try something like this. I'm trying to not get bogged down with such things so early into trying this out, but i will have to cross these at some point, I'd probably learn more trying something like this.
Understandable. Though sometimes fighting Spring to get what you want is part of the fun :wink:
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Placing a building outside of the construction yard.

Post by Google_Frog »

You don't need to spawn extra fake units. Just make your unit a static builder (as in not a factory) then reimplement factory logic with a gadget.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Placing a building outside of the construction yard.

Post by knorke »

The easiest way is probally to make your building consist of two units:
a garage (or whatever) for the vehicles and a crane for the buildings.
They could be spawned together and players would click garage/crane for whatever they want.

http://springrts.com/wiki/Lua_Scripting
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Placing a building outside of the construction yard.

Post by FLOZi »

Google_Frog wrote:You don't need to spawn extra fake units. Just make your unit a static builder (as in not a factory) then reimplement factory logic with a gadget.
How to circumvent the fact that for mobile builders build commands are CMDTYPE.ICON_MAP? I would have thought AllowCommand only gets it after the order is placed... I guess maybe you can replace the buildorder commands with your own custom commands entirely. I guess that would be the 'clean' way to do it.
Post Reply

Return to “Lua Scripts”