Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

problem to create a counter [help for map]

Share questions and tutorials related to the map editor. Share you maps in the Superfighters Deluxe Custom Maps section.
Forum rules
By using the forum you agree to the following rules.
Post Reply
Classic Fighter
Meatbag
Posts: 4
Joined: Wed May 01, 2019 9:25 am
Title: My name is frog
SFD Account: Classic Fighter
SFD Alias: froagialias
Gender:
Age: 19

problem to create a counter [help for map]

Post by Classic Fighter » Mon Jul 01, 2019 5:45 pm

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.
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1682
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 29

Post by Gurt » Mon Jul 01, 2019 8:01 pm

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();
		}
	}
}
0 x
Gurt

User avatar
hyper copter
Superfighter
Superfighter
Posts: 116
Joined: Thu Aug 31, 2017 11:38 am
Title: Leave my profile alone.
SFD Account: Hyper
SFD Alias: Hyper
Gender:
Age: 13

Post by hyper copter » Tue Jul 02, 2019 3:10 pm

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.
0 x
''The great thing about multitasking is that several things can go wrong at once."
- Andrew B. Sweger.

Classic Fighter
Meatbag
Posts: 4
Joined: Wed May 01, 2019 9:25 am
Title: My name is frog
SFD Account: Classic Fighter
SFD Alias: froagialias
Gender:
Age: 19

Post by Classic Fighter » Tue Jul 02, 2019 10:21 pm

forget it, I already solved the problem by putting together triggers in an ingenious way, anyway thanks for the help
0 x

Post Reply