ID:139237
 
Code:
mob
Merchant
icon = 'TatsumotoTestOutfit.dmi'
verb
Talk()
set src in oview(1)
switch(alert("What would you like to do?","Shopkeeper","Buy","Cancel")) // \
pops open an alert which allows only 3 max options.

if("Buy") // if usr press buy this will enable the \
proc

switch(input("What would you like to buy?","Buy Item") in list ("Shorts","Shoes","Pants","Short Sleeved Shirt", "Long Sleeved Shirt", "Glasses", "Sunglasses", "Summer Dress", "Long Dress", "Skirt", "Kimono", "Blindfold", "Jumpsuit", "Bandolier", "Nevermind..."))
if("Shorts")
if(usr.gold<10) // if your gold is lower than 10 it will disallow you from purchasing it.
usr << "You cannot afford this!" // tells you, that you cannot buy it.
return
else // otherwish you can purchase it.
usr.gold -= 10 // subtracts 10 gold from your original
var/icon/Clothes= new('Clothing.dmi',"Shorts")
var/colorthing = input("What color do you want?") as color
Clothes.Blend(colorthing)
set src(/icon/Clothes)
src.Move(usr)
usr << "Thank you and come again!"
return


Problem description:
I am trying to adapt a Hair Color code with a color wheel to work so that it colorizes your Clothes however you want when you guy them. But I am running into problems. Any Ideas on how I should write this instead?
JaffaJoke wrote:
Code:
mob
> Merchant
> icon = 'TatsumotoTestOutfit.dmi'
> verb
> Talk()
> set src in oview(1)
> switch(alert("What would you like to do?","Shopkeeper","Buy","Cancel")) // \
> pops open an alert which allows only 3 max options.

> if("Buy") // if usr press buy this will enable the \
> proc

> switch(input("What would you like to buy?","Buy Item") in list ("Shorts","Shoes","Pants","Short Sleeved Shirt", "Long Sleeved Shirt", "Glasses", "Sunglasses", "Summer Dress", "Long Dress", "Skirt", "Kimono", "Blindfold", "Jumpsuit", "Bandolier", "Nevermind..."))
> if("Shorts")
> if(usr.gold<10) // if your gold is lower than 10 it will disallow you from purchasing it.
> usr << "You cannot afford this!" // tells you, that you cannot buy it.
> return
> else // otherwish you can purchase it.
> usr.gold -= 10 // subtracts 10 gold from your original
> var/icon/Clothes= new('Clothing.dmi',"Shorts")
> var/colorthing = input("What color do you want?") as color
> Clothes.Blend(colorthing)
> set src(/icon/Clothes)
> src.Move(usr)
> usr << "Thank you and come again!"
> return
>

Problem description:
I am trying to adapt a Hair Color code with a color wheel to work so that it colorizes your Clothes however you want when you guy them. But I am running into problems. Any Ideas on how I should write this instead?

What you have there won't work, mainly because src in this case is the clicked mob. Pretty sure you don't want to take the mob, now do you.

What you'll want to do is make an object for the shorts and modify that.

//this part creates an object type clothes, with a subtype
//of shorts. This saves you some code.
obj
Clothes
Shorts
icon = 'Clothing.dmi'
icon_state = "Shorts"

mob
Merchant
icon = 'TatsumotoTestOutfit.dmi'
verb
Talk()
set src in oview(1)
switch(alert("What would you like to do?","Shopkeeper","Buy","Cancel")) // \
pops open an alert which allows only 3 max options.

if("Buy") // if usr press buy this will enable the \
proc

switch(input("What would you like to buy?","Buy Item") in list ("Shorts","Shoes","Pants","Short Sleeved Shirt", "Long Sleeved Shirt", "Glasses", "Sunglasses", "Summer Dress", "Long Dress", "Skirt", "Kimono", "Blindfold", "Jumpsuit", "Bandolier", "Nevermind..."))
if("Shorts")
if(usr.gold<10) // if your gold is lower than 10 it will disallow you from purchasing it.
usr << "You cannot afford this!" // tells you, that you cannot buy it.
return
else // otherwish you can purchase it.
usr.gold -= 10 // subtracts 10 gold from your original
var/obj/Clothes/Shorts/S = new(usr) //create a new Shorts object, labelled S
//and puts it in the usr, which is the usr's contents
var/color = input("What color do you want your shorts?") as color
S.icon += color


This isn't tested because I'm at work, but it should be something like that.
In response to Pyro_dragons
mob
Merchant
icon = 'TatsumotoTestOutfit.dmi'
verb
Talk()
set src in oview(1)
switch(alert("What would you like to do?","Shopkeeper","Buy","Cancel")) // \
pops open an alert which allows only 3 max options.

if("Buy") // if usr press buy this will enable the \
proc

switch(input("What would you like to buy?","Buy Item") in list ("Shorts","Shoes","Pants","Short Sleeved Shirt", "Long Sleeved Shirt", "Glasses", "Sunglasses", "Summer Dress", "Long Dress", "Skirt", "Kimono", "Blindfold", "Jumpsuit", "Bandolier", "Nevermind..."))
if("Shorts")
if(usr.gold<10) // if your gold is lower than 10 it will disallow you from purchasing it.
usr << "You cannot afford this!" // tells you, that you cannot buy it.
return
else // otherwish you can purchase it.
usr.gold -= 10 // subtracts 10 gold from your original
var/obj/Clothes/Shorts/S = new(usr) //create a new Shorts object, labelled S
var/color = input("What color do you want your shorts?") as color
S.icon += color
usr << "Thank you and come again!"
return



Alright. Now im getting an error where it doesnt know what S. is

loading New Game Project.dme
Clothier.dm:20:error: S.icon: undefined type: S.icon
Clothier.dm:18:error: S: unknown variable type


Any ideas on how to define this?
In response to JaffaJoke
Simply copying and pasting my code won't work, of course. Especially when you only copy half of it.

Did you create a new object type? A Subtype? Did you give it those naming conventions? It's not finding it because it doesn't exist in your code. You need to make your own type(s) of object(s) and make the example work for you.
In response to Pyro_dragons
Alright, I got it to color the object and place it in the inventory. However, when the object is equipped the players Icon changes color as well. I think it might be an issue with the way its blending. I think its making usr's color blend
In response to JaffaJoke
We can't help you without seeing the related code. Please post it.
In response to Pyro_dragons
mob
Merchant
icon = 'TatsumotoTestOutfit.dmi'
verb
Talk()
set src in oview(1)
switch(alert("What would you like to do?","Shopkeeper","Buy","Cancel")) // \
pops open an alert which allows only 3 max options.

if("Buy") // if usr press buy this will enable the \
proc

switch(input("What would you like to buy?","Buy Item") in list ("Shorts","Shoes","Pants","Short Sleeved Shirt", "Long Sleeved Shirt", "Glasses", "Sunglasses", "Summer Dress", "Long Dress", "Skirt", "Kimono", "Blindfold", "Jumpsuit", "Bandolier", "Nevermind..."))
if("Shorts")
if(usr.gold<10) // if your gold is lower than 10 it will disallow you from purchasing it.
usr << "You cannot afford this!" // tells you, that you cannot buy it.
return
else // otherwish you can purchase it.
usr.gold -= 10 // subtracts 10 gold from your original
var/obj/Clothing/Shorts/A = new(usr) //create a new Shorts object, labelled S
var/color = input("What color do you want?") as color
A.icon += color
usr << "Thank you and come again!"
return


There is the code that I am looking at. I can ttell where the problem is because i am still shite at code. Sorry if Im being a little slow.
In response to JaffaJoke
You said that the problem lies when you equip the item. So, it should be within the equip code, correct? Post that.
In response to Pyro_dragons
obj
verb
Get()
set category=null //this makes sure it will be a hidden verb. Just right click to use the verb
set src in oview(1) //when you get close the Get verb shows up
src.Move(usr) //puts it in the inventory
usr << "<b>You picked up a [src]!<b>" //shows the user in text his actions
Drop()
set category=null
set src in usr //tells the verb where the item is
src.Move(usr.loc) //takes it out of the inventory and drops it where you are standing
usr << "<b>You dropped your [src]!<b>"

verb
Equip()
set category=null
set src in usr
if(usr.equip >= 15)
usr << "[src.name] is already equiped" //instead of typing the name just copy and paste this into where is needed.src.name will show Sword is already equiped!
else
usr.equip += 1
usr.overlays+=src.icon

suffix += "{-Equiped-}" //Makes the suffix appear beside it in the inventory tab
usr << "<b>You equip your [src.name].<b>"
Un_Equip()
set category=null
if(usr.equip == 0)
usr << "You don't have anything equiped"
else
suffix = "" //Note*This only works if you have 1 suffix
usr.equip -= 1
usr.overlays-=src.icon
usr << "<b>You place your [src.name] back into your inventory.<b>"


I think that the problem may be that when it colorizes the clothing it colors the enitre 32X32 square. then when it overlays it overlays that too.
In response to JaffaJoke
It shouldn't. I use a similar code for coloring the hair in my game. It doesn't effect the whole sprite.
In response to Pyro_dragons
Yeah, The hair is fine too. Might be as simple as the use of Usr to identify the location. Might just be makign it set the colorization to affect the usr
In response to JaffaJoke
Could be, but I'm not sure. Try changing the color first then moving the object into the usr after.
In response to Pyro_dragons
                            if("Shoes")
if(usr.gold<30) // if your gold is lower than 10 it will disallow you from purchasing it.
usr << "You cannot afford this!" // tells you, that you cannot buy it.
return
else // otherwish you can purchase it.

usr.gold -= 30 // subtracts 10 gold from your original
var/icon/Clothing/Shoes/S = new('Clothing.dmi',"Shoes")
var/colorthing = input("What color do you want?") as color
S.Blend(colorthing)
usr.contents+=S
usr << "Thank you and come again!"
return



Heres something else Im trying. But I cant get it to recognize the S.blend. I dont understand why, because it is no different from the Hair code.
In response to JaffaJoke
Anybody Else have Thoughts? Im abotu tapped out and I need this to work to finish My game. This is like litterally the last step. Ive put it off as long as I can.