ID:1750581
 
(See the best response by Mightymo.)
Code:
obj
Crew
Low_Quality
obj1
...()
obj2
...()
obj3
...()


mob/verb
BCrew()
if(src.money >= 30000)
src.money -=30000
if(prob(LowQProb)) // 70% prob low quality
var/wobj = rand(/obj/Crew/Low_Quality)
crewcont += wobj // This is the 2nd inventory
CrewCont()
else if(prob(100-LowQProb))
// ..............................


Problem description:Hi, ive got a problem with the new system that i want to add, the system is a rulette with obj as reward, i want that when the player click a button from the interface, the rewards are /obj/Crew/Low_Quality/.... << all bellow Low_Quality, my problem is that when i spin it i dont get any obj.
How could i do it?
That rand statement isn't going to work. Look into typesof() to create a list of the objects that you want. Second, you probably want to actually create the object using new(), rather than just adding the path to a list.
ok, now i made a list with all the objects i want, now how can i get a random item from the list ?
var/list/Low_Quality = typesof(/obj/Crew/Low_Quality)

mob/verb
BCrew()
if(prob(LowQProb)) // 70% prob low quality
.. // Get Random item from the list
crewcont += new .. // This is the 2nd inventory
CrewCont()
Use pick().
yeah, but if in my list i got more than 50 objects and i have to make another 2 list with the same number of objs? im not sure about if i understand what you try to tell me. :S
and with pick() i dont know where i have to use the new list
// under if(prob(..))
var/Reward = pick("[/obj/Crew/Low_Quality/obj1]","[/obj/Crew/Low_Quality/obj2]","[/obj/Crew/Low_Quality/obj3]","[/obj/Crew/Low_Quality/obj4]","[/obj/Crew/Low_Quality/obj5]",)
crewcont += new [reward]
CrewCont()
Best response
You can just pick from a list.
var/Reward = pick(Low_Quality)

Assuming that you use the same list as above, although you probably want to remove the base type from the list.

Also, your syntax for new is incorrect, you do not need the brackets.
thanks you now it works fine