kertinker Posted March 12, 2018 Share Posted March 12, 2018 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. Link to comment Share on other sites More sharing options...
Cunning fox Posted March 13, 2018 Share Posted March 13, 2018 inst:DoTaskInTime(0, fn) 1 Link to comment Share on other sites More sharing options...
kertinker Posted March 14, 2018 Author Share Posted March 14, 2018 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. Link to comment Share on other sites More sharing options...
CarlZalph Posted March 16, 2018 Share Posted March 16, 2018 See: AddPrefabPostInit. Link to comment Share on other sites More sharing options...
kertinker Posted March 16, 2018 Author Share Posted March 16, 2018 2 hours ago, CarlZalph said: See: AddPrefabPostInit. AddPrefabPostInit did it. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now