Warcraft III resources & community, 2003–2006 · archived

Variable Integer Problems

22 posts
#1

Variable Integer Problems

I am making a trigger on one of my maps so that a player must enter a chat string that equals an integer variable that is set in another trigger. However, on the "events" (player enters chat message), i put in "convert string to integer" but the integer that i have prepared does not show on the usable variable list. Am I doing something wrong? Can you not use integers in input chat strings? Do you need a different kind of variable for this? Or am i doing something completely obviously silly? ;) Help much appreciated.
Teifi
#2
this might just have been a typo but you said you were looking under "convert string to integer" and didn't see your integer variable...the explanation is that an integer won't show up when you're trying to convert a *string* to an *integer*...

now like i said, you may have just misspoken, but that's the only problem i can see from the information you gave. if you are trying to convert the entered chat string to an integer and store the value in your variable then i do not see why it isn't working.
#3
Oh yeah sorry mate, that was a typo indeed. Since its confusing to say it, then I shall say it in the context of the map:

A code is required to open a certain door, which can be input by a chat string. Since I do not want the code to be the same every game, I have set it to randomise it between 1 and 9999 at the start of the map.
I then want an event that is basically:

[When a player enters a chat string that is EQUAL to that integer], then do action etc.

However, when programming the event for chat string, I cant seem to find anywhere to be able to input that feature.

(EDIT) Another way of saying it is that the variable doesnt show when im trying to check that a chat string is the same as an integer. (/EDIT)
#4
*Ping* Help still required
#5
Im starting to wonder wether its actually possible ;)
#6
I don't have wc3 on this computer but I'll try to explain with what I can remember.

Trigger [Int]
Event
Map Int
Actions
RndCode = Math(RandomNumber 1,9999)
End Trigger

Trigger [TypeCode]
Event
Player[1] Types in chat
Condition
Convert Str to Int(EnteredChatString) = RndCode
Actions
-Enter Actions-
End Trigger

I hope that helps...

- Azalgath
#7
Very useful mate, thank you, but theres just one problem.

In the event, player[1] types in "chat". What do i put for the "chat" part? How do i make an event that is triggered when the player types in anything?
Its that event part im stuck on.
#8
GUI is dumb, and wont let you use variables in events

make an event on the trigger that is Elapsed Game Time is 0.01 seconds

then, make THESE actions

Player Group - Pick Every Player in *the players that can type the message* and do multiple actions
Loop-Actions
Custom Script: call TriggerRegisterPlayerChatEvent( GetTriggeringTrigger(), GetEnumPlayer(), GetRandomInt( 1, 9999 ), true )
#9
Ok sorry to be a bother - one more thing. For the custom script (which ive never used before)...

I just copy/pasted it. Is there anything i need to replace?

eg. where do i input the variables/triggers etc in that code?
#10
oops...

ignore that old post, made a few mistakes cuz i had to go to class in about a min

jsut

for the action, if you just want a random integer between 1 and 9999, just make the event be

A Player Types a Chat Message Containing( Convert Integer to String( Math-random integer number between 1 and 9999 ) ) ) as an Exact Match

there was a func i forgot to add to the custom script line, and anyways the function would massively leak, cuz i forgot a few other lines =/

the reason that GUI does not allow you to assign variables to events is this - events are set in stone when they are initialized. They cannot be changed, so if Your Variable was equal to "bob" when the event line was called, it would always equal "bob", even if you changed it to "cheese"
#11
Based on what you said, this is what I have and it doesnt work:

[Let "Code" be the integer variable]

Event
Player types chat message containing (Convert Integer to String(Math -random integer number between 1000 and 9999)) as an exact match.

Condition
(Entered chat string) is equal to (Code)

Action
Open Door

However it doesnt work, and Im still not 100% sure of what you meant in your last post.
#12
Help still required :(
#13
oh, yeah, forgot about that, just, make the trigger, convert it to custom text and ill JASS it with the code variable.
#14
Im really sorry mate to keep going on like this, but what do you mean "convert it to custom text"?

/me is a mediocre mapper who doesnt use JASS or any coding or anything.
#15
coding is just another word for triggering. it comes from the fact that early programming was a lot like making codes or something. it was extremely complex anyways.