ID:156756
 
Allo. So i have been working on making my inventory/equip system atm and ive come to the point where i want to be able to change an items colour. but im not quite sure how i would go about this cause my system is a bit odd, so i decided to consult the forums and all their wisdom.

so first things first ill throw some code out here so you can see what kind of system im using. (do note it is basically a direct rip from my objects.dm and world.dm)
//first snip is the builder which makes all my overlays.
//the if statements after the eye and hair grab information from a list made (shown in other snip) and then output the icon etc of that object.
var/list/hair_types = list("bald" = 'blank.dmi', "kakashi" = 'Hair_Kakashi.dmi', "deidara" = 'Hair_Deidara.dmi')
mob/proc/Overlay_Build()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye

if(equipped["head"]) L += equipped["head"]
if(equipped["heada1"]) L += equipped["heada1"]
if(equipped["heada2"]) L += equipped["heada2"]
if(equipped["shirt"]) L += equipped["shirt"]
if(equipped["pants"]) L += equipped["pants"]
if(equipped["overalls"]) L += equipped["overalls"]
if(equipped["shoes"]) L += equipped["shoes"]
if(equipped["special"]) L += equipped["special"]
if(equipped["weapon"]) L += equipped["weapon"]

src.overlays = L
//////////////
//direct cut from my objects thing since i think it all may be relevant.
//////
mob/proc/UpdateInventory()
var/items = 0
for(var/obj/items/O in src)
if(equipment && O.islot && equipment[O.islot]==O)
continue // don't show equipped items
winset(src, "inventory", "current-cell=[++items]")
src << output(O, "inventory")
winset(src, "inventory", "cells=[items]") // cut off any remaining cells


mob/proc/EquipGridder(var/type, var/grid) //first part to the below thing.
var/list/Empty = list("overalls" = "D","shirt" = "Z")

if(isnull(equipment["[type]"]))
src << output(Empty["[type]"], "[grid]")
else
src << output(equipment["[type]"], "[grid]")

mob/proc/UpdateEquipment() //really bad and unworking output thing basically for outputting stuff to grids. i need to change this.
src.EquipGridder("shirt", "grid1")
src.EquipGridder("overalls", "grid2")
src.EquipGridder("weapon", "grid3")


mob
proc/Equip(obj/items/O)
if(!O || !O.islot) return
if(equipment && equipment[O.islot])
Unequip(equipment[O.islot])
if(equipment && equipment[O.islot]) return // unequip failed
if(!equipment) equipment = new
equipment[O.islot] = O
src.equipped[O.islot] = O.refe
src << output("You equip <font color = [RarityList["[O.rarity]"]]>[O]</font>.","balog")
src.str += O.strbonus
src.agi += O.agibonus
src.int += O.intbonus

UpdateInventory()
UpdateEquipment()
Overlay_Build()

proc/Unequip(obj/items/O)
var/mob/player = usr
if(!O || !O.islot) return
if(!equipment || equipment[O.islot]!=O) return // failed
equipment -= O.islot
if(!equipment.len) equipment = null // reclaim the list
player.equipped[O.islot] = 0
src << output("You unequip <font color = [RarityList["[O.rarity]"]]>[O]</font>.","balog")
src.str -= O.strbonus
src.agi -= O.agibonus
src.int -= O.intbonus
UpdateInventory()
UpdateEquipment()
Overlay_Build()

var/list/RarityList = list("Junk" = "gray", "Common" = "white", "Uncommon" = "green", "Rare" = "blue", "Epic" = "purple", "Legendary" = "yellow")
var/list/AffinityList = list("Sky" = "lightblue", "Rain" = "blue", "Storm" = "red", "Sun" = "yellow", "Mist" = "purple","Cloud" = "purple","Thunder" = "green")

obj/items
var/islot
var/refe
var/code
var/strbonus = 0, agibonus = 0, intbonus = 0, levreq = 0, affinityreq
var/rarity
verb/Get()
set src in oview(1)
if(src in oview(1)) // sanity check; the verb could come in late
loc = usr
usr << "You pick up <font color = [RarityList["[src.rarity]"]]>[src]</font>."
oview() << "[usr] picks up \a <font color = [RarityList["[src.rarity]"]]>[src]</font>."
usr.UpdateInventory()

verb/Drop()
set src in usr
if(src in usr) // sanity check; the verb could come in late
if(IsEquipped())
usr.Unequip(src)
if(IsEquipped()) return // unequip failed
loc = usr.loc
usr << "You drop <font color = [RarityList["[src.rarity]"]]>[src]</font>."
oview() << "[usr] drops \a <font color = [RarityList["[src.rarity]"]]>[src]</font>."
usr.UpdateInventory()
usr.UpdateEquipment()



proc/IsEquipped()
if(islot)
var/mob/M = loc
if(ismob(M) && M.equipment && M.equipment[islot] == src)
return 1
return 0

proc/IsReq()
var/AfReq, LReq
if(isnull(src.affinityreq))
AfReq = 1
else if(src.affinityreq == usr.Affinity)
AfReq = 1
else
AfReq = 0
if(usr.level >= src.levreq)
LReq = 1
else
LReq = 0

if(AfReq == 1 && LReq == 1)
return 1
else
return 0

proc/Use()
..()

Clothing //Define Clothes
Use()
set hidden = 1
if(src in usr)
if(IsReq())
if(IsEquipped())
usr.Unequip(src)
else
usr.Equip(src)
else
usr << output("<font color = [RarityList["[src.rarity]"]]>[src]</font> requires the \
<font color =
[AffinityList["[src.affinityreq]"]]>[src.affinityreq] Affinity</font> and Level [src.levreq] to equip.", "balog")

Click()
Use()

pants

shirts
testshirt
icon = 'CShirt_Lightning.dmi'
icon_state = "invent"
islot = "shirt"
refe = /obj/iconholders/shirts/testshirt
code = 3
rarity = "Common"

overalls
Suit
icon = 'SuitBlack.dmi'
icon_state = "invent"
name = "Suit of The Gods"
islot = "overalls"
refe = /obj/iconholders/overalls/suit
code = 1
strbonus = 700
agibonus = 700
intbonus = 700
rarity = "Legendary"
levreq = 1
affinityreq = "Thunder"

////////////
//and finally this is the icons that gets linked to by each individual icons "refe" var.
/////
//All object holders will be here as there will be a large list and therefore may get bulky
obj/iconholders
var/code
weapons
layer = FLOAT_LAYER-1
hidan
icon = 'Icons/Weapons/Hidansscythe.dmi'

shirts
layer = FLOAT_LAYER-3
testshirt
icon = 'CShirt_Lightning.dmi'
code = 3

headgear
layer = FLOAT_LAYER-2

pants
layer = FLOAT_LAYER-4
overalls
layer = FLOAT_LAYER-2
suit
icon = 'SuitBlack.dmi'
code = 1
suit2
icon = 'CShirt_Lightning.dmi'
code = 2


So does anyone have any ideas on how i would go about making items then be able to get a colour selection.

I know i can add an additional variable to each item to see if there allowed to RGB in the first place (since some will not be allowed to be recoloured) and thats easy enough. so is making the colour box show up. (since ive done all that for char creation)

The problem is just how id make colours selected (if someone decided to change the colour from the default black to w.e) stick to that object. and then be rebuilt when the olay proc is called.

And also, is this method of doing things alright or am i doing it wrong?


EDIT: There is already an option for colouring added to certain items and there is a root variable for all objects noted as colour. thats changed when they RGB it saves in the content list and is then dragged over to the "equipment" list when its equipped. but after that im not sure what needs to be done =\
Bump.

This was posted on the 31st. and it is now the 3rd. ive tried different things but i cant seem to figure it out.

so far my attempts have returned all kinds of errors.

Such as: type mismatch, cannot read and an (well not an error but just a fail to work)
In response to Midgetbuster
Try using the forum search function to find things you are looking for.

http://www.byond.com/developer/forum/?id=239673&view=1

http://www.byond.com/developer/forum/?query=RGB+items

You will find you can obtain the answer yourself, instead of expecting someone to help you out here. (Which hardly ever happens).
In response to UmbrousSoul
Sure enough its easy enough to pull the icon from the "refe" directory of the equipped item since thats all listed.

The problem is pulling the colour variable from the equipment list and then adding it to that object. i know i could use var/icon for blend etc but this needs to be run for 10 or so layers and thus would need a code that would ensure a low time so that it does not cause lag since its called on a regular basis (char create, login, saving, etc etc.)

ive also tried different alterations etc but i always get errored. meh, ill go to sleep and try some more later.
In response to Midgetbuster
Don't know if this will help but try searching the forums for different keywords. I found this...

http://www.byond.com/developer/forum/?query=adding+rgb

-Update Here I just put in a search for you
There are a couple of posts about RGB/ RGB to items/icons/etc.
In response to UmbrousSoul
Well the only reason i came was to try and find out how to do it. since i use a round about way of doing things instead of straight forward placement etc. and every attempt ive tried so far seems to not like me..


runtime error: type mismatch: /obj/iconholders/overalls/suit... (/obj/iconholders/overalls/suit2) + "#ff9999"
proc name: Overlay Build (/mob/proc/Overlay_Build)
source file: B. World.dm,156
usr: Logga (/mob/human/player)
src: Logga (/mob/human/player)
call stack:
Logga (/mob/human/player): Overlay Build()
Logga (/mob/human/player): Read(Saves/m/midgetbuster.sav (/savefile))
Midgetbuster (/client): Load("1")
LoadPro(1)
LoadSlotOne()

//
runtime error: Cannot read /obj/iconholders/overalls/suit... (/obj/iconholders/overalls/suit2).colour
proc name: Overlay Build (/mob/proc/Overlay_Build)
source file: B. World.dm,153
usr: Logga (/mob/human/player)
src: Logga (/mob/human/player)
call stack:
Logga (/mob/human/player): Overlay Build()
Logga (/mob/human/player): Read(Saves/m/midgetbuster.sav (/savefile))
Midgetbuster (/client): Load("1")
LoadPro(1)
LoadSlotOne()
//
runtime error: type mismatch: Blug (/obj/items/Clothing/overalls/Blug) += "#990099"
proc name: Overlay Build (/mob/proc/Overlay_Build)
source file: B. World.dm,153
usr: Logga (/mob/human/player)
src: Logga (/mob/human/player)
call stack:
Logga (/mob/human/player): Overlay Build()
Logga (/mob/human/player): Read(Saves/m/midgetbuster.sav (/savefile))
Midgetbuster (/client): Load("1")
LoadPro(1)
LoadSlotOne()


ive tryed making my equipment list that holds the link to the main icon have an additional string in there to also hold the colour of an object. sure i can get it to pull the colour out and the icon out. but soon as i try to merge them. WHAMMY error plaza
In response to Midgetbuster
What if you try applying the color before pulling the icon?
In response to UmbrousSoul
im not quite sure what your getting at. If you look at my original post each item has a new object called iconholders that handles the actual icon of the object whereas the object itself holds all the values and the state in which appears for the inventory.

i tried adding in an additional line of code under the part that sorts the equipments location to also include that of the colour but as i said i continously get type mismatches and other forms of errors. ive tried setting it as an icon var obj var etc but to no avail so far. =\
In response to Midgetbuster
Well i'm just making random jabs at the problem I have no idea what it could actually be or the fix for that matter.

Basically what I am trying to say is perhaps there is a way to go about it that will work, and ways to go about it that won't work. Maybe you can't pull out the icon and then the color and merge them, perhaps you have to assign the color before trying to use the icon, all just simple speculation on my part. I really do wish I could help you out more than this.

I wish someone else would post to help you out already because i'm just leading you on at this point, unintentionally of course.

Best thing I can do for you is use the forum search function and find stuff like this:

http://www.byond.com/developer/forum/?id=321883

http://www.byond.com/developer/forum/?query=RGB+item
In response to UmbrousSoul
Well i know how to like get the colour and all working. i tried making a list like my hair list etc and it works fine like that no worries but the problem is that i need to be able to pull the imagery from the iconholders of objects that matches that of the object in questions reference. and then add the colour. the colour is basically easy its just having problems taking the imagery of the iconholders and then smashing a colour with it

like this is what one my save files looks like atm.

Slot1 = object(".0")
.0
type = /mob/human/player
savefile_version = 1
Affinity = "Cloud"
stamina = 50
colour_hair = "#177B9F"
type_hair = "deidara"
equipment = list("head","weapon","overalls" = object(".0"))
.0
type = /obj/items/Clothing/overalls/Blug
colour = "#ff00ff"
equipped = list("overalls" = /obj/iconholders/overalls/suit2,"shirt" = 0,"overallsc" = "#ff00ff")
slot = 1
created = 1
name = "Logga"
SavedX = 19
contents = list(object("../equipment/.0"),object(".0"))
.0
type = /obj/items/Clothing/overalls/Suit
key = "Midgetbuster"
SavedY = 13
SavedZ = 2


var/list/testov = list("suit" = 'SuitBlack.dmi')
mob/proc/Overlay_Build()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye
for(var/islot in equipment)
if(equipped["head"]) L += equipped["head"]
if(equipped["heada1"]) L += equipped["heada1"]
if(equipped["heada2"]) L += equipped["heada2"]
if(equipped["shirt"]) L += equipped["shirt"]
if(equipped["pants"]) L += equipped["pants"]
if(equipped["overalls"])// L += equipped["overalls"]
var/testov2 = testov["suit"] + equipped["overallsc"]
// var/A = equipped["overalls"] + equipped["overallsc"]
// var/icon/A = equipped["overalls"]
// A.Blend(equipped["overallsc"],ICON_ADD)
L += testov2

if(equipped["shoes"]) L += equipped["shoes"]
if(equipped["special"]) L += equipped["special"]
if(equipped["weapon"]) L += equipped["weapon"]

src.overlays = L

as you can see by those things i can pull the colour out of the equipped list by adding another simple line of code in the equip line which is no problems or if i add an extra variable into the re builder i can pull it directly from the equipment list.

the problem is it just hates reading the refe thing. i understand that its a type path and what not by i dont understand why a type path can be formed perfectly in those other statements but give mismatches etc in any other case. there must be a way ive done wrong and as you can see by the commented out code ive tried a number of things but i must be missing something =\

Basically i need to.

1. Pull the type path from the equipped list as noted by the other if statements shown.
2. Pull the colour from the equipment list or leave it as is and pull it from the equipped list.
then 3. smash the 2 together and output.
In response to Midgetbuster
Have you ever used one of those html2color files? It can transform the color codes into text, maybe that will work?

My only guess is its having a problem reading the color code or something, I don't know at this point. Hopefully someone can help you out more then I can
In response to UmbrousSoul
Nah its grabbing the colour fine since its just a matter of pulling an objects "colour" var thats predefined for all objects as black. thats all set. and i can change it fine which is also easy and it gets pulled out of the list perfectly fine.

The problem is occuring when im trying to put the colour together with that of the type path of the objects "refe" variable which links to a new object all together in which (is meant to) handle the layering of said objects. the reason i use a new object altogether is because im not quite sure how to switch the icon from an "inventory" state and a "player" state freely. and IMO i think its easier but i could be wrong i guess
In response to Midgetbuster
My only advice is to use the forums search function as much as you can and search for all the keywords that relate to your subject, even things like "object overlays" and what not. I remember reading a post about objects overlays in that you can't do certain things but you can apply it to said over/underlay.

Theres a decades worth of questions in the archive so there is bound to be some info on this somewhere.

Perhaps you shouldn't be making a new object but obtaining the used object and changing that? I really don't know.
In response to Midgetbuster
You are attempting to add a color to an atom. You cannot do this. You can only add color to icon objects.
In response to Garthor
how would i go about transferring the atom to and icon so i could then add the colour to it before adding it to said list for adding to overlays?
In response to Midgetbuster
You don't transfer an /atom to an /icon, you make a variable with the type /icon, refer it to the /atom.icon, do your changing, set the /atom.icon to the modified one by /atom.icon = icon variable you chose... and there you go >_>
In response to GhostAnime
Hmm.

Im not quite reading the process right.

mob/proc/Overlay_Build()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye
for(var/islot in equipment)
if(equipped["head"]) L += equipped["head"]
if(equipped["heada1"]) L += equipped["heada1"]
if(equipped["heada2"]) L += equipped["heada2"]
if(equipped["shirt"]) L += equipped["shirt"]
if(equipped["pants"]) L += equipped["pants"]
if(equipped["overalls"])// L += equipped["overalls"]
var/icon/O
var/atom/Z = equipped["overalls"]
O = Z.icon + equipped["overallsc"]

L += O

if(equipped["shoes"]) L += equipped["shoes"]
if(equipped["special"]) L += equipped["special"]
if(equipped["weapon"]) L += equipped["weapon"]

src.overlays = L


obviously thats wrong cause its probably doin the exact same thing as my previous attempts =\.

Not quite sure on how to go about it though :(
In response to Midgetbuster
Here's a bare-bone skeleton of what I said. I forgot to mention about icon.Blend,... but you can figure out how to read that
var/icon/Icon variable = new(object.icon)  //  Forgot how to make a new instance of an /icon with your wanted icon
Icon variable.Blend(Read DM reference about the arguments)
object.icon = Icon variable
In response to GhostAnime
Im sorry. im utterly hopeless at this.

(i understand the part about blend perfectly and kinda figured that was meant to be in there anyway)

But the rest is just blurry and just plain refuses to work with me.

first thing i tried was putting in that "new" thing for the icon variable.

mob/proc/Overlay_Build()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye
for(var/islot in equipment)
if(equipped["head"]) L += equipped["head"]
if(equipped["heada1"]) L += equipped["heada1"]
if(equipped["heada2"]) L += equipped["heada2"]
if(equipped["shirt"]) L += equipped["shirt"]
if(equipped["pants"]) L += equipped["pants"]
if(equipped["overalls"])// L += equipped["overalls"]
var/icon/O = new(equipped["overalls"])
L += O

if(equipped["shoes"]) L += equipped["shoes"]
if(equipped["special"]) L += equipped["special"]
if(equipped["weapon"]) L += equipped["weapon"]

src.overlays = L
//This returns
//runtime error: bad icon operation

next i tried it without the new. which places the icon on the player perfectly. (this is without going any further into the code)

so the next thing (after removing the new) is to try and blend.

//error returned
//runtime error: Cannot execute null.Blend().

mob/proc/Overlay_Build()
var/L[0]
var/hair = hair_types[type_hair || "bald"] + colour_hair
var/eye = 'Eyes_Base.dmi' + colour_eye
L += hair
L += eye
for(var/islot in equipment)
if(equipped["head"]) L += equipped["head"]
if(equipped["heada1"]) L += equipped["heada1"]
if(equipped["heada2"]) L += equipped["heada2"]
if(equipped["shirt"]) L += equipped["shirt"]
if(equipped["pants"]) L += equipped["pants"]
if(equipped["overalls"])// L += equipped["overalls"]
var/icon/O = equipped["overalls"]
O.Blend(equipped["overallsc"])
L += O

if(equipped["shoes"]) L += equipped["shoes"]
if(equipped["special"]) L += equipped["special"]
if(equipped["weapon"]) L += equipped["weapon"]

src.overlays = L


heres a copy of the save file

Slot1 = object(".0")
.0
type = /mob/human/player
savefile_version = 1
Affinity = "Sun"
stamina = 50
colour_hair = "#E665A6"
type_hair = "deidara"
equipment = list("overalls" = object(".0"))
.0
type = /obj/items/Clothing/overalls/Blug
colour = "#993366" //overallsc originates from here
equipped = list("overalls" = /obj/iconholders/overalls/suit2,"overallsc" = "#993366") //as you can see by the equipped list it holds a location to an object shown below.
slot = 1
created = 1
name = "Midget"
SavedX = 14
contents = list(object("../equipment/.0"))
key = "Midgetbuster"
SavedY = 17
SavedZ = 2

////
obj/iconholders
var/code
overalls
layer = FLOAT_LAYER-2
suit2
icon = 'SuitBlack.dmi'
code = 2
In response to Midgetbuster
You are saving a type path in the savefile. Adding a type path to overlays is a valid action, as it pulls the appearance data from the code tree. Blending colors with it is not a valid action. You will need to create a new object of that type using new() first. The syntax would be new equipped["overalls"](), not new(equipped["overalls"]): the second passes the type as an argument to New(), the first using the variable as the type of the object to create.

Also: you'll get an obj out of this, not an icon. You THEN need to grab its icon.
Page: 1 2