ID:150011
 
iim trying to make a code that knows me for my key and changes my icon to what i tell it to.I get an error, heres the code:
if(src.key = "Scoobert" )
icon = 'person.dmi'
icon_state = "King Scoobert"
heres the error:
login.dm:55:error::missing expression
Scoobert wrote:
iim trying to make a code that knows me for my key and changes my icon to what i tell it to.I get an error, heres the code:
if(src.key = "Scoobert" )
icon = 'person.dmi'
icon_state = "King Scoobert"
heres the error:
login.dm:55:error::missing expression

maybe try putting two ='s in your if.
In response to Darkness
oh ok ill try now
In response to Scoobert
wow your da man, ok so realy im da man but thanks little errors get me everytime
In response to Scoobert
It still doesnt work its just theres no error
In response to Scoobert
Scoobert wrote:
It still doesnt work its just theres no error
try if(client.key == "Key") it might work better than src.key.
In response to Darkness
Hmm there must be something wrong

In response to Super16
Super16 wrote:
Whats wrong is you forgot src.

here is your code just an ex.

mob/Login()
if(src.key=="Scoobert")
src.icon='d.dmi'
src.icon_state="g"
..()

You need the src. to complete the argument

Um..what are you talking about? Scoobert used src in his code. and Key is a client var anyhow.
In response to Darkness
Darkness wrote:
Super16 wrote:
Whats wrong is you forgot src.

here is your code just an ex.

mob/Login()
if(src.key=="Scoobert")
src.icon='d.dmi'
src.icon_state="g"
..()

You need the src. to complete the argument

Um..what are you talking about? Scoobert used src in his code. and Key is a client var anyhow.

No he just put icon= you need src.icon
In response to Darkness
Key is a client var because only mobs with clients attached can have keys.
In response to Super16
I though you were talking about the if statement, and you don't always need src., it depends how the rest of the code is really, or where he puts it.
Can you post dm line 55
In response to Super16
if(src.key = "Scoobert" )
thats dm 55 but thats not a problem now that i put the == but nothing you have put on here helps
In response to Super16
Super16 wrote:
No he just put icon= you need src.icon

No, you dont. It defaults to src

Alathon
In response to Scoobert
I suggest using this code temporarily, and then examining the error messages you get:
if(src.key == "Scoobert")
src << "Changing icon to King Scoobert"
icon = 'person.dmi'
icon_state = "King Scoobert"
// you will need the latest beta version of BYOND for this next section to work
// just leave it out if you don't have the beta
var/ic
for(ic in icon_states(icon)) if(ic=="King Scoobert") break
if(!ic) src << "Icon state \"King Scoobert\" not found in person.dmi"
// end special block
else
src << "You are not King Scoobert. src.key = \"[key]\""

What this should do is either tell you it's changing the icon, or that it can't because your key doesn't match (and it will tell you which key you're using). This could be as simple as the icon not existing in the right file or having its icon state named incorrectly. In fact, I'd bet that the problem is likely that your icon state is misspelled or that you have the name in lowercase like "king scoobert", so the code is using the default icon in person.dmi instead of yours.

Lummox JR