# -Roll Trigger

#### HitmanYesman

##### New Member
I'm making a simple game, turn based game, in which two units, controlled by 2 people, take turns either attacking, casting spell, or use an item. Now in order to see who goes first, I want both players to type -roll. The highest number wins, of course if they don't do it in 10 seconds it will be rolled automatically. I just don't know how to start the action part of the -roll trigger.

Any helps would be great, Thanks!

Event
Map initialization
Condition
Action
Create hashtable
Set hashtable variable = last created hashtable
Set real variable = (number of players)
Save real variable as 1 of 1 for hashtable variable
For loop integer A 1 to (number of players)
Set integer[for loop integer A] = 0

Event
Player chat message entered was -roll as an exact match (For all your players)
Condition
Action
Set integer variable[Player number of triggering player] = random number from 1 to 100
Set real variable = Load 1 of 1 for hashtable variable
Save real variable - 1.00 as 1 of 1 for hashtable variable

(For 2 players, include more if neccessary)
Event
Real variable becomes 0.00
Condition
Action
If/then/else
If
Integer[1] is greater than Integer[2]
Then
-----Do action for player 1 to start first-----
Else
-----Do action for player 2 to start first-----

Edit:

If you want to auto roll After 10 seconds, then in between trigger 2 and 3, add this:

(For 2 players, add more if neccessary)
Event
Game time elasped is 10 seconds
Condition
Action
For loop integer A 1 to (number of players)
If/then/else
If
Integer[Integer A] = 0
Then
Set integer variable[integer A] = random number from 1 to 100
Set real variable = Load 1 of 1 for hashtable variable
Save real variable - 1.00 as 1 of 1 for hashtable variable
Else

The same answer if you can't use, or are confused by Hashtables:

Trigger:
• Roll P1
• Events
• Player - Player 1 (Red) types a chat message containing -roll as An exact match
• Conditions
• Actions
• Trigger - Turn off (This trigger)
• Set Int[(Player number of (Triggering player))] = (Random integer number between 1 and 100)
• Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Has Rolled + (String(Int[(Player number of (Triggering player))]))))

Trigger:
• Roll P2
• Events
• Player - Player 2 (Blue) types a chat message containing -roll as An exact match
• Conditions
• Actions
• Trigger - Turn off (This trigger)
• Set Int[(Player number of (Triggering player))] = (Random integer number between 1 and 100)
• Game - Display to (All players) the text: ((Name of (Triggering player)) + ( Has Rolled + (String(Int[(Player number of (Triggering player))]))))

Trigger:
• Autoroll
• Events
• Time - Elapsed game time is 10.00 seconds
• Conditions
• Actions
• Trigger - Run Roll P1 &lt;gen&gt; (ignoring conditions)
• Trigger - Run Roll P2 &lt;gen&gt; (ignoring conditions)
• Trigger - Turn off Roll P1 &lt;gen&gt;
• Trigger - Turn off Roll P2 &lt;gen&gt;

If you have multiple players it will get messier and i would advise you to use a hashtable, but this is the simplest way to -roll x)

But if you don't use hashtables, you won't find out whether all players have rolled already. And also, you have to compare the results.

I don't understand hashtables really

Hashtables, multiple triggers? Why ?
Just create one global boolean array variable. When the player rolled set it to false, and before the trigger does its actions check if the specific boolean is true.
Index all arrays with the playernumber.

But if you don't use hashtables, you won't find out whether all players have rolled already. And also, you have to compare the results.

So incredibly false. As has been said, a simple global boolean array can check if a player has rolled or not. And two simple global Integer arrays can save what they rolled. From there, its basically a matter of 'Which integer is larger?'

Well what I meant was, the solution that he gave didn't have hashtables and couldn't check if all the players have rolled, so without hesitating i used hashtables instead. Didn't consider any other points. So actually what I meant was, you had to use something boolean, hashtable, or whatever, just that at that moment the boolean idea didn't came to me.

My mistake, i forgot to add the check for if the player had rolled or not, but i assumed that Comparing Int[Player Number] values was an easy method of discerning who rolled the highest xD

General chit-chat
Help Users
• No one is chatting at the moment.
• The Helper:
News portal has been retired. Main page of site goes to Headline News forum now
• The Helper:
I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
• Ghan:
Easily done
+1
• The Helper:
https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
• Ghan:
Need to try something
• Ghan:
Hopefully this won't cause problems.
• Ghan:
Hmm
• Ghan:
I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
• Ghan:
See how we like that.
• The Helper:
I do not see a way to go past the 1st page of posts on the forum though
• The Helper:
It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
• Ghan:
Yeah I'm not sure what the deal is with the pagination.
• Ghan:
It SHOULD be there so I think it might just be an artifact of having an older style.
• Ghan:
I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
• The Helper:
I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
• Ghan:
RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
• The Helper:
• The Helper:
What do you think Tom?
• tom_mai78101:
I will have to get used to this.
• tom_mai78101:
The latest news feed looks good
• The Helper:
I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
• The Helper:
This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/