Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

kertinker

How to do stuff during the creation of a prefab?

Recommended Posts

kertinker    200

I was under the impression that "prefabs" had a "fn" member, which was used to construct instances of that prefab. But doing this:

local prefab = GLOBAL.require "prefabs/walls" -- stone wall

local old = {
   fn = prefab.fn
}

local function fn(...)
   print("***************************** creating a stone wall")   
   local inst = old.fn(...)
   inst:AddComponent("named")
   inst:SetName("Hound bait")
   return inst
end
prefab.fn = fn
print("***************************** ready to create stone walls.")

The "ready to create" message is displayed successfully, but when I create a stone wall, my local "fn" is never called. It isn't called when I construct the wall, or when I place it. I've tried augmenting "fn" for stone walls, spears, and map scrolls, but it always does nothing.

Share this post


Link to post
Share on other sites
kertinker    200
18 hours ago, Cunning fox said:

inst:DoTaskInTime(0, fn)

That... wouldn't do stuff during the creation of a prefab. It'd have to be already created, if I already had inst to work with. I want to add stuff to instances created by a prefab, during their creation process.

Share this post


Link to post
Share on other sites