klanphear Posted April 9, 2016 Share Posted April 9, 2016 Hello, I am trying to check the world for a prefab entity. I can retrieve the names for model entities but not the prefabs. If I change the name of the prefab(returning it to a model) it will get said value. I am trying to write a script in Lua to check if the "FPSPLayer" is present in the world, if the player is not present then create a camera. If I check for a model entity and it is present the camera is not created, if not present it creates the camera, so I know my script works just not for any prefab item. I have tried several prefabs with no avail. Models return "name" just fine. I found a function posted by Rick and modded it to use on a pivot with a key-press, thanks for all your posts have learned a lot. ty to all others who help in the forum also. function Script:Start() end function Script:UpdateWorld() if window:KeyHit(Key.I) then self:FindEntity() end end function Script:FindEntity(entityName) local x local world = World:GetCurrent() for x = 0, world:CountEntities() - 1 do local entity = world:GetEntity(x) System:Print("name = "..entity:GetKeyValue("name")) if entity:GetKeyValue("name") == entityName then return entity end end return nil end if I run this the output is listed below. I have the player prefab and controller prefab in the scene. I noticed CSG objects do not appear also with the exception of the Arch 1 which I did not rename. Loading shader "C:/Users/klanp_000/Documents/Leadwerks/Projects/test/Shaders/Model/Shadow/shadow.shader"... Loading shader "C:/Users/klanp_000/Documents/Leadwerks/Projects/test/Shaders/Lighting/directionallight.shader"... name = name = name = name = name = name = name = name = name = name = name = controller name = name = name = generic name = firepit name = brick name = Pivot 2 name = Arch 1 name = track_loader name = Directional Light Process Complete. any help appreciated, ty kirk Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 9, 2016 Share Posted April 9, 2016 CSG objects get collapsed when the level is loaded. This is done for performance. Try attaching an empty script or setting a mass to the csg brush and it should work. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.