• 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!

Chat commands, converting words and numbers into parts of a trigger.

Status
Not open for further replies.
Level 5
Joined
Oct 7, 2005
Messages
102
Can anyone here help me figure out how to make a trigger that will, for example, let a player raise or lower land by the specified amount. So say a player said "raise land 300 100"
(the first number being the size and the second being the depth). The trigger would do just that.

Hopfully that makes sense, and I would prefer that you found a normal trigger compared to JASS please. But if you really believe it's impossible with a normal trigger then I'll settle for JASS.
 
Level 3
Joined
Apr 11, 2010
Messages
35
I don't know how to do the actual raising of the land, but generally, you can use parts of chat messages entered by using the function of string (Substring(Entered chat string, X, Y) and covert them into integers or reals or whatever by using the Conversion function.

I've created a sample map, it is more clear when shown with the actual triggers, and writing it here would be difficult and difficult to understand.
Download it, open it, read the comments inside and observe the functions :)
 

Attachments

  • testSubstring.w3x
    14.6 KB · Views: 97
Level 5
Joined
Oct 7, 2005
Messages
102
Thanks very much! I'll try it out.

Edit:

That is very helpful mate, I also wandering if you know how to make it so for example I wanted to create 3 footman by typing in chat "Footman 3". How would I select in the trigger the word before the integer? Note that the word is going to vary in size because I'll be spawning different units.

Thanks a lot.
 
Level 3
Joined
Apr 11, 2010
Messages
35
I was trying to do the creation script in the past but I gave up, so thanks to you I tried harder and made it :)
It consists of two(well, three) triggers, I think it could be done easier but I don't see a way to do it easier now. Look at the folder "unit creation" and you can test it in-game

Vulcano, that wouldn't work, because when you have a unit type with different length(e.g. Sorceress), then the integer would not be on that spot and the trigger won't work. That's why my trigger consists of two triggers - on for the type, other for the quantity.
Download and try it :)
 

Attachments

  • testSubstring.w3x
    17.2 KB · Views: 85
Level 5
Joined
Oct 7, 2005
Messages
102
Oh nice one Davefin, I'll try it out.

Edit:

Okay, I tested it. In my game only the first trigger works when I type -u (unit type). But when I type -(number), nothing happens...?
 
Last edited:
Level 3
Joined
Apr 11, 2010
Messages
35
Ripper, you need to paste all the triggers PLUS the variables used in it, otherwise the first trigger can't save the unit-type and the second trigger can't load it and use it...
I suggest turning on "auto create variables when pasting triggers" option in the word editor preferences, it makes pasting triggers easier.

You can try Purges stringFind, I am afraid to start with Jass :D
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Here's how you find the space that divides the integer from the name of the caster:

First you create an integer variable. We'll call it i. Set both to 1 if you're using GUI, 0 and 1 if you're doing the non BJ in JASS/Custom Script.

Now, create a loop. Inside that loop set i and i to go up by 1. The loop should stop when i gets too big (Say greater than the StringLength) or when the SubString of i, i is " ", or a simple space. This will find the first space dividing the Footman from the space. Now, everything from 1 to i-1, i-1 will be the unit. Everything after i+1, i+1 to the StringLength will be the number amount.

I hope that made some sense. I'll show you how it works in JASS, but I'm afraid I dislike GUI too much to work in it. Still it's completely possible in GUI.

JASS:
        set i1 = 1
        set i2 = 2
        loop
            exitwhen i2 > StringLength(str) or SubString(str, i2-1, i2) == " "
            set i2 = i2 + 1
        endloop

After this loop runs it's course you just save the substring between 1 and i-1 as the UnitName of the string and i+1 to the StringLength as the integer.

I hope I helped :D This is part of the Roleplay map I am working on. It's similar to SotDRP but closer to QuatreDan in style.
 
Level 3
Joined
Apr 11, 2010
Messages
35
Titanhex, does it work even when the unit-type has space inside? (for example Druid of the Talon)?
 
Status
Not open for further replies.
Top