[Solved] npc:on_interaction_item(item), small problems

Started by MetalZelda, August 08, 2016, 12:56:47 AM

Previous topic - Next topic
August 08, 2016, 12:56:47 AM Last Edit: August 08, 2016, 02:07:24 AM by MetalZelda
Hello !

I'm facing a strange anomaly while making some item interaction stuffs.
I do have worked all items and they work perfectly, now, i'm making some kind of interaction with NPC's (trading)

Problem is

Code (lua) Select
function trade_npc:on_interaction_item(item)
  print("Interacting, no item has been choosen yet")
  if item == "green_chuchu_counter" then
    print("Green Chuchu (Counter) is being shown to this NPC")
  end

end


on_interaction_item is called, problem is, I'm using the item green_chuchu_counter item, but

print("Green Chuchu (Counter) is being shown to this NPC")

is not called, I tested without the "" on the condition, doesn't work eigher.

Trying to get the item through print(item) prints a userdata, so it doesn't help a lot

Any help would be welcome

The item parameter is of type item, not string.

PS: when you are facing a userdata, use sol.main.get_type() to know the more precise Solarus type.

August 08, 2016, 01:33:32 AM #2 Last Edit: August 08, 2016, 01:40:05 AM by MetalZelda
Hmmm, there are nothing wrong, the type is 'item'. I tried without the "" but nothing happen, the condition is never triggered.

doing item_used:get_name() displays the correct item name though

Edit : I might have doe something wrong, brb