Jump to content

Exposed script entity is linked but reads as nil


CrazyM
 Share

Recommended Posts

I have a Lua script that has the following exposed property.

 

Script.pawns = nil --entity "Pawns"

 

The Pawns entity is a pivot used as a parent to several other entities. Inside the script, I use this reference to iterate through the children.

 

childCount = self.pawns:CountChildren()

 

for i=0, i<childCount-1, 1 do

--Some action

end

 

This normally works great, but I've had three occurances of this reference suddenly reading as nil when no change occurred in the script, and the UI for the exposed property still shows the Pawns entity being linked.

 

Once this nil error occurs, nothing short of deleting the Pawns pivot, creating a new pivot and re-parenting all my child entities, and re-linking the Pawns property corrects the problem. I have tried un-linking and re-linking the reference, removing and re-adding the script, nothing else seems to work, and I've made no change to warrent reference failure.

Link to comment
Share on other sites

I have seen this also in my training sessions I do with this one person where we are making a chess game. It happens weekly.

 

CrazyM, Josh is going to ask for a map file so once it happens attach the map file to this post for him to check out.

Link to comment
Share on other sites

This is what happens in the beta: You create items or duplicate items. As soon as you make them a child of some other entity, it looks like everything is okay. However, save your scene and reopen it. Your child items are now no longer in your scene.

 

That is also the reason the scripts are failing. Those entities are actually nil.

Link to comment
Share on other sites

  • 3 months later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...