ID:158789
 
I've tried but i don't get how to get it to work, what i need is that if I've got something, and with the random code i cant get something2 or something3 if i don't have something1, and i can only get either something2 or something3, not both.

for example this is what I've tried

            if(usr.s = "something1")
usr.random=rand(1,2)
if(usr.random==1)
usr.ss = "something2"
return
if(usr.random==2)
usr.ss = "something3"
return
if(usr.s = "something2")
usr.random=rand(1,2)
if(usr.random==1)
usr.ss = "something3"
return
if(usr.random==4)
usr.ss = "something1"
return
if(usr.s = "something3")
usr.random=rand(1,2)
if(usr.random==1)
usr.ss = "something2"
return
if(usr.random==2)
usr.ss = "something1"
return


So, I don't get the problem here, i get error =/
Uhhh... What's the error? >_>
There's no goddamned reason to have a mob/var/random. Who the hell started that crap? If you need some variable for a proc, you just declare it.

proc
whatever()
var/random = rand() //HOLY CRAP MIND BLOWN


As for this, if you want to do something based on a random number, most straightforward is to use switch(), like so:

proc
whatever()
var/random = rand(1,4)
switch(random)
if(1)
//something
if(2)
//something else
if(3 to 4)
//another thing
In response to Garthor
Garthor wrote:
There's no goddamned reason to have a mob/var/random. Who the hell started that crap? If you need some variable for a proc, you just declare it.

proc
> whatever()
> var/random = rand() //HOLY CRAP MIND BLOWN

As for this, if you want to do something based on a random number, most straightforward is to use switch(), like so:

proc
> whatever()
> var/random = rand(1,4)
> switch(random)
> if(1)
> //something
> if(2)
> //something else
> if(3 to 4)
> //another thing


I already know how to do that you just told me, did you really understand what i meant? how do i make it random to get either something 2 or 3 if i got something1 and if i got something2, it will random to choose between something2 or something3

This is the error i get
error::missing expression
if :warning: if statement has no effect
In response to Enic
Enic wrote:
how do i make it random to get either something 2 or 3 if i got something1 and if i got something2, it will random to choose between something2 or something3

Uh, dude, just nest your if()s (or switch()s or whatever)? That's common sense here. BTW, I still got it, but that's a kinda confusing way to try and explain what you want. :P Here, I'll give you a more easy to understand example than something1 and 3: =P First it decides if to randomly choose a fruit or a vegetable, then chooses out of 2 more options:
var/food_type = rand(0,1)
if(food_type) //if it's 1
//choose a fruit
var/fruit = rand(0,1)
if(fruit) world << "orange!"
else world << "watermelon!"
else
//choose a vegetable
var/veggie = rand(0,1)
if(veggie) world << "cucumber!"
else world << "tomato!"

BTW, I sticked with rand() to make it fit in here and all and keep it simple, but also look into prob() and pick(), they can be more convenient (such as in the above example).
In response to Kaioken
Kaioken wrote:
Enic wrote:
how do i make it random to get either something 2 or 3 if i got something1 and if i got something2, it will random to choose between something2 or something3

Uh, dude, just nest your if()s (or switch()s or whatever)? That's common sense here. BTW, I still got it, but that's a kinda confusing way to try and explain what you want. :P Here, I'll give you a more easy to understand example than something1 and 3: =P First it decides if to randomly choose a fruit or a vegetable, then chooses out of 2 more options:
> var/food_type = rand(0,1)
> if(food_type) //if it's 1
> //choose a fruit
> var/fruit = rand(0,1)
> if(fruit) world << "orange!"
> else world << "watermelon!"
> else
> //choose a vegetable
> var/veggie = rand(0,1)
> if(veggie) world << "cucumber!"
> else world << "tomato!"

BTW, I sticked with rand() to make it fit in here and all and keep it simple, but also look into prob() and pick(), they can be more convenient (such as in the above example).
hehe, well i couldnt come up something else than something1,2 =P but otherwise thank you, seemed to work fine now =)