2025-07-04 00:08 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002503Spring engineUnit Scriptingpublic2011-11-26 16:09
Reporteruser744 
Assigned ToKloot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
Product Version0.82.7+git 
Target VersionFixed in Version 
Summary0002503: (master) unit scripts does not work on startunits, works on units created later
Descriptiongame: spring tanks RC5.2
map: any of those: http://springrts.com/wiki/Spring_Tanks#The_Maps

If you start via spring.exe or the SP menu, you will notice no units scripts seem to be loaded.
units do not turn their wheels, aim or fire.
if you do
/cheat
/give tptaktak
then this unit will work.
If you selfdestruct a unit and wait for a replacement to spawn, this unit will also work.
after /luar rules reload, all units will work.

The start units are created in gadgets\tp_startbase_spawn.lua

Now thinking about it, it might be because I create the units on
function gadget:Initialize()
instead of
function gadget:GameStart()
?
I do this so that you can already see the units even if the game is not yet started. (ie other players are still loading)
That works in current.
Additional Informationinfolog
http://pastebin.com/DYRFV7Pf

http://www.abload.de/img/unitscriptauxh.jpg

1+2 units created by gadgets\tp_startbase_spawn.lua - do not work
(notice the extra parts on the "ice cone" thing are not hidden and the tank has no tracks)

3+4 the same unit types created with /cheat /give - works

5 unit spawned by tp_gamelogic.lua after game was running for some time - works

TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
related to 0002769resolvedabma Units created by gadget before gamestart do not function 
+Relationships

-Notes

~0006830

user744

can somebody please change the title to say master or 0.83?

Tested a bit and it seems that using UnitCreate in
function gadget:Initialize()
indeed results in a unit without working unit script.

~0006831

Kloot (developer)

Last edited: 2011-06-30 13:13

The Lua unit-script gadgets are themselves loaded from unit_script.lua::gadget:Initialize, which possibly runs BEFORE your spawn-gadget's Initialize ==> your units won't work because they do not exist yet at that point.


[f=0000000] Loading gadget: Lua unit script framework <unit_script.lua>
...
[f=0000000] Loading unit script: scripts/tplegocar.lua
...
[f=0000000] Loaded gadget: Lua unit script framework <unit_script.lua>
[f=0000000] Loaded gadget: Spring Tanks | Start Point Remover Gadget <init_start_point_remover_gadget.lua>

[f=0000000] Loaded gadget: base spawner <tp_startbase_spawn.lua>

~0006835

user744

in my spawn gadget i changed
layer = 0,
to
layer = 9000,
which fixed it.

~0006838

FLOZi (reporter)

Unit script gadget is also layer 0 (they are loaded alphabetically within layers) so layer 1 is sufficient ;)

~0006840

Kloot (developer)

goodgood

~0006845

user744

the example gadget
https://github.com/spring/spring/blob/master/cont/base/springcontent/LuaGadgets/Gadgets/game_spawn.lua
is layer=0, too.
It probally still works because it uses function gadget:GameStart() but maybe it should still be changed to something "higher" that unit_script, ie layer=1

~0007713

Kloot (developer)

as before: change the layer in which your gadget(s) live(s) to a number > 0, there is not much else we can do
+Notes

-Issue History
Date Modified Username Field Change
2011-06-29 17:55 user744 New Issue
2011-06-29 17:55 user744 Graphics Card => unknown
2011-06-30 02:16 user744 Note Added: 0006830
2011-06-30 02:21 abma Summary unit scripts does not work on startunits, works on units created later => (master) unit scripts does not work on startunits, works on units created later
2011-06-30 13:10 Kloot Note Added: 0006831
2011-06-30 13:11 Kloot Note Edited: 0006831
2011-06-30 13:13 Kloot Note Edited: 0006831
2011-07-01 01:55 user744 Note Added: 0006835
2011-07-01 18:21 FLOZi Note Added: 0006838
2011-07-01 22:03 Kloot Note Added: 0006840
2011-07-01 22:03 Kloot Status new => resolved
2011-07-01 22:03 Kloot Resolution open => no change required
2011-07-01 22:03 Kloot Assigned To => Kloot
2011-07-02 05:57 user744 Note Added: 0006845
2011-07-02 05:57 user744 Status resolved => assigned
2011-07-02 05:57 user744 Resolution no change required => reopened
2011-11-25 17:38 abma Relationship added related to 0002769
2011-11-26 16:09 Kloot Note Added: 0007713
2011-11-26 16:09 Kloot Status assigned => closed
2011-11-26 16:09 Kloot Resolution reopened => no change required
+Issue History