Jump to content

World::FindEntity returns NULL


martyj
 Share

Recommended Posts

Here is the list of entities in my world

https://imgur.com/a/tPRa6

When I run the following code in Lua, it returns NULL

local world = World:GetCurrent()
CaveIn2_ATrappedMiner.boundingBox = world:FindEntity("EndAsdfgwg")

if CaveIn2_ATrappedMiner.boundingBox == nil then
	System:Print("Null bounding box")
	return
end

When I run the following code it returns the Entity as expected

CaveIn2_ATrappedMiner.rubble = world:FindEntity("Rubble")

When I loop through all the entities and print their name, EndAsdfgwg isn't listed in the World

Any ideas as to what I am doing wrong?

Link to comment
Share on other sites

App:FindEntity("EndAsdfgwg")

why are you doing App:FindEntity()? shouldn't it be 'world:FindEntity()' since you went to the trouble of finding the current world and thats the title of your topic? And are you for some reason still using the very depreciated app.lua scripting?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

7 hours ago, AggrorJorn said:

Anything special about this entity? CSG brush, camera, model?

Reminder: CSG brushes are collapsed if they don't have a script or mass.  Makes finding the entity impossible if that hasn't happened.

The entity that cannot be found is a Box.

The entity that can b e found is a Pivot
 

4 hours ago, macklebee said:

App:FindEntity("EndAsdfgwg")

why are you doing App:FindEntity()? shouldn't it be 'world:FindEntity()' since you went to the trouble of finding the current world and thats the title of your topic? And are you for some reason still using the very depreciated app.lua scripting?

I've updated my sample to reflect the topic.

I wrote my own FindEntity function to try to see if there is a bug in the World's FindEntity. It just loops through the world entities calling World::GetEntity(n) and compares the name.

Both my version and the LE version have the same problem, I'd imagine they are along the same lines of code.

Link to comment
Share on other sites

10 hours ago, martyj said:

The entity that cannot be found is a Box.

The entity that can b e found is a Pivot
 

I've updated my sample to reflect the topic.

I wrote my own FindEntity function to try to see if there is a bug in the World's FindEntity. It just loops through the world entities calling World::GetEntity(n) and compares the name.

Both my version and the LE version have the same problem, I'd imagine they are along the same lines of code.

good to know - without that info about your own function it makes people guess at the problem.

when you say the entity that cannot be found is a Box are you referring to a CSG created box or an actual model that has been imported? Because like Aggror has asked/implied about twice now: if that entity is a CSG created box that you made in the LE world editor and you do not have the mass set greater than 0 or a lua script attached, then that CSG brush will be collapsed into one object with all the other mass-less, script-less CSG objects in the world which would prevent you from finding it via the "name" key.

If for some reason this is an imported model or you have set mass or script to a CSG created box, then I would suggest posting  an example map and sample code so others can try to replicate the issue.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

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.

Guest
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.

 Share

×
×
  • Create New...