ID:149918
 
This all started last night when my little bro wanted to make a game. So I helped him draw the icons, he came up with the ideas etc. He wanted different tabs for weapons, armor, shields etc. So this is what i did:
Stat()
statpanel("Status")
stat("Strength: ", str)
stat("Defense: ", def)
statpanel("Weapons")
stat(src.weapons)
statpanel("Shields")
stat(src.shields)
statpanel("Armor")
stat(src.armor)
statpanel("Inventory")
stat(src.contents)

Then I did this for the login code.
Login()
src.icon_state = input("What gender do you wish to be?") in list ("Male","Female")
src.Move(locate(1,1,1))
var/rstr = rand(1,5)
var/rdef = rand(1,5)
src.str = rstr
src.def = rdef
new/obj/Short_Sword(src.weapons)
new/obj/Wooden_Shield(src.shields)
new/obj/Short_Sword(usr)

When I login, there is a short sword in my inventory, but not in my weapons tab, no shield in the shield tab either. I tried it many different ways, but nothing worked. Can someone tell me what could be wrong?

Thanks.

-Rcet
Rcet wrote:
  new/obj/Short_Sword(src.weapons)
new/obj/Wooden_Shield(src.shields)
new/obj/Short_Sword(usr)

When I login, there is a short sword in my inventory, but not in my weapons tab, no shield in the shield tab either. I tried it many different ways, but nothing worked. Can someone tell me what could be wrong?

The short sword is being added to inventory because of the third line I've quoted there (although I'd say usr is unsafe here; use src). The other items aren't being set because you forget that the first argument to obj/New() is an atom, a place to put it. What you really need is this:
  weapons=new/obj/Short_Sword(src)
shields=new/obj/Wooden_Shield(src)

Both items should appear within your inventory, and now on their proper stat panels as well. I would recommend compressing your weapon and shield stat panels to one single equipment panel, though, because too many stat panels get in the way.

Lummox JR
In response to Lummox JR
Ok, I got that. Now I have this code:
Stat()
statpanel("Status")
stat("Strength: ", str)
stat("Defense: ", def)
statpanel("Equipment")
stat(src.equipment)


Login()
usr.icon_state = input("What gender do you wish to be?") in list ("Male","Female")
usr.Move(locate(1,1,1))
var/rstr = rand(1,5)
var/rdef = rand(1,5)
usr.str = rstr
usr.def = rdef
equipment=new/obj/Short_Sword(src)
equipment=new/obj/Wooden_Shield(src)

But it only creates a wooden shield in the equipment tab. How do i make it create both?

-Rcet
In response to Rcet
>       equipment=new/obj/Short_Sword(src)
> equipment=new/obj/Wooden_Shield(src)
>


equipment needs to be a list (if its not already). Then change this to:

>       equipment+=new/obj/Short_Sword(src)
> equipment+=new/obj/Wooden_Shield(src)
>


-AbyssDragon