Total Miner Forums

Total Miner => Creative Features => Topic started by: Jakub34 on November 22, 2017, 08:11:14 PM

Title: Variable script not working?
Post by: Jakub34 on November 22, 2017, 08:11:14 PM

Var [loot] = [1] [+] [rand:3]

If
IsVar [loot] = [1]
then
Inventory [player] [add] [apple] [1]
elseif
IsVar [loot] = [2]
then
Inventory [player] [add] [apple] [2]
elseif
IsVar [loot] = [3]
then
Inventory [player] [add] [apple] [3]
elseif


As far as I understand, the variable script should choose a random number between 1-3. ( Hopefully it is not including decimals... ) The script works perfectly, but sometimes, the script will not give an apple.
Title: Re: Variable script not working?
Post by: Craig on November 22, 2017, 10:11:08 PM
[rand:3] returns a random value between 0 and 3 inclusive, either 0, 1, 2 or 3. That's 4 possible numbers.

change your script to [rand:2]
Title: Re: Variable script not working?
Post by: Jakub34 on November 23, 2017, 07:38:14 AM
[rand:3] returns a random value between 0 and 3 inclusive, either 0, 1, 2 or 3. That's 4 possible numbers.

change your script to [rand:2]

Guess that script documentation was a bit misleading then ;s It applied it to the name instead of the rand, so who knows :s

Tanks for the help.
Title: Re: Variable script not working?
Post by: cY Agent 115 on November 23, 2017, 08:36:55 AM
With variables, is it a random chance for each one? Im trying to figure out an easier way to make drop chances happen in scripts

for instance, i click a button which gives me a chance to get a sword. The chance of a higher tier sword dropping is dependant on the percentage. but is there an easier way to do it?
Title: Re: Variable script not working?
Post by: Jakub34 on November 23, 2017, 10:38:56 AM
With variables, is it a random chance for each one? Im trying to figure out an easier way to make drop chances happen in scripts

for instance, i click a button which gives me a chance to get a sword. The chance of a higher tier sword dropping is dependant on the percentage. but is there an easier way to do it?

The script rolls a random number between the numbers you chose. In my case (when I changed the script), I rolled a number between 1 and 3. If my number landed on 1, I get 1 apple. If my number landed on two, I get 2 apples.

To answer your question, this is way better for drop chances. Say you have wood swords and iron swords. You will roll a random number between 1-5, upon pressing the button.  Wood sword has the values of 1,3,5 and iron sword has 2,4. Rolling 1,3,5 will give a wood sword, and rolling 2 or 4 will give iron sword. Now, let's say iron sword has a value of 3. Rolling a 3 will give you both the iron and wood sword.
Title: Re: Variable script not working?
Post by: cY Agent 115 on December 13, 2017, 06:33:50 AM
To answer your question, this is way better for drop chances. Say you have wood swords and iron swords. You will roll a random number between 1-5, upon pressing the button.  Wood sword has the values of 1,3,5 and iron sword has 2,4. Rolling 1,3,5 will give a wood sword, and rolling 2 or 4 will give iron sword. Now, let's say iron sword has a value of 3. Rolling a 3 will give you both the iron and wood sword.
how would you write that in the script? [rand:1,3,5] is a completely random guess
Title: Re: Variable script not working?
Post by: Jakub34 on December 14, 2017, 03:39:17 PM
To answer your question, this is way better for drop chances. Say you have wood swords and iron swords. You will roll a random number between 1-5, upon pressing the button.  Wood sword has the values of 1,3,5 and iron sword has 2,4. Rolling 1,3,5 will give a wood sword, and rolling 2 or 4 will give iron sword. Now, let's say iron sword has a value of 3. Rolling a 3 will give you both the iron and wood sword.
how would you write that in the script? [rand:1,3,5] is a completely random guess

Just follow what I have. I'm not 100% sure on what number to use (since my script somehow had a 0 in it), but if you did Var [loot] = [1]
Title: Re: Variable script not working?
Post by: cY Agent 115 on December 14, 2017, 09:04:07 PM
My point is how do you control how many of those are 1 item and the others a different item.
Title: Re: Variable script not working?
Post by: Lunar on December 16, 2017, 08:42:40 AM
Also you have operators mixed up, on IsVar it would be
Title: Re: Variable script not working?
Post by: cY Agent 115 on December 16, 2017, 10:43:07 AM
Okay so

If
IsVar [Ran:3] [0,1,2]?
Title: Re: Variable script not working?
Post by: Jakub34 on December 18, 2017, 10:28:01 PM
Okay so

If
IsVar [Ran:3] [0,1,2]?

IDK exactly but that sounds right
Title: Re: Variable script not working?
Post by: cY Agent 115 on December 21, 2017, 08:07:03 AM
IDK exactly but that sounds right
no i got it now, i got taught by MrMarooca. He's such a good teacher.

what it is, is:

Var [loot] [Rand:2]

If
IsVar [loot] [=]
Then
Inventory [player] [add] [apple] [1]

ElseIf
IsVar [loot] [=] [1]
Then
Inventory [player] [add] [apple] [2]

ElseIf
IsVar [loot] [=] [2]
Then
Inventory [player] [add] [apple] [3]

Edit: no idea why there's a dot in the way :/