Page 1 of 1

Rules js Modification

Posted: 31 Aug 2018, 21:19
by WZ2100ModsFAn
I was modifying the rules to use const instead of the seperate enablestructures

here it is

Code: Select all


		enableStructure(START_STRUCTURES, playnum);		// make structures available to build
is there a mistake i made in the const part?

seperate one i also made

Code: Select all

		const RESEARCH_START = [

		enableResearch(RESEARCH_START, playnum);		// enable clean tech research

Re: Rules js Modification

Posted: 01 Sep 2018, 21:00
by Berserk Cyborg
What you want is to access each element of that array and pass it to enableStructure(). This can be done in a for loop by making use of the length property of an array, which returns how many elements are in that array.

Code: Select all

for (var i = 0; i < START_STRUCTURES.length; ++i)
    var stat = START_STRUCTURES[i];
    enableStructure(stat, player);
Alternatively, you could make use of the forEach method for such a simple task:

Code: Select all

START_STRUCTURES.forEach(function(stat) { enableStructure(stat, player); });

Re: Rules js Modification

Posted: 02 Sep 2018, 01:23
by WZ2100ModsFAn
I chose the top one.

Now to try it out.

I double posted again *facepalm* :oops:

and it this time it happened when i simply just hit submit once.


Now i realize the top one replacing it didn't work.

hmm perhaps i made a mistake? checking to find out.

now it finally doesn't work.

here's the logs.

Code: Select all

--- Starting log [C:\Users\WZ2100ModsFan\Desktop\Warzone 2100 Portable-master\Warzone 2100 master\logs\WZlog-0902_074620.txt]---
error   |07:46:29: [callFunction:243] 0 : eventGameInit() at multiplay/skirmish/rules.js:209
error   |07:46:29: [callFunction:243] 1 : <global>() at -1
info    |07:46:29: [callFunction:246] Uncaught exception calling function "eventGameInit" at line 209: ReferenceError: Can't find variable: player
info    |07:46:29: [callFunction:246] Assert in Warzone: c:\projects\warzone2100\src\qtscript.cpp:246 (false), last script event: '<none>'
nope apparently not. fixing player with playnum.

now it works flawlessly now to start playing 8)