Page 1 of 1

problems with if researchFinished

Posted: 22 Dec 2011, 16:53
by Mysteryem
Since there is no easy way for one research topic to remove another one after it has been researched, I've tried to do it via a script where the actual research topic doesn't actually enable any other research upon completion. Instead, if it is researched, the script will make the research topics available and research the other research topic at the same time (thus removing the unneeded one from the research menu). No matter what I've tried with researchFinished so far, it has always given me an error: (top line of my script is line 100)

Code: Select all

info    |02:36:30: [loadPlayerScript] Syntax error in multiplay/skirmish/rules.js line 100: Expected `;', `)'

Code: Select all

		if ((researchFinished(RESEARCH "Tech-Enabler-F1", me)) and (not researchFinished(RESEARCH "Tech-Enabler-F2", me)))
		{
			enableResearch("F1R-Sys-Sensor-Turret01", playnum);
			enableResearch("F1R-Wpn-MG1Mk1", playnum);
			enableResearch("F1R-Sys-Engineering01", playnum);
			completeResearch("Tech-Enabler-F2", playnum);
			enableStructure("F1ResearchFacility", playnum);
			}
		else if ((researchFinished(RESEARCH "Tech-Enabler-F2", me)) and (not researchFinished(RESEARCH "Tech-Enabler-F1", me)))
		{
			enableResearch("F2R-Sys-Sensor-Turret01", playnum);
			enableResearch("F2R-Wpn-MG1Mk1", playnum);
			enableResearch("F2R-Sys-Engineering01", playnum);
			completeResearch("Tech-Enabler-F1", playnum);
			enableStructure("F2ResearchFacility", playnum);
			}
I've tried looking at Nexus.slo

Code: Select all

while(_result < techCount[_techTree])
	{
		if((not researchFinished(tech[_techTree][_result], me)) and (not researchStarted(tech[_techTree][_result], me)))
		{
			return _result;		//found research
		}
		_result++;
	}
where it corresponds to a technology in Nexus.vlo, e.g.:

Code: Select all

tech[1][0]		RESEARCHSTAT		"R-Struc-VTOLFactory"
This is my second time delving into the scripting, so apologies if it's some rookie mistake. :P

Re: problems with if researchFinished

Posted: 22 Dec 2011, 19:20
by Per
You cannot just declare a variable in the actual function call like that. You need to declare the tech in the VLO, then use that variable to pass to researchFinished().

Re: problems with if researchFinished

Posted: 23 Dec 2011, 14:36
by Mysteryem
Alright, got it working. Sort of works in multiplayer too, everybody else picks their research first, then the host does. Thanks for the help, some of NoQ's scripts were also very useful to compare to too.