ID:272405
 
Hello,

I'm trying to make clicking a object on the hud actually say something without editting the object on the hud's Click() itsself.

This is what I tried:
client
Click(O)
if(O==typesof(/obj/hud/))
usr<<"haha"
else
..()


I don't understand why it doesn't work, can anyone explain to me? And if possible post the fix?

Thank you for your time! This shouldn't be too big a problem.

Use istype():

<code>if(istype(O,/obj/hud)) usr << "haha"</code>
Prodigal Son wrote:
I'm trying to make clicking a object on the hud actually say something without editting the object on the hud's Click() itsself.

Why? It'd be more efficient to override the Click() proc only for the object you want to handle clicking of. It also eliminates the need for a type check.

I don't understand why it doesn't work, can anyone explain to me?

This stems from not understanding things before you use them. You should look things up in the DM Reference (also available from F1 in Dream Maker) etc to avoid this.
Let's dissect your if() statement:
It uses:
-'O', an argument var of the proc, containing an atom object
-'==', the equality operator
-'typesof()', a procedure that returns a list object containing types
(You should probably look those up)
Therefore, you are comparing an atom and a list, checking if they're equal. Since they're not equal (and can never be because they're different datatypes), the if() fails and your indented code doesn't execute.

And if possible post the fix?

For checking types, the type var or the istype() proc are used. The latter is often more recommended, however you should look them both up.
In response to DivineO'peanut
God, thanks, its just I been outta the DM language for so long, any programming language tbh. I totally forgot, thanks so much!