• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] Chat strings

Status
Not open for further replies.
Level 29
Joined
Jul 29, 2007
Messages
5,174
I want to make this system that when a player types for example "-Set Red X" (x = a number beetwin 0-255) it will change his units red color to the X.

I could make this with like 20 triggers but I guess thats not worth it now is it ? :xxd:

So how do I make an action that will know that if the player said "-Set"
and then after that for example "Red 200", it will know the whole string was "-Set Red 200".

Thanks in advance.
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
That is a bit hard, as it requires a lot of substrings, I don't know if you'll understand, but here it goes:

[TRIGGER=This is the trigger I made]Tint Command
Events
Player - Player 1 (Red) types a chat message containing -set as A substring
Player - Player 2 (Blue) types a chat message containing -set as A substring
Player - Player 3 (Teal) types a chat message containing -set as A substring
Player - Player 4 (Purple) types a chat message containing -set as A substring
Conditions
(Substring((Entered chat string), 1, 4)) Equal to -set
Actions
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units in (Playable map area) owned by (Player((Integer((Substring((Entered chat string), 6, 6))))))) and do (Animation - Change (Picked unit)'s vertex coloring to ((Real((Substring((Entered chat string), 8, 10))))%, (Real((Substring((Entered chat string), 11, 13))))%, (Real((Substring((Entered chat string), 14, 16))))%) with 0.00% transparency)
[/TRIGGER]

The condition is a String Comparison.
To get to the first part of the action...
Pick every unit in (Playable Map Area) owned by
Conversion - Convert Player Index to Player
> Conversion - Convert String to Integer
> Substring​

The color codes: Convert String to Real > Substring.
Sorry for the hard explanation, maybe someone can find an easier way.


Happy mapping.:thumbs_up:
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Don't bother with the actions, only need the condition.

What does the 1,4 mean ?

[Edit] Ok in a second thought, what are ALL those x , x numbers ?

[(Edit)x(2)] Ok I think I got it so ill try to make it for my own trigger, Thanks.

[(Edit)x(3)] Where do I find those numbers ? (which as I understood mean the number of letter in the string).

[(Edit)x(4)] Ok found it, I think I need new glasses x.X

[(Edit)x(5)] Ok, I made this trigger
  • Chat String Colors
    • Events
      • Player - Player 1 (Red) types a chat message containing Set as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to Set
    • Actions
      • Animation - Change Unit_1 vertex coloring to ((Real((Substring((Entered chat string), 5, 7))))%, (Real((Substring((Entered chat string), 9, 11))))%, (Real((Substring((Entered chat string), 13, 15))))%) with 0.00% transparency

And then typed "Set 100 100 100" and it did nothing.

Spot any problem ? x.X
 
Last edited:

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
Lol lots of edits there.

Well, does anything happen at all? If not...
  • Are you sure you are player 1 (Red)?
  • Does "Unit_1" refer to the unit you are trying to change color?
If all of those are correct, then I don't see what the problem is.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Im automaticly player 1 since I did Test in WE and Unit_1 is a variable which I set in 0.01 sec of game

[(Edit)x(24)/(4)](thats 6...) I changed the unit to be a unit on the map instead of a variable but it didn't help, didn't really have any reason to help lol.
No idea why it aint working ? :(

And a aditional question,
How do I move a unit to a similiar x,y coordinates in another region (I have a left region and a right region, and want a unit to move instantly to the same coordinates but on the oposite region).
Since I don't know I made it like this
  • Then - Actions
    • Set Real = ((Width of Region <gen>) + 20.00)
    • Unit - Move (Triggering unit) instantly to (Point offset by Real towards 0.00 degrees))
(Point is a point variable set beforehand)

But its really not accurate and if I want it to be, ill need to text like 100 times in a row lol.
(By the way, if you are asking yourself why +20 , its because there is a space beetwin the regions)
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
Here this code should do the trick.
  • RealtiveMov
    • Events
      • Player - Player 1 (Red) types a chat message containing move as An exact match
    • Conditions
    • Actions
      • Set Temp_Real_Array[0] = ((X of Unit_To_Move) - (Min X of Rect 000 <gen>))
      • Set Temp_Real_Array[1] = ((Y of Unit_To_Move) - (Min Y of Rect 000 <gen>))
      • Set Temp_Real_Array[2] = ((Min X of Rect 001 <gen>) + Temp_Real_Array[0])
      • Set Temp_Real_Array[3] = ((Min Y of Rect 001 <gen>) + Temp_Real_Array[1])
      • Set Temp_Point = (Point(Temp_Real_Array[2], Temp_Real_Array[3]))
      • Unit - Move Unit_To_Move instantly to Temp_Point
      • Point - Remove Temp_Point
I use 4 variables so it doesn't look so complex. The first 2 determine the units position relative to the rect. The second 2 move the point to the same position relative to the second rect. Then I generate the point, move the unit and clean up the point.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Uhhh. It worked for me. Obviously you need to practice your trigger copying skillz.

If your in the top square of grass type move. If your in the bottom type moveb.
You'll always move to the exact location relative to the other square.
 

Attachments

  • MoveRelativeToLoc.w3m
    13.6 KB · Views: 45
Level 29
Joined
Jul 29, 2007
Messages
5,174
Critical Error, couldn't find GetUnitX in data base. lol

And by the way you used custom scripts ? I made X of location which was the location of triggering unit (and as you can see in my previous comments it isn't a type command its a spell so don't tell me there isn't a triggering unit ^^).
 
Level 11
Joined
Aug 25, 2006
Messages
971
Sorry I didn't know you didn't use WEU. Let me try and modify the map to use normal GUI. Brb Dangit, I don't have time to mod the map at the moment. Get WEU it adds a bunch of great native triggers to GUI. It also adds Advanced triggers but don't use those, they leak. G2g.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Suit yourself. I personally have made many hundreds of games with it and have never had a single corruption. Of course there are several people who report map corruption, so I guess it depends on your computer.

Without WEU I heavily suggest you switch to pure/semi JASS, otherwise wonderful natives like GetUnitX won't be available to you, and you'll be stuck using weird roundabout methods.

Also unless you use a few lines of custom script you wont be able to solve leaks with normal WE. Post the map, and I'll open it in a normal editor to see what you did wrong. (If you switch to JASS get Jass New Gen pack)

For your benifit I completed it without the use of any WEU actions. I tested it already. (It works in normal WE)
  • RealtiveMovb
    • Events
      • Player - Player 1 (Red) types a chat message containing moveb as An exact match
    • Conditions
    • Actions
      • Set Temp_Point = (Position of Unit_To_Move)
      • Set Temp_Real_Array[0] = ((X of Temp_Point) - (Min X of Rect 001 <gen>))
      • Set Temp_Real_Array[1] = ((Y of Temp_Point) - (Min Y of Rect 001 <gen>))
      • Set Temp_Real_Array[2] = ((Min X of Rect 000 <gen>) + Temp_Real_Array[0])
      • Set Temp_Real_Array[3] = ((Min Y of Rect 000 <gen>) + Temp_Real_Array[1])
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Set Temp_Point = (Point(Temp_Real_Array[2], Temp_Real_Array[3]))
      • Unit - Move Unit_To_Move instantly to Temp_Point
      • Custom script: call RemoveLocation(udg_Temp_Point)
Notice the annoying method of getting the X and Y of the point.
Notice the two necessary (unless you want leaks) lines of custom script, where there was GUI before.
And heres the map containing it...
In the map first type move, to move from the first to the second rect (Relative) then type moveb to move from the second to the first rect (Relative)
 

Attachments

  • MoveRelativeToLoc.w3x
    13.8 KB · Views: 51
Level 29
Joined
Jul 29, 2007
Messages
5,174
(Sorry in advance for double post lol)

The chat string weird problem was solved by [Me] (lol), for some reason I made exacly the same thing but with loops like the trigger below and it worked perfectly.

I put this for those who want to do string-based actions and get weird problems.

  • Chat String Colors
    • Events
      • Player - Player 1 (Red) types a chat message containing Set as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 3)) Equal to Set
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 5, 10)) Equal to random
        • Then - Actions
          • Animation - Change Your_Unit's vertex coloring to ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%) with 0.00% transparency
        • Else - Actions
          • For each (Integer A) from 1 to 12, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring((Entered chat string), 5, 5)) Equal to (String((Integer A)))
                • Then - Actions
                  • Animation - Change Your_Unit's vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Unit - Change color of Your_Unit to (Color of (Player((Integer A))))
                • Else - Actions

The first If/Then/Else is for a random color.
The loop is for normal player colors, I reseted the units color to 100%/100%/100% because it messes up each other if you don't reset it.


[Notice] Ghostwolf has just raised his intelligence by 1 ! Current intelligence - 5 !
Congratulations Ghostwolf !
(lol... on the top of this thread I didn't even know whats a substring, now I know pretty good I think :) )
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Oh I see, that was pretty dum of me as usuall.
Actauly untill about 10 minutes ago I didn't notice its in % (yes... I defiantly need new glasses :xxd:) and not 0-255 like units colors in the Object Editor :wink:

There's the reason why I get bad marks in math ! I know everything (or almost everything) but I just do those StUpId mistakes for no reason :p
 
Status
Not open for further replies.
Top