ID:159817
 
I am working on a non-combat RPG-like game in which I hope to have a lot of character customization allowed as well as many quests.

I have the bases of the characters made as well as some clothes, but I am not sure how to set up the code for picking up, dropping, wearing, and taking off clothes which will appear on the character.

I know layers are involved, but my coding skills are novice at best.

Could someone please help me?
obj
Shirt
icon = 'Shirt.dmi'
icon_state = "Shirt"
verb/Wear()
set src in usr // Make sure it's in you're inventory to drop it.
set category = null // So you have to right click the obj.
usr.overlays += /obj/Shirt/ // Adds the Shirt overlay.
usr << "You put on [src]."
verb/Take_Off()
set src in usr // Make sure it's in you're inventory to drop it.
set category = null // So you have to right click the obj.
usr.overlays -= /obj/Shirt/ // Deletes the Shirt overlay.
usr << "You take off [src]."
verb/Get()
set src in oview(1) // Make sure it's in you're oview 1.
set category = null // So you have to right click the obj.
src.Move(usr) // Moves the Shirt into you're inventory.
usr << "You pick up a [src]."
verb/Drop()
set src in usr // Make sure it's in you're inventory to drop it.
set category = null // So you have to right click the obj.
src.loc = locate(usr.x,usr.y,usr.z) // Puts the shirt under the player.
usr << "You drop [src]."


Hope this helps you out. =D
In response to Gizhy
Thanks! That should work fine.
In response to SladeJT
No problem, glad to help xD
In response to Gizhy
Will this also work with hair? I mean, if I alter the code to allow choice of hairstyle or base appearance when people log-in.
In response to SladeJT
/*THIS IS THE HAIR OBJECTS*/

obj
Hair1
icon = 'Hair.dmi'
icon_state = "hair"
Hair2
icon = 'Hair.dmi'
icon_state = "hair2"


/*THE LOGIN AS A TEST*/

mob
Login()
switch(input("What type of hair would you like?")in list("Hair 1","Hair 2")) // Makes a list to pick out of.
if("Hair 1")
usr.overlays += /obj/Hair1 // Gives them the hair overlay.
usr << "You picked Hair 1!"
if("Hair 2")
usr.overlays += /obj/Hair2 // Gives them the hair overlay.
usr << "You picked Hair 2!"


I made a login thingy to go with the hair to show you how to use it.
In response to Gizhy
Cool! Thanks again. I knew that you could have classes (in the case of combative games) chosen through the following sort of thing:

mob/player
        Login()
                world << " \red [usr] logs on!"
                alert("Welcome to the demo. This is a test to see if the game works fairly well.  Any suggestions to improve it are welcome.  Any reports of bugs or glitches are requested.  Thanks for your time.","Welcome","Ok")
                src.name = input("What is your name?","Name",src.key)
                var/a = input("What do you want to be?")in list("Swordsman","Cleric")
                if(a=="Swordsman")
                        usr.icon = 'Player.dmi'
                        usr.icon_state = "Fighter"
                        usr.Class = "Swordsman"
In response to SladeJT
You should use the:

switch(input("What class")in list("Warrior","Mage"))


I find that easier to use then:

var/a = input("What do you want to be?")in list("Swordsman","Cleric")
if(a=="Swordsman")
In response to Gizhy
Switch seems to imply just two choices. What if there's more than two?
In response to SladeJT
here is an example:

switch(input("You can have as many options as you desire")in list("1","2","3","4","5","6","7","8","9","10"))
if("1")
usr << "As many as you want =D"
if("2")
usr << "As many as you want =D"
if("3")
usr << "As many as you want =D"
if("4")
usr << "As many as you want =D"
if("5")
usr << "As many as you want =D"
if("6")
usr << "As many as you want =D"
if("7")
usr << "As many as you want =D"
if("8")
usr << "As many as you want =D"
if("9")
usr << "As many as you want =D"
if("10")
usr << "As many as you want =D"


You can have as many inputs as you want xD
In response to Gizhy
Ahh... Cool! That'll save length!
In response to SladeJT
Glad I could help, if you need anything else contact me on my MSN: [email protected]
In response to Gizhy
Thank you very much.
In response to SladeJT
No problem.
In response to Gizhy
Er, I have hit a little obstacle.

                                switch(input("Do you want shorts?")in list("Yes","No")).
                                        if("Yes")
                                                switch(input("What color?")in list("Red","Green","Yellow","Black","White","Blue")).
                                                        if("Red")
                                                                usr.overlays += /obj/Red_Shorts/
                                                                src.Move(usr) += /obj/Red_Shorts/ in usr

The last line is apparently incorrect. How do I make the clothes item appear in the inventory through the Login?
In response to SladeJT
At the Login() put:
mob
Login()
src.contents += new/obj/Red_Shorts
In response to Gizhy
Ah. Thanks.
In response to SladeJT
no prob.
In response to Gizhy
That's not really good.

You should define the verbs under something like /obj/equippable instead of just obj/Shirt. That helps with repeated code issue.

Another thing I noticed was:

src.loc = locate(usr.x,usr.y,usr.z)


Why not just equal it to usr.loc ? Or better yet, Move() it to usr.loc.
In response to SladeJT
It's also more efficient than multiple if()s.
Page: 1 2