Page 1 of 1

COB script -- global, team, and allyteam variables

Posted: 07 Nov 2007, 02:38
by trepan
http://spring.clan-sy.com/fisheye/chang ... g/?cs=4732

Code: Select all

4732 created by trepan on 07 November 2007, 02:31:35 +0100 (5 minutes ago) (patch) 

* Added global, team, and ally GET/SET variables to COB scripts
   1024 - 2047:  1024 global variables
   2048 - 2175:  128  variables per team      (the COB script unit's team)
   2176 - 2303:  128  variables per allyteam  (the COB script unit's allyteam) 

Posted: 07 Nov 2007, 08:25
by Archangel of Death
Ooo, more COB toys. Which of course can be readily accesed via LuaCob and/or LuaRules? Not that I was hit by an immediately apparent way I could use it in BTech this time.

Posted: 07 Nov 2007, 09:29
by Pressure Line
Archangel of Death wrote:Not that I was hit by an immediately apparent way I could use it in BTech this time.
'Hero' units that can only be built once during the game and only by one player...

Posted: 07 Nov 2007, 15:36
by trepan
LuaCob and LuaRules can use Spring.GetUnitCOBValue() and
Spring.SetUnitCOBValue() to access any COB GET/SET values,
for any unit.

Pressure Line
Your hero unit limiter would be better done with LuaRules.

Posted: 07 Nov 2007, 15:37
by rattle
Not without further Lua.

Posted: 07 Nov 2007, 15:42
by tombom
rattle wrote:Not without further Lua.
What does this mean? It's pretty simple in Lua actually.

Posted: 07 Nov 2007, 21:23
by KDR_11k
Unit variables would have been more useful but still nice.

Posted: 07 Nov 2007, 21:24
by trepan
Unit variables instead of script static vars?

Posted: 07 Nov 2007, 21:30
by FLOZi
I think he means a variable accesable by all units of a given type.

Posted: 07 Nov 2007, 21:41
by trepan
Ah, I had mentionned that in #moddev, but didn't get much of a response.
It's easy enough to setup.

Posted: 07 Nov 2007, 22:57
by trepan
It turns out that KDR actually wants per-unit variables (not per-unitDef),
so that he can pass information between units. To that end, I'm adding
8 per-unit variables, with the ability to get and set variables for other units.

The new layout is as follows:

Code: Select all

  // SIZES
  static const int UNIT_VAR_COUNT   = 8;
  static const int TEAM_VAR_COUNT   = 64; 
  static const int ALLY_VAR_COUNT   = 64;   
  static const int GLOBAL_VAR_COUNT = 1024;

  // CODES
  static const int UNIT_VAR_START   = 1024;
  static const int TEAM_VAR_START   = 2048;
  static const int ALLY_VAR_START   = 3072;
  static const int GLOBAL_VAR_START = 4096;

Posted: 07 Nov 2007, 23:24
by imbaczek
I can't see how per-unit vars are different from static vars...?

Edit: missed 'setting from other units bit' 8)

Posted: 07 Nov 2007, 23:27
by rattle
You can't read static-vars in one script from another script. You could use the globals for that but it's confusing.