For example, I find that both delayedCall and timers will print errors in the console for an invalid target, when the script functions were defined in an onInit hook.
(Yet those functions can be called directly from other hooks, and even from the defined script itself.)
Code: Select all
--place and equip this object
defineObject{
name = "scripted_figure_skeleton",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/figure_skeleton.fbx",
},
{
class = "Item",
uiName = "Skeleton Figurine",
gfxIndex = 363,
description = "This figurine is crafted out of a single piece of pale bone.",
weight = 0.2,
onEquipItem = function(self)
self.go.script:test()
delayedCall(self.go.id, 1, "test")
end
},
{
class = "ScriptController", --or Null
onInit = function(self) self.go.script:setSource(
[[
function test2(caller)
if caller then
print("Test2 function was called via "..caller:getName()) end
end
function test(caller)
if caller then
print("Test function was called via "..caller:getName())
self.go.script:test2()
end
end
]])
end,
},
{class="Script"},
}
}