Solarus > Development


<< < (2/2)

If the only problem with the code is that it is calling a string, all you would need to do is take away the quotation marks.


--- Code: ---function npc_1:on_interaction_item(item_used)
  if item_used == boomerang then"secret")
--- End code ---

i just tried that and that doesn't work either....

I think what you're missing is fundamentally misunderstand what an "item" is in this context.

If I say x = 1
Then x is a number

If x = "boomerang"
Then x is a string

If x = y
Then x is whatever the variable y is.

Right now you're saying
`if item_used == x then`
But you haven't defined the variable x. You have to tell the code that by the variable x, you mean the equipment item named boomerang, so you need to use a game method to get that equipment item.

local x = game:get_item("boomerang")
if item_used == x then ...

Cheers bro I totally get what you're saying.

I did try a variation of this but i never got the "game:get_item("boomerang")" part of it.

what you wrote makes perfect sense thought and I've used that so many times on other things, nice explanation for anyone else that gets stuck on something like this.

and...yes those last 2 lines are indeed what i needed. thanks :)


[0] Message Index

[*] Previous page

Go to full version