Sidedata.lua: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
Maddox (talk | contribs)
m Typo fixed - sitedata.lua => sidedata.lua
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Location==
==Location==
<code>sitedata.lua</code> is a file in the <code>Gamedata/</code> directory of a Spring Game.
<code>sidedata.lua</code> is a file in the <code>Gamedata/</code> directory of a Spring Game.
It defines the playable factions/races/sides in a game. (ie ARM & CORE, Terran, Protoss, USA, Bananas,...)
 
==Purpose==
This file defines the playable factions/races/sides in a game. (ie ARM & CORE, Terran, Protoss, USA, Bananas,...)


==Source==
==Source==
The engine source code which parses the data from this file is viewable here: https://github.com/spring/spring/blob/master/rts/Sim/Misc/SideParser.cpp
The engine source code which parses the data from this file is viewable here:  
 
* {{sourcelink|file=rts/Sim/Misc/SideParser.cpp}}


==Details==
==Details==
Line 11: Line 15:
*<code>startUnit</code> (must be read by [http://springrts.com/phpbb/viewtopic.php?f=67&t=21883&p=417021 a gadget to actually spawn the start unit])<br>
*<code>startUnit</code> (must be read by [http://springrts.com/phpbb/viewtopic.php?f=67&t=21883&p=417021 a gadget to actually spawn the start unit])<br>


These values are available to lua via <code>Spring.GetSideData</code>:
These values are available to lua via <code>Spring.GetSideData</code> (See [[Lua_SyncedRead#Sides.2FFactions|Lua_SyncedRead]]):
<code><pre>local sideName, startUnit = Spring.GetSideData(sideID)</pre></code>
<code><pre>local sideName, startUnit = Spring.GetSideData(sideID)</pre></code>


Line 17: Line 21:
===Single Faction===
===Single Faction===
<code><pre>local sideData = {
<code><pre>local sideData = {
{
  {
name = 'AwesomeDudes',
    name = 'AwesomeDudes',
startunit = 'awesomedudebase',
    startunit = 'awesomedudebase',
},
  },
}
}
return sideData
return sideData
Line 26: Line 30:
===Multiple Factions===
===Multiple Factions===
<code><pre>local sideData = {
<code><pre>local sideData = {
{
  {
name = 'NKG',
    name = 'NKG',
startunit = 'bflagship2',
    startunit = 'bflagship2',
},
  },
{
  {
name = 'Drone',
    name = 'Drone',
startunit = 'kdroneengineer',
    startunit = 'kdroneengineer',
},
  },
  ...
}
}
return sideData
return sideData
Line 47: Line 52:
<code>AwesomeDudes.bmp NKG.bmp Drone.bmp</code>
<code>AwesomeDudes.bmp NKG.bmp Drone.bmp</code>


[[Category:Game development]]
[[Category:gamedata]]
[[Category:gamedata]]

Latest revision as of 01:07, 2 November 2021

Location

sidedata.lua is a file in the Gamedata/ directory of a Spring Game.

Purpose

This file defines the playable factions/races/sides in a game. (ie ARM & CORE, Terran, Protoss, USA, Bananas,...)

Source

The engine source code which parses the data from this file is viewable here:

Details

Each faction can have two properties:

These values are available to lua via Spring.GetSideData (See Lua_SyncedRead):

local sideName, startUnit = Spring.GetSideData(sideID)

Example

Single Faction

local sideData = {
  {
    name = 'AwesomeDudes',
    startunit = 'awesomedudebase',
  },
}
return sideData

Multiple Factions

local sideData = {
  {
    name = 'NKG',
    startunit = 'bflagship2',
  },
  {
    name = 'Drone',
    startunit = 'kdroneengineer',
  },
  ...
}
return sideData

Faction Icons

Faction icons are not defined in this file but just read from the Sidepics/ directory.

(NB: Some widgets, such as advanced playerlist, may complain about missing faction icon if they are not present)

Can be .bmp and maybe other formats. Filename is same as Faction name ie for above examples: AwesomeDudes.bmp NKG.bmp Drone.bmp