generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Pick a random vehicle with rarity included?

Previous Thread :: Next Thread 
MajorCrusader is not online. MajorCrusader
Joined: 09 Jun 2016
Total Posts: 396
17 Jun 2016 08:33 AM
How would you want to do this? I don't want to create X number of children and select randomly because that's messy. I don't want to enter items into a table more than once.


Report Abuse
Isosta is not online. Isosta
Joined: 10 May 2015
Total Posts: 14729
17 Jun 2016 08:39 AM
uhmmm
this is pseudo code but maybe try something like this

local itemRarity = {
['Item1'] = 10, --Increasing == more common
['Item2'] = 2
}

local select = function()
local pseudoTable = {}
for Item,Rarity in next, itemRarity do
for i=1,Rarity do
table.insert(pseudoTable,Item)
end
end
local value = math.random(1,#pseudoTable)
return pseudoTable[value]
end

local SelectedItem = select()


#code io.write('( ͡° ͜ʖ ͡°)')
Report Abuse
MajorCrusader is not online. MajorCrusader
Joined: 09 Jun 2016
Total Posts: 396
17 Jun 2016 08:41 AM
Thought about doing that, was hoping there was a cleaner solution. Oh well.


Report Abuse
Isosta is not online. Isosta
Joined: 10 May 2015
Total Posts: 14729
17 Jun 2016 09:09 AM
probably a good idea to create the pseudo table outside of the function if you plan on running the function more than once.


#code io.write('( ͡° ͜ʖ ͡°)')
Report Abuse
KapKing47 is not online. KapKing47
Joined: 09 Sep 2012
Total Posts: 5522
17 Jun 2016 09:22 AM
I can make a Module for that if u like, or I could ask a friend, but yeah, there is no easy way out, remember that :P
Report Abuse
MajorCrusader is not online. MajorCrusader
Joined: 09 Jun 2016
Total Posts: 396
17 Jun 2016 09:43 AM
No need for a module, it's not hard, it's just not as clean as I wish I could make it. Oh well.


Report Abuse
KapKing47 is not online. KapKing47
Joined: 09 Sep 2012
Total Posts: 5522
17 Jun 2016 01:24 PM
Lol... I could easily make so u could do something like this

require(Module)
Choose({Stuff = 5; Other = 1}) --The higher the number the more common

And I mean WITHOUT having to even define 'Choose' all u gotta do is set it up with require() and ur set, but if u dont want it, then sure whatever u say lol :P
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image