• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Variable Player Event

Status
Not open for further replies.
Level 1
Joined
Apr 28, 2018
Messages
2
Hello!

So as of now I am working on making my "rename" feature in my game a lot more efficient, but I'm not exactly sure how.

Currently I have:
Event:
-When Player1(Red) types -rename as a substring...
-When Player2(Blue) types -rename as a substring...
etc

What I'm looking for:
Event:
-When [Player] types -rename as a substring

Thank you for your help!
 
On map initialization, try declaring this loop.

  • For (Picked player) in (All Players), do (Actions)
    • Loop - (Actions)
      • Trigger - Add to <yourTrigger> the event: (Picked Player) types -rename as a substring.
That's the basic thing about it, and if you want it so that you can add only active players, just add a condition onto the loop Actions
 
Level 1
Joined
Apr 28, 2018
Messages
2
Ah okay, that makes sense. Seems strange they never added a player variable that can do this task to begin with...

Question is though, is it required to loop the action? and if so, why? Is it not sufficient to just add the events via Trigger in one instance?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
Seems strange they never added a player variable that can do this task to begin with...
Not strange at all seeing how variables have to have a value and a player variable can represent 1 player.

I do agree that it is strange that they did not assign a player constant to mean any player. StarCraft II did this so one can refer to all players with some events and actions, avoiding the need for a loop.
Question is though, is it required to loop the action?
Yes.
and if so, why?
So that it can create an event for the trigger for every player. Each event created is for a single player. So that events are created for every player the action is rerun using different unique players in a loop.
Is it not sufficient to just add the events via Trigger in one instance?
That would only create 1 event for 1 player. Basically your starting problem.
 
Status
Not open for further replies.
Top