1
Development / What does this error mean?
« Last post by lefthandedhero on Today at 02:39:32 AM »Recently, I created a script specifically for code related to the hero, that I called hero_meta. Here is the code that's currently in this script:
The purpose of this code is to establish a maximum distance away from the hero and create a table storing the hero's prior movements within that distance.
When I try to run the quest, I keep getting this error:
What does this error mean? Any idea what is causing it to occur?
Code: [Select]
local MAX_BUFFER_SIZE = 48
function hero:on_position_changed(x,y,z)
local hero = self
if not hero.position_buffer then hero.position_buffer = {} end
local hero = self
local dir = hero:get_sprite():get_direction()
table.insert(hero.position_buffer, 1, {x=x, y=y, layer=z, direction=dir})
if #hero.position_buffer > MAX_BUFFER_SIZE then
table.remove(hero.position_buffer)
end
end
The purpose of this code is to establish a maximum distance away from the hero and create a table storing the hero's prior movements within that distance.
When I try to run the quest, I keep getting this error:
Quote
Error: In main: scripts/meta/hero_meta.lua:2: attempt to index global 'hero' (a nil value)
What does this error mean? Any idea what is causing it to occur?