Author Topic: [Other] Variable script not working?  (Read 224 times)

0 Members and 1 Guest are viewing this topic.

Jakub34

  • Member
  • ***
  • Posts: 230
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • http://www.kongregate.com/games/Coolio_Niato/streamline?acomplete=streaml
    • Awards
  • Xbox: jakub34
[Other] Variable script not working?
« 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.

Craig

  • Developer
  • Extreme Member
  • ******
  • Posts: 6541
  • Dig Deep
  • Awards Developer 4 years on site+1000 posts 3 years on site+600 posts 2 years on site+300 posts Was in the top 10 of the forum stats page as of 4/12/15 Members who have unlocked the robotic avatar 1 year on site+100 posts Day 1 w/25+ posts (4/12/13)
    • View Profile
    • Twitter
    • Awards
  • Steam: tota1miner
Re: Variable script not working?
« Reply #1 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]

Jakub34

  • Member
  • ***
  • Posts: 230
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • http://www.kongregate.com/games/Coolio_Niato/streamline?acomplete=streaml
    • Awards
  • Xbox: jakub34
Re: Variable script not working?
« Reply #2 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.

cY Agent 115

  • Member
  • ***
  • Posts: 184
  • Death to trolls on the forums
  • Awards 1 year on site+100 posts
    • View Profile
    • Awards
  • Xbox: cY Agent 115
  • Steam: cY Agent 115
Re: Variable script not working?
« Reply #3 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?

Jakub34

  • Member
  • ***
  • Posts: 230
  • Awards Members who have unlocked the robotic avatar 1 year on site+100 posts
    • View Profile
    • http://www.kongregate.com/games/Coolio_Niato/streamline?acomplete=streaml
    • Awards
  • Xbox: jakub34
Re: Variable script not working?
« Reply #4 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.