Starting building spawn differs from Construction
Moderator: Moderators
Starting building spawn differs from Construction
I am getting a different orientiaton on my buildings from when they spawn to when they are constructed by a builder.
I've been told that there is a facing setting in the CreateUnit function and another setting that is determined by the player.
How do I manage these different facing settings? I can't find the CreateUnit function anywhere.
Edit: Thanks
I've been told that there is a facing setting in the CreateUnit function and another setting that is determined by the player.
How do I manage these different facing settings? I can't find the CreateUnit function anywhere.
Edit: Thanks
Re: Starting building spawn differs from Construction
CreateUnit is specified here: http://springrts.com/wiki/Lua_SyncedCtrl#Unit_Handling
The synced/unsynced - read/ctrl may be a bit confusing at first, but here is a breakdown of how they differ.
Read parts only read from the game state, things like what units are where, what commands are queued up, and calling any of them should have no effect on what is happening in the game.
Ctrl parts obviously effect the state of the game, things like creating a unit, moving it, giving it orders.
Synced/unsynced is a bit different;
Spring runs a deterministic simulation of a game, where the only inputs are the commands given to each unit. This design choice has multiple advantages, but that is discussed elsewhere.
Think of spring as a model-view-controller architecture;
-changing the model's state directly roughly corresponds to syncedctrl
-reading the state of the model is syncedread
-Adding inputs to the controller is unsyncedctrl
-reading the state of the view is unsyncedread
Apologies for the bad analogy.
The synced/unsynced - read/ctrl may be a bit confusing at first, but here is a breakdown of how they differ.
Read parts only read from the game state, things like what units are where, what commands are queued up, and calling any of them should have no effect on what is happening in the game.
Ctrl parts obviously effect the state of the game, things like creating a unit, moving it, giving it orders.
Synced/unsynced is a bit different;
Spring runs a deterministic simulation of a game, where the only inputs are the commands given to each unit. This design choice has multiple advantages, but that is discussed elsewhere.
Think of spring as a model-view-controller architecture;
-changing the model's state directly roughly corresponds to syncedctrl
-reading the state of the model is syncedread
-Adding inputs to the controller is unsyncedctrl
-reading the state of the view is unsyncedread
Apologies for the bad analogy.
Re: Starting building spawn differs from Construction
I searched my scripts and units for a CreateUnit entry but found nothing?
Re: Starting building spawn differs from Construction
Which scripts did you search? As CreateUnit is syncedctrl, only gadgets may have access to it.
Gadgets are all things that implement core game mechanics. They cannot be changed by the players. Thus, only gadgets may call syncedctrl stuff.
Widgets can be different or enabled/disabled by each player, and they may not call any syncedctrl stuff.
EDIT: here is the old, simple implementation of spawning the starting units in BA: http://imolarpg.dyndns.org/trac/balates ... ua?rev=303
Gadgets are all things that implement core game mechanics. They cannot be changed by the players. Thus, only gadgets may call syncedctrl stuff.
Widgets can be different or enabled/disabled by each player, and they may not call any syncedctrl stuff.
EDIT: here is the old, simple implementation of spawning the starting units in BA: http://imolarpg.dyndns.org/trac/balates ... ua?rev=303
Re: Starting building spawn differs from Construction
Besides the whole facing option you can just rotate units (buildings too if using a newer engine) freely by invoking the Spring.SetUnitDirection(unitId, x, y, z).
I'm not sure if it properly sets the yardmap and if units built by that building will be properly rotated nowdays, iirc jk fixed that, but I would have to try to be sure.
I'm not sure if it properly sets the yardmap and if units built by that building will be properly rotated nowdays, iirc jk fixed that, but I would have to try to be sure.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: Starting building spawn differs from Construction
You might also need to search inside basecontent (not sure but have no code to hand right now).
Re: Starting building spawn differs from Construction
If i put that into the...gajop wrote:Besides the whole facing option you can just rotate units (buildings too if using a newer engine) freely by invoking the Spring.SetUnitDirection(unitId, x, y, z).
I'm not sure if it properly sets the yardmap and if units built by that building will be properly rotated nowdays, iirc jk fixed that, but I would have to try to be sure.
fucntion script.Create()
Spring.SetUnitDirection(unitId, x, y, z).
end
What would I call for the UnitID?
Thanks
Re: Starting building spawn differs from Construction
You would probably call it like this:
local unitId = Spring.CreateUnit(...)
Spring.SetUnitDirection(unitId, x, y, z)
If you want to set the direction in a script.Create, well, no idea how you do it then :)
local unitId = Spring.CreateUnit(...)
Spring.SetUnitDirection(unitId, x, y, z)
If you want to set the direction in a script.Create, well, no idea how you do it then :)
Re: Starting building spawn differs from Construction
lua scripts know their own unitID.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: Starting building spawn differs from Construction
Enter the variable "unitID" - it globally exists in this scope.Zhall wrote:If i put that into the...gajop wrote:Besides the whole facing option you can just rotate units (buildings too if using a newer engine) freely by invoking the Spring.SetUnitDirection(unitId, x, y, z).
I'm not sure if it properly sets the yardmap and if units built by that building will be properly rotated nowdays, iirc jk fixed that, but I would have to try to be sure.
fucntion script.Create()
Spring.SetUnitDirection(unitId, x, y, z).
end
What would I call for the UnitID?
Thanks
Re: Starting building spawn differs from Construction
Spring.SetUnitDirection(unitId, x, y, z) does nothing when called under function script.Create()
I simply want to force the facing direction of the building when it is constructed.
EDIT: I found a way around this, aswell as the start unit's direciton is set in the game_spawn.lua startup script. Settting facing to 0 should make everything face south, other than that the model itself is messed up
I simply want to force the facing direction of the building when it is constructed.
EDIT: I found a way around this, aswell as the start unit's direciton is set in the game_spawn.lua startup script. Settting facing to 0 should make everything face south, other than that the model itself is messed up
Re: Starting building spawn differs from Construction
unitId is NOT THE SAME AS unitIDZhall wrote:Spring.SetUnitDirection(unitId, x, y, z) does nothing when called under function script.Create()
Re: Starting building spawn differs from Construction
Good spot. However the problem was caused by game_spawn.lua calculating facing for startunit.