ID:145502
 
Code: A equip code. Unequip and Equip easily.
    verb/EquipUnequip()
if (src.Equiped == 0)
if (src.weapon == 1)
if (usr.weapon == "")
src.Equiped = 1
src.layer = 8
usr.overlays += src
usr.weapon = "[src]"
usr.attack += src.attack
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You have a weapon equiped! Unequip your [usr.weapon]."
else
if (src.shield == 1)
if (usr.shield == "")
src.Equiped = 1
src.layer = 7
usr.overlays += src
usr.shield = "[src]"
usr.defence += src.defence
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You have a shield equiped! Unequip your [usr.shield]."

else
if (Equipable == 1)
src.Equiped = 1
src.layer = 6
usr.overlays += src
usr << "You equip the [src]."
src.suffix="Equiped" // It's called suffix
else
usr << "You can't equip this."
else
if (src.weapon == 1)
if (usr.weapon == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays -= src
usr.weapon = ""
usr << "You unequip the [src]."
else
if (src.shield == 1)
if (usr.shield == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays -= src
usr.shield = ""
usr << "You unequip the [src]."
else
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays -= src
usr << "You unequip the [src]."


Problem description: The code worked fine when I didn't add the Suffixs - The Overlay doesn't disappear if I unequip that item. Don't say this code don't work, as this is a code from a previous game of mine, but just adding those damn Suffixs.

I don't might if you shorten it. I just want the Overlay thing sorted.

In Unequiping, I placed the Suffix there as I thought they where causing the problem. (I thought they registered the same item different because of it)
That's is a horrible, horrible unequipping system. Anyhow, overlays kind of 'get stuck' to a character once you log out. So here's what you do;

mob
var/Overlays=list()
proc/update(obj/o)
src.overlays=null // Set overlays to nothing!
src.Overlays+=o // 'Overlays' (notice caps) list plus the object
for(var/i in Overlays) // For everything in 'Overlays'
src.overlays+=i


This is techinically plug and play. Instead of 'usr.overlays+=src', you now add 'usr.update(src)'.
In response to Mysame
It fixed the Computer (Whoops, said too much) being stuck on me after a small bug (Forgot to make it unequipable)..



But all other items still stick. I replaced the += ones as you said, and I also tried the whole lot.

UPDATE: If a item is stuck (unequiped as well), if you equip a new item that item gets unstuck. Something is dodgy.
Hmm the only problem with that I could imagine, is that the icon is in the overlays more than once. Try:
while(icon in usr.overlays)
usr.overlays-=icon
In response to CIB
I just noticed a clean-ass mistake - I put caps in Overlays (meant to be overlays)... But then it would of come up as a error. I don't remember no "Overlay" in any of my code...


I will try that code too CIB.

UPDATE: Both ideas seem to fail.
In response to RedlineM203
I gave you 'Overlay'. Re-read my code.
In response to Mysame
Oh. But still, it ain't working.

Current state...
        else
if (src.weapon == 1)
if (usr.weapon == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix)
while(src.icon in usr.overlays)
usr.overlays-=icon
usr.weapon = ""
usr << "You unequip the [src]."
else
if (src.shield == 1)
if (usr.shield == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix
while(src.icon in usr.overlays)
usr.overlays-=icon
usr.shield = ""
usr << "You unequip the [src]."
else
src.Equiped = 0
src.suffix="" // It's called suffix
while(src.icon in usr.overlays)
usr.overlays-=icon
usr << "You unequip the [src]."


I'm working on it as well too, so I might update.
In response to RedlineM203
You had to figure that the update() I gave you was for equipping only.
Anyway, to fix it;
mob
var/Overlays=list()
proc/update()
src.overlays=null
for(var/i in src.Overlays)
src.overlays+=i

Now you'd need to change
usr.update(src) into
usr.Overlays+=src;usr.update()
-- and in the UNEQUIP --
usr.Overlays-=src;usr.update()

Have fun..
In response to RedlineM203
Errmm... 2 other possibilities:
The icon of the equipment is being changed.
It isn't even being called up; to see if that's the case put
usr<<"Removing icon"
while(src.icon in usr.overlays)
usr.overlays-=icon

In response to Mysame
Fighter.dm:320:usr :warning: unused label
Fighter.dm:320:update :warning: unused label
Fighter.dm:332:usr :warning: unused label
Fighter.dm:332:update :warning: unused label
Fighter.dm:344:usr :warning: unused label
Fighter.dm:344:update :warning: unused label
Fighter.dm:16:usr :warning: unused label
Fighter.dm:16:update :warning: unused label
loading GameMap.dmp
saving World.dmb (DEBUG mode)




Basicly, its giving warnings everywhere there is a update().
In response to RedlineM203
Are you sure it's update() and not update without the brackets?
In response to CIB
You forgot the brackets, indeed.
In response to Mysame
Fighter.dm:16:error: usr: missing comma ',' or right-paren ')'
Fighter.dm:16:error: usr: expected end of statement
Fighter.dm:16:error: ): expected }
Fighter.dm:16:error: location of top-most unmatched {


First try, first bulls-

mob/BaseCamp/ChoosingCharacter
Login()
spawn()
usr.loc = locate(8,63,1)
usr.freeze = 1
world << "<b>[usr] has logged in.</b>"
usr << 'TitleMusic.mid'
return ..()
Logout()
(usr.Overlays-=src;usr.update)


Yes......
In response to RedlineM203
I mean brackets like:
   Logout()
usr.Overlays-=src;usr.update()
In response to CIB
What the hell are you doing. That code is supposed to be in the Unequiping code.
In response to Mysame
"-- and in the LOGOUT --
usr.Overlays-=src;usr.update()"


Thats what the hell I'm doing. Now how the hell did I miss those (good) brackets? Hell no... hehe.
In response to RedlineM203
Ugh, my bad -.-. Just do as I said and you'll be alright. God why did this take 9 posts? :|
In response to Mysame
The only reason this took (over) 9 posts is because the help don't work.


And you could say it made it worse... somehow, I don't know.
In response to RedlineM203
It DOES work, you need to use common sense. Ungh. Read the DM Guide / Demo's. There are PLENTY. Why bother us here for something there are about 50 demos on?
In response to Mysame
None include Overlay, and that is the reason we are here.

I'm not happy either. So far I made and deleted 23 "Redline" saves because of this bug.

        else
if (src.weapon == 1)
if (usr.weapon == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix)
usr.overlays-=src
usr.attack -= src.attack
usr.weapon = "Melee Ability"
usr << "You unequip the [src]."
else
if (src.shield == 1)
if (usr.shield == "[src]")
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays-=src
usr.defence -= src.defence
usr.shield = ""
usr << "You unequip the [src]."
else
src.Equiped = 0
src.suffix="" // It's called suffix
usr.overlays-=src
usr << "You unequip the [src]."


I like simple things, no matter how long as well.

You can call this "Back to square 1 Revised" - I still got...

mob
var/Overlays=list()
proc/update()
src.overlays=null
for(var/i in src.Overlays)
src.overlays+=i

mob/BaseCamp/ChoosingCharacter
Login()
spawn()
usr.loc = locate(8,63,1)
usr.freeze = 1
world << "<b>[usr] has logged in.</b>"
usr << 'TitleMusic.mid'
return ..()
Logout()
usr.Overlays-=src;usr.update()


And I found a small glitch in my weapon and shield unequips - I forgot to subtract the Player's strength/defence at the end.
Page: 1 2 3