ID:1869943
 
Code:
obj
clothes_grid
cloth1
name=""
icon='System Icons/Clothes/cloth1.dmi'
Click()
var/obj/T = new /obj/clothes/cloth1
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T
cloth2
name = ""
icon = 'System Icons/Clothes/cloth2.dmi'
Click()
var/obj/T = new /obj/clothes/cloth2
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T
cloth3
name = ""
icon = 'System Icons/Clothes/cloth3.dmi'
Click()
var/obj/T = new /obj/clothes/cloth3
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T
cloth4
name = ""
icon = 'System Icons/Clothes/cloth4.dmi'
Click()
var/obj/T = new /obj/clothes/cloth4
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T
cloth5
name = ""
icon = 'System Icons/Clothes/cloth5.dmi'
Click()
var/obj/T = new /obj/clothes/cloth5
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T


Problem description:

Instead of using the code that is seen above, and contiously spam creating those for like 100 Objects, couldn't I do something like this ? ( Look below. )






obj
clothes_grid
Click()
var/obj/T = new src
T += input(usr,"What colour would you like to colour this item.") as color
usr.contents += T
cloth1
name=""
icon='System Icons/Clothes/cloth1.dmi'
cloth2
name = ""
icon = 'System Icons/Clothes/cloth2.dmi'
Click()
cloth3
name = ""
icon = 'System Icons/Clothes/cloth3.dmi'
cloth4
name = ""
icon = 'System Icons/Clothes/cloth4.dmi'
cloth5
name = ""
icon = 'System Icons/Clothes/cloth5.dmi'


Yes sir/ma'am.
Yes, except for the fact that adding a color to an object doesn't work. You'd need to add or multiply that color to an icon.
In response to Lummox JR
Lummox JR wrote:
Yes, except for the fact that adding a color to an object doesn't work. You'd need to add or multiply that color to an icon.

What do you mean by it doesn't work because, it normally works when I use the code like that ?
I don't know about "object += color". Maybe you're thinking about "object.icon += color".

Also, in "var/obj/T = new src", "src" should instead be "type", unless there's some new feature that automatically reads the type of the object instead of failing. (Really, it should probably be "var/obj/T = new type (usr)" to get rid of that silly "usr.contents += T" line.)
Object += color will produce a type mismatch error. You want to add color to the icon, not the object.
In response to Lummox JR
Lummox JR wrote:
Object += color will produce a type mismatch error. You want to add color to the icon, not the object.

Kaiochao wrote:
I don't know about "object += color". Maybe you're thinking about "object.icon += color".

Also, in "var/obj/T = new src", "src" should instead be "type", unless there's some new feature that automatically reads the type of the object instead of failing. (Really, it should probably be "var/obj/T = new type (usr)" to get rid of that silly "usr.contents += T" line.)

Yeah, I looked at my code and actually realised the rubbish I was writing xD Sorry about that, I was tired when I made this part of my code. Thanks guys.
One thing I would suggest too: Don't actually use all those types. Instead, maybe load the options from a list or a file, which will be more extensible.
In response to Lummox JR
Lummox JR wrote:
One thing I would suggest too: Don't actually use all those types. Instead, maybe load the options from a list or a file, which will be more extensible.

How would you go about doing that ?
In response to AngelReincarnation
One simple way:

var/list/global_clothes_types = list(\
'System Icons/Clothes/cloth1.dmi',
'System Icons/Clothes/cloth2.dmi',
'System Icons/Clothes/cloth3.dmi',
'System Icons/Clothes/cloth4.dmi',
'System Icons/Clothes/cloth5.dmi')

When you load up your grid, just create different objs for each of those icons. Use the list length to define how the grid is laid out and if you need multiple pages, etc. This list could be extended at any time, and eventually could even be made to read from a file. Also, you could make the list associative like so:

var/list/global_clothes_types = list(\
'System Icons/Clothes/cloth1.dmi' = "shirt",
'System Icons/Clothes/cloth2.dmi' = "shirt",
'System Icons/Clothes/cloth3.dmi' = "pants",
'System Icons/Clothes/cloth4.dmi' = "hat",
'System Icons/Clothes/cloth5.dmi' = "hat")

If each icon represented a different article of clothing, the list could be used to categorize them so later on you could change the grid to be category-based. Just one possibility.
Have we sorted the color problem yet? I recommend making use of color var.
T.color = input(usr,"What colour would you like to colour this item.") as color

You may need to change all the icons color to base of white, this can be done by removing all contrast, it doesn't actually need hand picking every shade of grey. Although there may be a more simple way to do this that I am unaware of.

I'd like to think that if you're going to save those rgb colored clothing somewhere later, it'd be far better just use color var and not actually add rgb to an icon. Thankfully SOMEONE added this very useful variable called color, how convenient.

There is however one drawback to this method, the color won't display in statpanels, a workaround for this is to have a "folded" clothing state that'll appear in statpanels while wearing the item will have a different state.

If you wish me to elaborate further I can.
In response to Rotem12
Thanks for the help but, we've already sorted out the problem and I know exactly what you mean. Thank you very mcuh for your help and that includes everyone aswell.