ID:140958
 
Code:
turf
TitleScreens
density=1
MainTitle
icon='gamescreen.png'

NewButton
Click()
if(fexists("Players/[usr.key].sav"))
if(alert("You already have a character. /nCreate a new one anyway?","File Detected","New","Cancel")!="New")
return
usr.loc=locate(17,5,2)

LoadButton
Click()
if(usr.Load())
world << "[src] has logged in."
else
alert(usr,"You don't have a character!","Load error")

CharSelect
icon='clanchoose.png'

ClanButton
name="Clan1"

Click()
src.name = input("What is your character's name?",src.name)
switch(input("Do you choose this clan?")in list("Yes","No"))

if("Yes")
switch(rand(1,100))
if(100)
usr.loc=locate(5,5,3)
else
return 0
world << "[src] has joined Clan1!"
usr.loc=locate(1,200,1)
usr.Clan = "Clan1"
usr.Class="Warrior"
if("No")
return 0


Problem description:
I'm trying to make it so that there is a 1/100 random chance someone will be located to a certain part of a map when they start a new game (the random code I used is near the bottom of the entire code above). I'm not sure exactly how I'm supposed to put the code as, though. When I compile, it keeps saying "Inconsistent Indentation" when I do it this way, and if I try fixing the identation, it tells me something like 'expected "if" or "else"'.
                if("Yes")
switch(rand(1,100))
if(100)
usr.loc=locate(5,5,3)
else
return 0
world << "[src] has joined Clan1!"
usr.loc=locate(1,200,1)
usr.Clan = "Clan1"
usr.Class="Warrior"



Looks like you have a space on the if right after your switch statement, that would be your inconsistent indentation.
In response to Jotdaniel
Jotdaniel wrote:

Looks like you have a space on the if right after your switch statement, that would be your inconsistent indentation.

Wow, that was it? I had no idea that was there... and I probably never would have noticed it.
Thanks so much!
UR DOIN IT RONG!

What you want to use is prob() here. A 1 in 100 chance = 1% chance. In this situation, prob() is DEFINITELY better than rand().

So, remove the switch(rand) and instead put if(prob(1)) where the if(100) is. Also, look up prob() in the reference.
In response to Demon_F0rce
Demon_F0rce wrote:
UR DOIN IT RONG!

What you want to use is prob() here. A 1 in 100 chance = 1% chance. In this situation, prob() is DEFINITELY better than rand().

Prob actually just does a random number check, which is exactly what he is doing... There is no 'DEFINITE' one that is better or worse. It is mostly personal preference.

if(prob(50))

Is pretty much equivalent to

if(rand(1,100)>=50)
In response to AJX
Yes, however generally I reckon it looks neater when using prob(), not to mention prob() is designed specifically for what he's using here.
In response to AJX
AJX wrote:
Demon_F0rce wrote:
UR DOIN IT RONG!

What you want to use is prob() here. A 1 in 100 chance = 1% chance. In this situation, prob() is DEFINITELY better than rand().

Prob actually just does a random number check, which is exactly what he is doing... There is no 'DEFINITE' one that is better or worse. It is mostly personal preference.

if(prob(50))

Is pretty much equivalent to

if(rand(1,100)>=50)

Aside from the fact that one is 50% and the other is 51%