Page 1 of 1

problem to create a counter [help for map]

Posted: Mon Jul 01, 2019 5:45 pm
by Classic Fighter
I would like to know how to develop an accountant.

Example: when an activator is activated, the number 1 will be shown in (some part of the map without covering a lot of space), if it is activated again, the number 2 is displayed, if it is activated again, the number 3 is displayed and then It is activated until you reach number 15 fifteen.

Re: problem to create a counter [help for map]

Posted: Mon Jul 01, 2019 8:01 pm
by Gurt
For your trigger that shall increase the counter you need to call a custom Script Method.
Mark your trigger responsible for increasing your counter and the Script Method property and type in a name of the function you want to call, for example "IncreaseCounter".

In the map script create a public method with the name "IncreaseCounter" with the correct signature and increase your custom counter. For each time it increases update a Text marker by a custom ID and check if you have reached 15.

Code: Select all

int myCounter = 0;
public void IncreaseCounter(TriggerArgs args) {
	myCounter += 1;
	
	// update text on an "IObjectText" tile (Text marker for example) named "MyTextCounter"
	IObjectText textObj = Game.GetSingleObjectByCustomID<IObjectText>("MyTextCounter");
	if (textObj != null) {
		textObj.SetText(myCounter.ToString());
	}
	
	if (myCounter == 15) {
	    // Do whatever you want. For example, let's activate some known trigger by name "MyTriggerAt15."
		// counter reached 15. Let's activate a trigger by name "MyTriggerAt15"
		IObjectTrigger trigger = Game.GetSingleObjectByCustomID<IObjectTrigger>("MyTriggerAt15");
		if (trigger != null) {
			trigger.Trigger();
		}
	}
}

Re: problem to create a counter [help for map]

Posted: Tue Jul 02, 2019 3:10 pm
by hyper copter
I think it can be done with triggers. It'd just be very infuriating to do because you'dmaybeneed to place 15 duplicates in the exact same location.

Re: problem to create a counter [help for map]

Posted: Tue Jul 02, 2019 10:21 pm
by Classic Fighter
forget it, I already solved the problem by putting together triggers in an ingenious way, anyway thanks for the help