I have a few questions about using meta for certain purposes.

Unofficial support for the creating and editing of metas.
tsxmetabot
Posts: 4

I have a few questions about using meta for certain purposes.

Post #1 »

Alright so I made a topic on the general forum asking a dumb question which was answered very quickly and I really appreciate that. Well, little did I know that...I knew very, very little about meta, apparently.

I mean, I know enough to have made full quest metas and bots for certain things, but now I'm bored of that and want to get into some crazier stuff. I want to learn how all the expressions work and how to use them to the maximum.

Okay, starting out...how would I make a very simple rock-paper-scissors mini-game within meta? In my head it seems very simple; I just need a few states and a few variables to work with.

But...what? How do I manipulate the variable functions, exactly? I know about the "randint[2]" function but I have no earthly clue how to use it. It says there are two parameters that determine minimum and maximum of a random number but what is the proper format? "randit[1-3]"? "randit[1 3]"? Furthermore, once it makes a number how do I print it in chat or make states that are called based on what that number is?

What I want to do is basically make one variable for the "computer player's choice"--a value between 1 and 3 (rock, paper or scissors)--that is picked when a player says a certain command. Maybe "go" or something. Then the meta waits for the player to say their choice: rock, paper or scissors. Then the meta will react and give its response BASED ON the RANDOM VARIABLE created earlier. So, let's say the player says "rock" and the random variable's value was 1 (rock). The meta would say "Rock. It's a tie." If the player said paper and the variable was 1, the meta might say "Rock. You win." And lastly, if the player said scissors and the variable was still 1: "Rock. You lose." And so on and so forth.

I realize that rock-paper-scissors seems like a bad and completely arbitrary example, but I feel that it works well as a beginner exercise in understanding the inner workings of meta variables/expressions and how to utilize them effectively. I want to eventually make better projects than simple little mini-games, but in order to do so I need to know exactly how this stuff works. I have googled all over but am overwhelmed either by the lack of specific info or the abundance of info I'm not exactly looking for.

If anybody has any ideas or advice I would be SUPER grateful. I am definitely not looking for someone to do the work for me as I wouldn't learn a thing from it. I just want to know how I might be able to use variables/expressions to create a simple rock-paper-scissors mini-game and I should be able to go solo from there.

Thank you!

yaroz
Moderator
Posts: 129

Post #2 »

randint[0,2] would return a random value between 0 and 2 (0,1,2)
randint[3,15] would return a random value between 3 and 15 (3,4,5,6,7,8,9,10,11,12,13,14,15)

For your example, I'd use chat strings.. just logic here, since I don't have a pc running ac/vtank to test out on

Code: Select all

[default state]
Chat: You say, \"RPS\"  Call Meta State: "Game"

[Game state]
Chat: You say, \"Rock\"  All{setvar[RPS_Player,Rock];Call: "GameCheck" Return: default}
Chat: You say, \"Paper\" All{setvar[RPS_Player,Paper];Call: "GameCheck" Return: default}
Chat: You say, \"Scissors"\ All{setvar[RPS_Player,Scissors];Call: "GameCheck" Return: default}

[GameCheck state]
Always: setvar[varRand,randint[0,2]]
Expression: getvar[varRand]==0  setvar[RPS_Computer,Rock]
Expression: getvar[varRand]==1  setvar[RPS_Computer,Paper]
Expression: getvar[varRand]==3  setvar[RPS_Computer,Scissors]
All{
  Expression: getvar[RPS_Player]==Rock
  Expression: getvar[RPS_Computer]==Rock}   All{Chat: We both said Rock, it's a tie!;Expression: clearallvars[]; Return}
All{
  Expression: getvar[RPS_Player]==Paper
  Expression: getvar[RPS_Computer]==Paper}   All{Chat: We both said Paper, it's a tie!; Expression: clearallvars[]; Return}
All{
  Expression: getvar[RPS_Player]==Scissors
  Expression: getvar[RPS_Computer]==Scissors}   All{Chat: We both said Scissors, it's a tie!; Expression: clearallvars[]; Return}
All{
  Expression: getvar[RPS_Player]==Paper
  Expression: getvar[RPS_Computer]==Rock}   All{Chat: I choose Rock.. but you chose Paper, so you win. ARGH!!  Good job!; Expression: clearallvars[]; Return}

Something like that.. You could also just set your vars to numeric values and get rid of the extra getvar/setvars in the GameCheck state.

Tacit_MT
Posts: 13

Post #3 »

Remember that the description of randint on the wiki isn't correct though. The min is inclusive, max is not.

Randint[0,2] will return 0 or 1, but never 2.
Randint[5,10] will return 5, 6, 7, 8, or 9, but never 10.

User avatar
HellsWrath
Site Admin
Posts: 389

Post #4 »

Tacit_MT wrote:Remember that the description of randint on the wiki isn't correct though. The min is inclusive, max is not.

Randint[0,2] will return 0 or 1, but never 2.
Randint[5,10] will return 5, 6, 7, 8, or 9, but never 10.
Thanks for the info, I used the /vt metafunchelp [function] output for all of the wiki descriptions so I'll blame that one on V :D

Added your example to the randint dropdown.

tsxmetabot
Posts: 4

Post #5 »

Thank you guys SOOO much! I've been busy lately with RL stuff and haven't messed with AC or meta yet but I will definitely try this stuff out. I really appreciate the help! Thank you, thank you, thank you!