Current Side

Current Side

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

Moderator: Moderators

Post Reply
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Current Side

Post by kalda341 »

Does anyone know of a spring lua variable that would allow me to execute a command if you are playing as a certain faction?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Current Side

Post by zwzsg »

http://springrts.com/wiki/Lua_Scripting

Spring.GetTeamInfo 5th returned value.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Current Side

Post by CarRepairer »

Beware however, if you develop using an empty script with spring.exe, that value is nil (or empty string) so be sure that you account for that.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Current Side

Post by hoijui »

yeah true.. it is usually not a good idea to rely on that. as in spring, you can change faction during the game (capture or resurrect an enemy construction unit, loose your own construction units), you should rather rely on the current units in the team, if possible.
Last edited by hoijui on 13 Dec 2010, 16:59, edited 1 time in total.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Current Side

Post by knorke »

CarRepairer wrote:Beware however, if you develop using an empty script with spring.exe, that value is nil (or empty string) so be sure that you account for that.
omg i was wondering why it would not work.
wtfisthatshit.jpg
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Current Side

Post by knorke »

Code: Select all

	local localplayerID = Spring.GetLocalTeamID()
	local _,_,_,_,f = Spring.GetTeamInfo(localplayerID)
	local _,faction = Spring.GetSideData (f)
	Spring.Echo ("You are playing as faction:" .. faction)
Also attached the widget I talked about in the "Custom GUI" thread, it replaces "metal" with "wood" for Arm and with "gold" for Core.
Turns out it was all fine, Spring just fails to set faction when playing over spring.exe directly. So use a lobby.
To change the resource/faction names see
function widget:Initialize()
at the end of the file.
Attachments
tp_resdisplay_hack.lua
works in xta
(4.46 KiB) Downloaded 132 times
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Current Side

Post by kalda341 »

Thanks.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Current Side

Post by Forboding Angel »

get moar wood! hur hur :lol:
kalda341
Posts: 101
Joined: 19 Nov 2010, 09:44

Re: Current Side

Post by kalda341 »

?
User avatar
Pithikos
Posts: 146
Joined: 26 Dec 2008, 14:26

Re: Current Side

Post by Pithikos »

CarRepairer wrote:Beware however, if you develop using an empty script with spring.exe, that value is nil (or empty string) so be sure that you account for that.
What do you mean with an empty script? The configuration file?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Current Side

Post by FLOZi »

he means if you run spring.exe directly and not via a lobby.
Post Reply

Return to “Lua Scripts”