ID:262841
 
Code:


Problem description:
i think im missing part of the code, but when it overlays it overlays behind the player, not in front of them. how come. can't put any code up there cus i dont have one for it really. thx much guys.


i know it hasnt been 24hrs but i need some help. can i have some plz?
How are you adding your overlays?
In response to Crispy
here ill show you.


verb/Equip()
if(usr.key == "Pyro_dragons" | "Steiner" | "Chris_110872")
if(usr.W) usr.W.Unequip()
usr.W=src
src.suffix = "Equipped"
usr << "You equip a [src]"
usr.overlays += usr.W
usr.Attack += Attack
usr.Magic_Attack += Magic
usr.Fire_Skill += Fire
usr.Ice_Skill += Ice
usr.Wind_Skill += Wind
usr.Thunder_Skill += Thunder
usr.Earth_Skill += Earth
usr.Light_Skill += Light
usr.Darkness_Skill += Darkness
In response to Pyro_dragons
The problem is that you're adding an object to the player's overlays, and the object has a lower layer than the player. When you add an object to overlays, it keeps its existing layer.

There are a few ways to get around this; probably the safest one is to use a lookalike image object instead of the object itself:

usr.overlays += image(src.icon, icon_state=src.icon_state)
In response to Crispy
Eum, it's
 if("Lalalal" || "Blablabla")

Not one '|'
In response to Mysame
Good point, I didn't notice that... and it's wrong anyway, it should be:

if(usr.key == "Pyro_dragons" || usr.key == "Steiner" || usr.key == "Chris_110872")


Or alternatively:

if(usr.key in list("Pyro_dragons", "Steiner", "Chris_110872"))
In response to Crispy
either one works. its already been tested and works fine
In response to Pyro_dragons
Actually, I'm afraid it doesn't work. Try logging in with a key that isn't in that list; it will also have access!

This is because a text string on its own always evaluates to true. So this line:

if(usr.key == "Pyro_dragons" || "Steiner" || "Chris_110872")


is equivalent to this line:

if(usr.key == "Pyro_dragons" || 1 || 1)


which is equivalent to:

if(1)


which will, obviously, give everyone access regardless of their key.

It seems like it should work because that's how we'd say it in English: "If my key is Pyro_dragons or Steiner or Chris_110872". But programming doesn't work like that.

The | operator will also appear to work because it's similar to the || operator. But in boolean contexts such as this one, you should use the || operator. Getting into the habit of using the | and || operators correctly will save you the headache of subtle bugs later, in situations where it actually matters.
In response to Crispy
don't worry about it. i had put that part in a long time ago before i had a larger staff. now that i do, i have all my staff members in a list and changed thatpart to:

if(usr.key in Staff)