Jump to content

Prefabs not working correctly

Recommended Posts

When i use

local building = Prefab:Load("Prefabs/Buildings/"..pfbfile)


in my script, the Start function is not called and trying to call it manually with

building.script:Start() ends with an exception.



If i place it in the Map with the editor, the placed entity calls its start script, however

GetKeyValue("name") returns nothing.


When the Prefab is placed with the editor and i load another prefab with the script the loaded prefab calls its Start function and returns the correct GetKeyValue("name")



This issue might be related:




//Edited thread title as there is even a small bug when placing it with the editor.

Edited by beo6

Share this post

Link to post

Yes. i know that Thread, i thought it is obvious what the issue is. Sorry about that.


Have now created a project where i reproduced the issues. Hope that helps to fix them.




Press the Space key to call the Prefab:Load function.

the loading script part is in the gamecontroller.lua script.


There are two maps.


Where the prefab is already placed in the editor. There the prefab that was placed with the editor does not return the Name but the Start function is called. The by script loaded prefabs do return the name and Start is called.



this one is without a placed prefab in the map.

There the loaded prefabs do never call Start.


It seems that the Start function is not called when the first load has Prefab.NoStartCall as parameter.

Then the prefabs loaded after that do still not call the Start Script even if that parameter is missing or i explicitly set the parameter Map.LoadScripts

Share this post

Link to post

Okay, you just need to have Map.LoadScripts in your flags when the first Prefab::Load() command is called.

Share this post

Link to post




Prefab:Load("Prefabs/myprefab.pfb", Map.LoadScripts+Prefab.NoStartCall)


seems to work.


But it feels a bit odd since calling only



for the first time does load the script. So it is not really clear that Prefab.NoStartCall does completely prevent loading the script and not only just prevents calling the Start function.



//Edit: what about that prefabs placed by the editor do not return their entity name with

self.entity:GetKeyValue("name") ?

Edited by beo6

Share this post

Link to post

ok. thanks now it makes sence. :)


still GetKeyValue issue on Editor-placed prefabs.. ph34r.png

Share this post

Link to post

i haven't tried it again if the issue is fixed, but if it is not, too bad Josh is ignoring my posts. Maybe someone needs to post the issue again in a new thread. sleep.png

Share this post

Link to post

If you post a bug report with an example map that demonstrates a problem I will be happy to take a look. smile.png

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...