HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

help newb developer

04-21-2003, 02:10 AM#1
SektorGaza
I am working on a map, my DnD map and even though I just begun I already have tons of problems.

Wondering if you could help me.

First of all I have big problems with Chat input..
how do you store an integer from user entered char into an array?

ive tried a lot of things... just dont know

well that's the first problem and the biggest problem because I dont like to go on until I solved one thing.


My map will be great hopefully, but I also need a good terrainer, cause I suck and dont have patience, but anyway, if you could help me with chat input stuff or refer me to tutorials that would be great.
04-21-2003, 03:44 AM#2
MrDoomMaster
well that all depends on how the user enters the number.

Heres an example:

Lets say a player has to type the following to execute the trigger:

"gold xx"

xx would be any number 1-99. Here is what the trigger would look like:

Events:
Player X enters the chat string of (gold ) as a substring

Conditions:
String Comparison - substring((entered substring),6,7) greater than 0
String Comparison - substring((entered substring),6,7) less than 100

Actions:
Set ChatString = integer(substring((entered substring),6,7))


I don't have my WE open, so this may be a bit rusty. But hopefully you gain a basic idea of how to monitor substrings now. If you need more detail, i'll open WE later and create you an actual trigger that works.
04-21-2003, 01:08 PM#3
SektorGaza
yeah you right I dont know what you wrote :), plus I dont want
to use substrings,

something like this

user types "something"
after that it asks him to type a number
user types an integer
that integer is put into array.


thats all i need
04-21-2003, 04:01 PM#4
MrDoomMaster
Here is a map i've created for you that will display everything you need to know. Be sure to read the comments i have made for each trigger in this map, they give important information and notes on how the programming works. Enjoy!
04-21-2003, 06:28 PM#5
SektorGaza
I dont understand why you make it as a substring?

now i see why its <empty string> though, thanx for that..

I dont get it , how do some of you know so much?is there a manual for it?
04-21-2003, 07:14 PM#6
SektorGaza
cool it actually works, thanx
04-21-2003, 07:41 PM#7
MrDoomMaster
A substring is simply a specifc part of a string.

In the substring argument, you have 3 options to fill in:

Substring(String,Min,Max)

The first one, String, is asking what string it is to look at for specific parts. Since you want to check the string that players enter as a chat message, you would put (entered chat string) in this argument. Now onto the second and third options.

The second and third options, Min and Max, specify what part of that string is supposed to be evaluated. For example, lets say a player enters the following chat string:

Hello Everybody!

if you had Min set to 7, and Max set to 11, then this is the only part of that chat string that passes through the condition and onto the actions:

Every


Min and Max is the same thing as telling JASS to check letters 6 - 11 of the specified string. This also includes spaces.

Here is a breakdown of the "Hello Everybody!" chat string:

H = 1
e = 2
l = 3
l = 4
o = 5
(space) = 6
E = 7
v = 8
e = 9
r = 10
y = 11
b = 12
o = 13
d = 14
y = 15
! = 16

This means, the string "Hello Everybody!" has a total of 16 characters in it. use the Min and Max arguments to set only certain parts of the entered chat string to a variable, or to only run the actions of that trigger on that specific substring.


If this is still a bit hard to grasp, i'll give a more realistic example. You've played Ark Defense right? As you know, in that map, players have the ability to transfer gold to other players using the substring functions. This is how it is done:

A player must type this to send gold:

give yy xx gold (at least i think this is it, i don't remember)

xx = number of gold
yy = player that gets the gold


Event:
Player X enters "give " as a SUBSTRING (this means the trigger will be evaluated no matter what, just as long as "give " can be found in the entered chat string)

Conditions:
Integer Comparison - Integer(Substring((entered chat string),6,7) greater than 0
Integer Comparison - Integer(Substring((entered chat string),6,7) less than 100
Integer Comparison - Integer(Substring((entered chat string),9,10) greater than 0
Integer Comparison - Integer(Substring((entered chat string),9,10) less than 13
String Comparison - Substring((entered chat string),11,15) equal to " gold"

Actions:
(no need to display the actions)



All of the conditions, as you can see, make sure that characters 6-7 of the entered chat string are a number 1-99, and characters 9-10 are a number 1-12 to represent the player number of a player, and the final condition makes sure that the string " gold", with a SPACE before it, is entered after the player number. Keep in mind, that if not all of these conditions are TRUE, then the actions are not executed.

I hope this helps, there's really no other way i can explain it. It was tough for me to grasp when i was starting out, but through experience i got the hang of it pretty well.

And the only reason we know so much is because we put time and effort into our work. All JASS programmers, whether they program by using the script or GUI, all have great skill and have earned it through ASKING QUESTIONS and EXPERIENCE. If you want to learn how to program as well as anyone in this forum, you must devote yourself to JASS and actually WANT to learn it.

I hope i've helped. Good luck with your map, i'd like to see it when you're finished. Just click the link in my signature to email me the map whenever it's done! Thanks!
04-21-2003, 07:56 PM#8
SektorGaza
cool

lol ,now I have a very similar question but this time its about string..

i want the user to input a string and I want to manipulate that string the way i want.

its not the same way as integer cause i tried <empty string> as a substring

so how to do that?
04-21-2003, 08:13 PM#9
MrDoomMaster
Same as the integer trigger, except this time just delete the condition.

Events:
Player X enters <empty string> as a substring

Conditions:
-none-

Actions:
Set EnteredString = (entered chat string)


Simple as that!