ID:176342
 
I wanted to know if there was a small code like that, that would flick an icon state on an NPC?
flick("state",NPC)
In response to Garthor
Thanks a bunch. :)

*edit
That tells me NPC is an udefined variable. O.o
In response to Jnco904
mob
NPC
icon = 'NPC.dmi'
density = 1
verb
Flick()
set src in view(1)
flick("Dance",src)
usr <<"[src]: Dance."
flick("Dance",usr)
usr <<"[usr]: Yeah,Dance!"
In response to Jnco904
That's because you haven't defined it.

Your main problem here is that you have no idea what you're doing... you're looking for "a bit of code" to do something, and what you're looking for is a puzzle piece or building block or something. You think you can make a whole game just by getting a bunch of these "pieces" from people, throwing them into a pile, and hoping that they manage to fit together.

It don't work that way.

You have "the code" you need... you put it your original post. It's the flick() proc. Problem is, you have no idea what flick() actually does or how it works. I'll tell you. You type flick(, and then you type an icon file or an icon state, and then you type a comma, and then you put in a variable that refers to the object whose icon you want to flick, then you put ). For example:

flick("attack",usr)

tells the computer to find the mob referred to as "usr", and briefly change its icon state to "attack".

flick("gasp",NPC)

tells the computer to find the mob referred to as "NPC", and briefly change its icon state to "gasp".

If you don't actually have a variable called NPC, this is a problem. You can declare a variable called NPC like this:

var/NPC

You can tell the computer that this "NPC" refers to a mob by doing it this way, though:

var/mob/NPC

The problem is, how do you tell the computer which mob this variable refers to? Chances are, you probably won't have to... you probably don't need to make a variable for this mob, because it's probably either the src or argument of the verb that you're making.

First thing you need to do... figure out exactly what causes the NPC to "flick." Is it something the player can do to any NPC? Is it something that the player can only do to this particular NPC? Or is it something that this NPC does on its own, independently of the player?

Second thing you need to do... having figured out what triggers the flick, you need to write the verb/proc. If this is something the player can do to any mob, a good way to do it is this:

mob/player/verb/poke(mob/m as mob in oview(1))
flick("poked",m)

This assumes that all your players are assigned to a mob of type "mob/player". Chagne that part to match whatever you're actually using. In this case, the player's mob can "poke" any other mob around them... the code refers to the mob being poked as "m".

If this is something that the NPC mob does on its own, you would need to put it somewhere in the NPC's code that's already being executed (like if you have an ongoing combat code, or "life cycle" code, or something that the NPC runs periodically automatically), and you just refer to the NPC as src:

flick("queasy",src)

If this is just something that the player can do to one particular type of NPC, refer to Siientx's example.
In response to Lesbian Assassin
Lesbian Assassin wrote:
That's because you haven't defined it.

Your main problem here is that you have no idea what you're doing... you're looking for "a bit of code" to do something, and what you're looking for is a puzzle piece or building block or something. You think you can make a whole game just by getting a bunch of these "pieces" from people, throwing them into a pile, and hoping that they manage to fit together.

It don't work that way.

I don't have any idea what I'm doing, that's why I'm asking if there is such a code. I know I could get the result I want if I make it an obj, but it would take up a lot more space then a tiny code like that. I have a hard time learning what a code does just by reading it's definition, so I take codes from the FAQ or libs and change them around to fit my needs. Sometimes it works sometimes it doesn't(obviously), but every time I learn something new such as the flick("state",usr). It was in some code and when I found out what it did I put that little bit of code and put it into one of my own codes that was formed from other little bits of code. I don't take full codes and put them in my game because I am trying to learn this language, not just make a game.

Also, the forum is a final resort for me. I would much rather be able to find this stuff out on my own, but until I learn more I will probably be here often.

You have "the code" you need... you put it your original post. It's the flick() proc. Problem is, you have no idea what flick() actually does or how it works. I'll tell you. You type flick(, and then you type an icon file or an icon state, and then you type a comma, and then you put in a variable that refers to the object whose icon you want to flick, then you put ). For example:

flick("attack",usr)

tells the computer to find the mob referred to as "usr", and briefly change its icon state to "attack".

flick("gasp",NPC)

tells the computer to find the mob referred to as "NPC", and briefly change its icon state to "gasp".

If you don't actually have a variable called NPC, this is a problem. You can declare a variable called NPC like this:

var/NPC

You can tell the computer that this "NPC" refers to a mob by doing it this way, though:

var/mob/NPC

The problem is, how do you tell the computer which mob this variable refers to? Chances are, you probably won't have to... you probably don't need to make a variable for this mob, because it's probably either the src or argument of the verb that you're making.

First thing you need to do... figure out exactly what causes the NPC to "flick." Is it something the player can do to any NPC? Is it something that the player can only do to this particular NPC? Or is it something that this NPC does on its own, independently of the player?

Second thing you need to do... having figured out what triggers the flick, you need to write the verb/proc. If this is something the player can do to any mob, a good way to do it is this:

mob/player/verb/poke(mob/m as mob in oview(1))
flick("poked",m)

This assumes that all your players are assigned to a mob of type "mob/player". Chagne that part to match whatever you're actually using. In this case, the player's mob can "poke" any other mob around them... the code refers to the mob being poked as "m".

If this is something that the NPC mob does on its own, you would need to put it somewhere in the NPC's code that's already being executed (like if you have an ongoing combat code, or "life cycle" code, or something that the NPC runs periodically automatically), and you just refer to the NPC as src:

flick("queasy",src)

If this is just something that the player can do to one particular type of NPC, refer to Siientx's example.

This is a lot better than the definitions in DM, thanks.
In response to Jnco904
If you want to learn how to code, you really need to learn how to read the definitions. I didn't provide any information here that isn't in the F1 file on flick().
In response to Lesbian Assassin
Lesbian Assassin wrote:
If you want to learn how to code, you really need to learn how to read the definitions. I didn't provide any information here that isn't in the F1 file on flick().

I'm guessing you have never seen the FAQ or asked questions on the forum to figure something out. That is what I am doing only I have a lot to figure out right now. :)