ID:145484
 
Code:
if(usr.V==1)


Problem description:

it keeps saying invalid expression, and i tried everything i know and it just made it worse, so how do i fix it
first of all, if V is a toggle switch (1 or 0 only) all you have to do is
if(usr.V)

otherwise, check to see if V is a defined variable for all mobs and that you aren't using this in a part of the program where usr is null (most procs - New(), Login(), user-defined).

Also, if statements must have following lines, or else it will be an error:
//one following statement
if(A || B) return
//a few short ones
if(A && !B) {usr << "[M]!"; usr.sp = 0; return;}
//a lot
if(A || !B && K)
usr << "[A]!"
src.sp = 0
usr.name = "[x]"
src << "[Mn]"
var/D = X + Y
// and so on...


Check all of that.


--Vito
In response to Vito Stolidus
Vito, he probably didn't understand any of that.
In response to KirbyRules
NO I DIDNT LOL
In response to LeeZein
Create_Character()
var/mob/newmob
var/newname=input("Welcome to [world.name]. Choose a Name for your RPing Character","Name")as text
switch(input("What is your Gender?","Gender")in list("Male","Female"))
if("Male")
newmob=new/mob/charas/Male()
if("Female")
newmob=new/mob/charas/Female()
newmob.name=newname
usr.client.mob=newmob
switch(input("Choose a Village.","Village of Birth")in list("Hidden Leaf","Hidden Sand","Hidden Mist","Hidden Rain","Hidden Water","Hidden Grass","Hidden Cloud","Hidden Stone","Hidden Earth","Hidden Snow"))
if("Hidden Leaf")
usr.from="Hidden Leaf"
usr.V=1
if("Hidden Sand")
usr.from="Hidden Sand"
usr.V=2
usr.chance+=rand(1,50)
if("Hidden Mist")
usr.from="Hidden Mist"
usr.V=3
if("Hidden Rain")
usr.from="Hidden Rain"
usr.V=4
if("Hidden Water")
usr.from="Hidden Water"
usr.V=5
if("Hidden Grass")
usr.from="Hidden Grass"
usr.V=6
if("Hidden Cloud")
usr.from="Hidden Cloud"
usr.V=7
if("Hidden Stone")
usr.from="Hidden Stone"
usr.V=8
if("Hidden Earth")
usr.from="Hidden Earth"
usr.V=9
if("Hidden Snow")
usr.from="Hidden Snow"
usr.V=10
if(usr.V)
switch(input("Clan","Blood Line")in list("Uchiha","Hyuuga","Inuzuka","Akamichi","Nara","Kaguya","Non-Clan"))
if("Uchiha")
usr.clan="Uchiha"
usr.MCP+=rand(5,50)
if("Hyuuga")
usr.clan="Hyuuga"
usr.MCP+=rand(5,70)
if("Inuzuka")
usr.clan="Inuzuka"
if("Akamichi")
usr.clan="Akamichi"
if("Nara")
usr.clan="Nara"
if("Kaguya")
usr.clan="Kaguya"
usr.MSP+=50
usr.MCP=1
if("Non-Clan")
usr.clan="Non-Clan"
usr.Tai+=10
usr.MSP+=50
usr.MCP=1
if(usr.V==2&&usr.chance==30)
usr<<"the Tsuchikage has inplanted a demon within you"
usr<<"you cry as your body changes bittersweat in stats"
usr.MCP=200
usr.MSP=50
usr.MHP=200
if(usr.V==3)
switch(input("Clan","Blood Line")in list("Haku","Non-Clan"))
if("Haku")
usr.clan="Haku"
if("Non-Clan")
usr.clan="Non-Clan"
if(usr.V==6)
switch(input("Clan","Blood Line")in list("Chuuga","Non-Clan"))
if("Chuuga")
usr.clan="Chuuga"
if("Non-Clan")
usr.clan="Non-Clan"

check if there is anything wrong plz
In response to LeeZein
Did i confuse you? sorry. Maybe I should use smaller words...

Anyway, I found it.
      if(usr.V==3) // <-- You need lines after an if statement. for form, see my obfuscating post.
switch(input("Clan","Blood Line")in list("Haku","Non-Clan"))
if("Haku")
usr.clan="Haku"
if("Non-Clan")
usr.clan="Non-Clan"
if(usr.V==6)// <-- and here, and anywhere else you did this
switch(input("Clan","Blood Line")in list("Chuuga","Non-Clan"))
if("Chuuga")
usr.clan="Chuuga"
if("Non-Clan")
usr.clan="Non-Clan"

See it? Since there isn't anything after the if(), it says there's an error. If the code following the if() is supposed to be inside it (AKA only activated if the conditional returns true) you have to indent it.

EDIT: Looking at those input lines, you'll have problems there in the future. You want an alert line - For an alert, the first argument (text) is the question, the second (text) is the box's heading, and the rest (all text) are buttons.
switch(alert("[Question]", "[Title]", "[Button1]", "[Button2]"))


--Vito
In response to Vito Stolidus
wait give me an example of the line thing, or maybe i just didnt get you lol, sry
In response to LeeZein
Okay...


Optional:
For one line after an if() statement you put the line directly after the if():
if(A && (B || C)) return
// one line after the if() only.


For a few short lines, you enclose them in brackets and seperate them with semicolons ";" similar to what you'd do in C++ or Java:
if(A && (B || C)) { usr << "Ha!"; usr.sp --; return; }
// note that there really is no limit to length



Not optional:
For any number of lines, you just indent once and DM assumes brackets and semicolons:
if(A && (B || C))
usr << "Hah! You lose!"
usr.sp --
usr.hp --
usr.loc = locate(x2, y2, z2)
// You can put as many as you like - there is n limit


Does that simplify things? (For simplicity, the third method woreks for any number of lines - you can use it for all three. the other two are to shorten your code.)


--Vito
In response to Vito Stolidus
okay, okay so how would u fix my problem like write down what would u do because, u confuse me, if i saw u ull confuse me like ur confusing me right now just talking to u confusion king lol
In response to LeeZein
It's not hard. You have two options right now:

A) If the lines after the if() statement are supposed to execue only if, say, V == 1

  • Indent those lines so they're part of the if statement. problem solved.

    B) The lines after the if() statement are independent - they always execute, reguardless of V's value.
  • Simply put some code after the if() statements so they actually do something.
  • Optionally, you could place them in comments, by adding "//" to the front of the lines. This makes them invisible to the program, and you leave them like that until you need them to do something later.



    --Vito
In response to LeeZein
Rule 0 of posting code: Never use only one space where a tab belongs. Use at least two spaces per tab. Above all else, your code must be readable--particularly because you've obviously got an indentation error.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Rule 0 of posting code: Never use only one space where a tab belongs. Use at least two spaces per tab. Above all else, your code must be readable--particularly because you've obviously got an indentation error.

Lummox JR

Lummox got it.

      if(usr.V)  //There's that darn indentation error. =/
switch(input("Clan","Blood Line")in list("Uchiha","Hyuuga","Inuzuka","Akamichi","Nara","Kaguya","Non-Clan"))
In response to Vito Stolidus
okay okay big words man, ill i need u to do is to write down the correction not explain how to correct it, i need my game done as soon as possible so i pasted all your confusing good words to study it k, i appriciate for ur help tho
In response to LeeZein
Sorry. forgot the big words thing.

you have:
if(usr.V == 1)
switch(alert(...)) // the '...' is to abbreviate
... // whatever follows the switch


you need:
if(usr.V == 1)
switch(alert(...))
... // whatever follows the switch


Simple enough?

Also, note that the shortening of "you" to "u" and other IMer abbrevations are not good etiquette on these forums and you probably should take the time to make your posts (sorry, all you AIM-ers out there) more civilized.


--Vito
In response to Vito Stolidus
i did but still the same :(

Create_Character()
var/mob/newmob
var/newname=input("Welcome to [world.name]. Choose a Name for your RPing Character","Name")as text
switch(input("What is your Gender?","Gender")in list("Male","Female"))
if("Male")
newmob=new/mob/charas/Male()
if("Female")
newmob=new/mob/charas/Female()
newmob.name=newname
usr.client.mob=newmob
switch(input("Choose a Village.","Village of Birth")in list("Hidden Leaf","Hidden Sand","Hidden Mist","Hidden Rain","Hidden Water","Hidden Grass","Hidden Cloud","Hidden Stone","Hidden Earth","Hidden Snow"))
if("Hidden Leaf")
usr.from="Hidden Leaf"
usr.V=1
if("Hidden Sand")
usr.from="Hidden Sand"
usr.V=2
usr.chance+=rand(1,50)
if("Hidden Mist")
usr.from="Hidden Mist"
usr.V=3
if("Hidden Rain")
usr.from="Hidden Rain"
usr.V=4
if("Hidden Water")
usr.from="Hidden Water"
usr.V=5
if("Hidden Grass")
usr.from="Hidden Grass"
usr.V=6
if("Hidden Cloud")
usr.from="Hidden Cloud"
usr.V=7
if("Hidden Stone")
usr.from="Hidden Stone"
usr.V=8
if("Hidden Earth")
usr.from="Hidden Earth"
usr.V=9
if("Hidden Snow")
usr.from="Hidden Snow"
usr.V=10
if(usr.V==1)
switch(alert("Clan","Blood Line")in list("Uchiha","Hyuuga","Inuzuka","Akamichi","Nara","Kaguya","Non-Clan"))
if("Uchiha")
usr.clan="Uchiha"
usr.MCP+=rand(5,50)
if("Hyuuga")
usr.clan="Hyuuga"
usr.MCP+=rand(5,70)
if("Inuzuka")
usr.clan="Inuzuka"
if("Akamichi")
usr.clan="Akamichi"
if("Nara")
usr.clan="Nara"
if("Kaguya")
usr.clan="Kaguya"
usr.MSP+=50
usr.MCP=1
if("Non-Clan")
usr.clan="Non-Clan"
usr.Tai+=10
usr.MSP+=50
usr.MCP=1
if(usr.V==3)
switch(alert("Clan","Blood Line")in list("Haku","Non-Clan"))
if("Haku")
usr.clan="Haku"
if("Non-Clan")
usr.clan="Non-Clan"
if(usr.V==6) //
switch(alert("Clan","Blood Line")in list("Chuuga","Non-Clan"))
if("Chuuga")
usr.clan="Chuuga"
if("Non-Clan")
usr.clan="Non-Clan"
In response to LeeZein
Double-click on the error message. Which line does it highlight?

Note - please use 2-4 spaces to represent tabs, it makes these posts so much more readable.

--Vito
In response to Vito Stolidus
the line with the if(usr.V==1)
In response to LeeZein
Oh. That if() statement is indented once two many, as are, I'll bet, all the lines after it. You're not supposed to indent before an if(), only after it.


--Vito
In response to Vito Stolidus
so how would u fix it(in english XD)
In response to LeeZein
'untab' the if() statement and probably all the lines 'tabbed-in' to the if() statement.

Note that the words I used in the last few posts were about as 'dumbed-down' as such topics can be. I suggest getting to know programming lingo, as the language of this forum is not "2-bit IM".

Also, something to help when someone suggests code you've never heard of - the DM Guide. If someone tells you to use, say, the rgb() function to do something, this will tell you how to use it. It may help with that pseudo-language barrier problem (Whoops, sorry, that's long words...), too.

--Vito
Page: 1 2