Hey i have this code:
[lua]
function find_me(ply)
local schdRunner = ai_schedule.New( "AI Random Run" )
schdRunner:EngTask("TASK_GET_PATH_TO_ENEMY", 128) --RANDOM_NODE", 128)
schdRunner:EngTask("TASK_RUN_PATH", 0)
for k,v in pairs(ents.FindByClass("npc_combine_s")) do
Msg(k .. "- ")
v:StartSchedule(schdRunner) --line 11
Msg("Schedule Run!")
end
end
concommand.Add("findme", find_me)
[/lua]
But when i run the findme command i'm getting this error:
[code]
1- autorun/server/dropme.lua:11: attempt to call method 'StartSchedule' (a nil value)
[/code]
Which makes me think that if StartSchedule is a nil value that you cannot use it on normal npc's. Is this correct? or what am i doing wrong?
That is correct, but since your schedule consists of engine tasks it shouldn't be much of a problem.
Any idea why it does not work then?
Because they're not scripted in lua.
The only reason StartSchedule isn't available on NPCs is they don't derive from base_ai which is where those functions are defined. Those functions are merely wrappers; you could still call them on NPCs.
[url]http://luabin.foszor.com/code/gamemodes/base/entities/entities/base_ai/schedules.lua[/url]
[b]EDIT:[/b] Working now thanks.
Sorry, you need to Log In to post a reply to this thread.