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

Variable Integer Problems

Status
Not open for further replies.
Level 6
Joined
Aug 22, 2006
Messages
253
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
 
Level 5
Joined
Jun 17, 2006
Messages
114
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.
 
Level 6
Joined
Aug 22, 2006
Messages
253
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)
 
Level 4
Joined
Apr 8, 2005
Messages
70
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
 
Level 6
Joined
Aug 22, 2006
Messages
253
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.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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 )
 
Level 6
Joined
Aug 22, 2006
Messages
253
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?
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
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"
 
Level 6
Joined
Aug 22, 2006
Messages
253
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.
 
Level 24
Joined
Jun 26, 2006
Messages
3,406
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.
 
Level 6
Joined
Aug 22, 2006
Messages
253
To double check before i convert... this is the trigger you want?

Event:
Chat message (Integer(Random number between 1000 and 9999)

Condition:
(entered chat string) equal to (Code)

Action:
Open Door
 
Level 8
Joined
Feb 10, 2006
Messages
466
PurplePoot you are wrong on many levels. Please stop fagging up the thread. When it's possible to do someting in gui you should do it in gui.

Teifi
All you have to do is create event:

Player types chat message containing code as a substring.

Then get a substring from entered string, from char 6 to char [length of string] (ie if entered string is "code 345" you'll get "345"), convert it to integer and compare with your code.
 
Level 6
Joined
Aug 22, 2006
Messages
253
YAY! IT WORKS! :D

Thank you so much low-life, i am eternally grateful. Thank you to you too purplepoot for your efforts and patience ^___^


(I have another problem now with it, that the random number seems to appear the same everytime but i shall not burden you with that) :D

thanks again
 
Level 6
Joined
Aug 22, 2006
Messages
253
Oh well I figured it out anyway - i just didnt put the [Generate Random Number] variable action in a timed trigger, eg map initialization. Anyway, ill do what you said.

Thank you both of you.
 
Status
Not open for further replies.
Top