What does this error in my item script mean?

Started by lefthandedhero, January 26, 2024, 04:46:11 PM

Previous topic - Next topic
January 26, 2024, 04:46:11 PM Last Edit: February 18, 2024, 07:54:07 PM by lefthandedhero
I recently started making an item and one thing about this item is that, when the hero obtains the item, an entity appears near the hero. I saw that all item scripts have "local map = item:get_map()" near the top of the script, so, in my item:on_obtained() function, I wrote, "local hero = map:get_hero()" so that I could then obtain the hero's position for knowing where to place the entity. However, when I tested my code by having the hero obtain the item, I got this error message:

"attempt to index upvalue 'map' (a nil value)"

What does this error mean?

EDIT: I fixed the problem by adding, "local map = item:get_map()" to the function.