Hi guys, I've been trying to make a sensor which on activated a dialog will load from an NPC who will then walk off and vanish, I've tried to make it a save game variable so that the sensor and the NPC are gone forever after this. I can't seem to get my NPC to disappear when the map reloads, I realize the below will make him disappear when the sensor is activated again (which is what it is doing). Can anyone show me how to make it do what I need it to do. I tried lots of things but I can't seem to get it to work
local meeting_quest_1 = false
function meeting_sensor:on_activated()
if game:get_value("meeting_quest_1") then
worker_npc:remove()
else
game:start_dialog("meeting.1")
hero:freeze()
local path_movement = sol.movement.create("path")
path_movement:set_path({ 2, 2, 2, 2, 2, 1, 1, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 0, 0, 0 })
path_movement:set_ignore_obstacles(true)
worker_npc:is_traversable()
path_movement:set_speed(64)
path_movement:start(worker_npc, function()
worker_npc:remove()
game:set_value("meeting_quest_1", true)
hero:unfreeze()
end)
end
end
I kept getting these errors when i tried to get it working outside the sensor:on_activated
Error: attempt to index global 'worker_npc' (a nil value)
Error: attempt to index global 'meeting_sensor' (a nil value)
but as those are names of entities on my map...isnt that enough to use them just as : worker_npc:remove() ?
as in
map:on_started(function()
if game:get_value("meeting_quest_1") then
worker_npc:remove()