Code:mob/barber
icon='Barber.dmi'
name="Barber"
mob/barber/verb
Haircut()
set src in view(1)
switch(input("Would you like a haircut?")in list("Yes","No"))
if("Yes")
switch(input in list("Afro"))
if("Afro")
set overlays+='afro.dmi'
obj/Hair
Afro
icon='afro.dmi'
Problem description:Cant seem to make a working barber code,have tried many things,the code i used is just one of the many i tried,plz help me a little here
Your problem lies within the line:
switch(input in list("Afro")) See if you can see what you did wrong here. |
In response to JEY_SENSEY
|
|
JEY_SENSEY wrote:
1-should place the code within the code (<)dm(>) code (<)/dm>(/) {whitouts ()} Not really helping if you're judging him on a NPC he wants to have in his game. |
In response to Howey
|
|
I was editing my post to be more specific ¬ ¬ |
ok check this out Jordan35 what I did was to use a DblClick() to to interact with the npcs:
mob/barber and use some variables and a one proc() to select the color of your hair mob Greetings, jey sensey |
In response to JEY_SENSEY
|
|
JEY_SENSEY, I think you need to take some time to learn good code concepts. You have posted many bad examples that really complete simple concepts recently.
Always increase Re-usability, and decrease Redundancy. Use Encapsulation, the language is built for it. Become Organized with you code, and use the most efficient methods to get the job done. Remove code that adds no meaning. Finally, learn the concepts of the language. You abuse usr far to much to prove you know how the language works. |
In response to Pirion
|
|
okey thanks so much...
apparently not enough to help, you have to be perfect, nobody is,neither are their codes pirion,is the last time I help in this way bye bye... |
He gave you good advice. Basically imagine the steps it would take to add more hair selections to your code and decrease them.
|
That code can be improved a lot though - Pirion is trying to help him as well as you; no one here is bashing and he shouldn't be offended.
That's 6 vars under mob, two of which I don't see actually used, 5 of them don't need to exist. He uses an alert for bald and afro which should be an input. There's a bit of needless switching going on. Overall it looks like bit and pieces of two different methods. mob/barber Now for cool stuff. If you do not want to set the states personally, and make it so you just have to add new icon states into the dmi to add more hairs to the game, use: var/list/Hairs = icon_states('Hair.dmi') Note: for the icon_states() method the current example expects the Hair.dmi to only contain hair states. If you want hair states to be mixed with other states you're going to have to make a proc to filter the icon_states. The above example also makes use of the color var and that only works with white icons. |
well it seems that the code doesnt work,but i really thank jey_sensey for his help,and i dont want to bash anyone and thanks for help,will try to figure this on my own
Jittai ty |
My code?. I have it in a test environment right now and it works.
Edit: I copied the color proc wrong and it would prevent compiling, fixed. The errors were very minimal, if you have issues troubleshooting those errors I suspect you are just copy paste dumping stuff others give you which is not a good way to learn. If you have any questions please ask - I'm sure my method could even be improved upon. Tip for you Jordan35. Instead of using /obj/ for overlays use images. They're purely visual but carry layers, names, and anything else you might need for overlay systems. Plus images can have their own overlays as well. |
In response to Jittai
|
|
yeah your code works,just one question,every hairstyle i have has many states,so if i put them all in one hair.dmi how will i let the code know which one to get?
And no i dont copy paste,i just get the code use it once to see how it orks,and then try to to create something that works the same with what i know |
You mean states like jumping, punching or such? If so, then you're going to have to rework how the images are created and avoid using the icon_states() trick.
Worst case scenario you may have to have each hair in its own icon. usr.hair = image('Hair.dmi',hair_state,layer=MOB_LAYER+0.01) -> usr.hair = image(file("[hair_state].dmi"),layer=MOB_LAYER+0.01) hair = image('Hair.dmi',hair.name,layer=MOB_LAYER+0.01) -> hair = image(file("[hair.name].dmi"),layer=MOB_LAYER+0.01 Changing those two lines allows for multiple states per hair, like dead or punching or whatever. But you need to have one hair per icon. |
In response to Jittai
|
|
Yeah these kind of states,i am thinking on adding a number in the front of states names,so i can use (if) and set which type of hair get which states,could that work?
|
I told you how to make it work. In each icon you just need the same state names as the poses for mobs.
Mob icon has states: default, running, dead Hair icons have: default, running, dead |
In response to Jittai
|
|
ah got it,thank you very much for your help
|
In response to Jittai
|
|
Jittai wrote:
mob/barber if you move the check a little higher you can remove a little redundancy and the need for a bald.dmi. |
2- who wants to make a verb that can change someone's hair or an npc that will interact with the hair change someone?
if npcs is a need to put a proc interaction can be Click() or Dblclick()