HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Changing kills to win goal...how?

04-10-2007, 09:34 PM#1
Elhyse
I've been lingering on my trig editor for about 3 hours now and i still can't figure it out.

I want a trigger that would change my kills to win goal (currently 30) into something that a player would want.

Example :

they typed -kills 50

Then the trigger should change the kill goal(30) to 50.

But I just can't!

How am I gonna do this?
04-10-2007, 09:39 PM#2
akolyt0r
example:
Trigger:
killsgoal
Collapse Events
Player - Player 1 (red) types a chat message containing -kills as a part of the string*
Player - Player 2 (blue) ......
Conditions
Collapse Actions
Set YourIntegerVariable = (Integer((Substring((Entered chat string), 8, (Length of (Entered chat string))))))

*my editor displays that in german ..i translated it ...maybe wrong -.-
04-10-2007, 09:42 PM#3
Pyrogasm
Set the number of kills required to a variable, and just change it when a player types a message. Example:
Trigger:
Collapse Events
Player - A player types a chat message that contains -kills as (a substring)
Conditions
Collapse Actions
Set YOUR_KILLS_VARIABLE = (Integer(Substring((Entered Chat String) 7, (Length of (Entered chat string)))))
04-10-2007, 09:45 PM#4
Elhyse
say what? Some of it didn't make sense...
04-10-2007, 09:45 PM#5
Ammorth
Basically that, except make sure that kills is in the proper location:

Trigger:
Conditions
Substring((Entered Chat String), 1, 7 equals -kills ) <-- space at the end


So the entire script is

Trigger:
Kills
Collapse Events
Player - Player 1 (red) types a chat message that contains -kills as a substring
Collapse Conditions
Substring((Entered Chat String), 1, 7 equals -kills )
Collapse Actions
Set YOUR_KILLS_VARIABLE = (Integer(Substring((Entered Chat String) 7, (Length of (Entered chat string)))))
04-10-2007, 09:50 PM#6
Elhyse
But it has a value thingy on the end of the line?

Set Kills[(Integer((Substring((Entered chat string), 30, (Length of (Entered chat string))))))] = Value

What do i put? I don't even know if I did the script right...
04-10-2007, 09:53 PM#7
akolyt0r
you have not told us that your kills variable is an array ...what is supposed to be its index ?

(the value should be its current array index ...)


@Pyrogasm and Ammorth
Trigger:
kills
Collapse Actions
...Entered chat string), 8, (Length of (Entered...
is much cooler*
Hidden information:
why do you want to have the space in the substring ^^
04-10-2007, 09:53 PM#8
Elhyse
Array 12
04-10-2007, 10:04 PM#9
Pyrogasm
To be honest, you're not even close. Here's an explaination of the "substring" function:

It returns part of a string, so Substring((Darth Vader) 2, 4) would return "art", because "art" is what is from the 2nd to 4th character in "Darth Vader".

Likewise, Substring((-kills 65) 8, 9) would return the string "65". Now, we have to convert that to an integer to use as a kill count:
Integer(Substring((-kills 65) 8, 9)). Then we only have to set your killcount variable equal to that.

To make it work for whatever is typed after "-kills " (with the space, as Ammorth said), we'll have to modify which string is evaluated and what substring gets turned into an integer, because Integer(Substring((-kills 6585) 8, 9)) would still return 65.

Thus, we use the Length of (Entered Chat string) function, like so: Integer(Substring((Entered chat string) 8, (Length of (Entered Chat String))))
Note that the "8" doesn't change, since the start of the number is always the 8th character.

We'll also want to make sure that the new number isn't 0, so we'll add that in

Here's what your full trigger would look like:
Trigger:
Kills
Collapse Events
Player - Player 1 (red) types a chat message that contains -kills as a substring <NOTE THE EXTRA SPACE AFTER "-kills">
Collapse Conditions
Substring((Entered Chat String), 1, 7) equals -kills
Collapse Actions
Set TempInt = Integer(Substring((Entered chat string) 8, (Length of (Entered Chat String))))
If (TempInt not equal to 0) then (Set Set Kills[12] = TempInt) else do (Do nothing)

Quote:
why do you want to have the space in the substring ^^
It doesn't matter if it's in there or not. When the substring is converted to an integer, the space is irrelevant. It does ensure that the command will still work if someone forgets to type the space, though.
04-10-2007, 10:16 PM#10
Elhyse
Do i Make another variable? TempInt? Cuz when I use Kills I get that value at the end again...
04-10-2007, 10:24 PM#11
akolyt0r
Quote:
Originally Posted by Pyrogasm
Here's what your full trigger would look like:
Trigger:
Kills
Collapse Events
Player - Player 1 (red) types a chat message that contains -kills as a substring <NOTE THE EXTRA SPACE AFTER "-kills">
Collapse Conditions
Substring((Entered Chat String), 1, 7) equals -kills
Collapse Actions
Set TempInt = Integer(Substring((Entered chat string) 8, (Length of (Entered Chat String))))
If (TempInt not equal to 0) then (Set Set Kills[12] = TempInt) else do (Do nothing)

It doesn't matter if it's in there or not. When the substring is converted to an integer, the space is irrelevant. It does ensure that the command will still work if someone forgets to type the space, though.

i know that ...i could add irony tags in the future xD but i tought "^^" would express the irony quite well ^^

Nevertheless it will not "ensure that the command will still work if someone forgets to type the space" since we have
Code:
...that contains -kills  as a substring [b]<NOTE THE EXTRA SPACE AFTER "-kills">[/b]
and
Substring((Entered Chat String), 1, 7) equals "-kills "
:D
04-10-2007, 10:32 PM#12
Elhyse
So at the value i need to put -kills?

God it's only GUI and it hurts my head. Wonder how bad I'll fare in JASS...

Could someone pleaaase explain this to me in a transparently clear manner?

BTW: Nobody answered my Do i need to make a tempint variable question...
04-10-2007, 10:34 PM#13
akolyt0r
no u dont ..w8 a little i will give another example

EXAMPLE:

Trigger:
kills
Collapse Events
Player - Player 1 (Red) types a chat message containing -kills as a substring
Collapse Conditions
(Substring((Entered chat string), 1, 7)) equals -kills //<"-kills "
(Integer((Substring((Entered chat string), 8, (Length of (Entered chat string)))))) unequals 0
Collapse Actions
Set kills = (Integer((Substring((Entered chat string), 8, (Length of (Entered chat string))))))

pyrogasm obviously likes mass globals ;D
04-10-2007, 10:49 PM#14
Pyrogasm
The problem, akolyt0r, is: what if someone doesn't type a number after it?

If someone types "-kills OMGIMANUB", It will set "kills" equal to 0. That's what TempInt is for. If it's going to set the kills to 0, it catches it and doesnt.

Oh, and I know that by changing what the entered chat string is, it removes the "forgot the space" failsafe, but that was just an explaination :D


EDIT: Oh. Why didn't I think of putting it in the condition? ><
04-10-2007, 10:56 PM#15
akolyt0r
Yeah ...its a quite common mistake ^^