# Attempt to index local 'entity' (a nil value) - in function 'traceentity'

**URL:** <https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999>\
**Category:** Resolved Reports\
**Tags:** resolved\
**Created:** [October 8, 2015, 4:48pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999 "2015-10-08T16:48:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 7, 2015, 9:33pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/1 "2015-10-07T21:33:13Z")

</div>

Hi,

I get the follow error after reloading my game. First time to get the error at once before I saved the game:

```auto
develop-2630 (x64)
...nehearth/components/building/building_component.luac:124: attempt to index local 'entity' (a nil value)
stack traceback:
    radiant/modules/events.luac:48: in function <radiant/modules/events.luac:45>
    ...nehearth/components/building/building_component.luac:124: in function '_trace_entity'
    ...nehearth/components/building/building_component.luac:37: in function '_restore_structure_traces'
    ...nehearth/components/building/building_component.luac:17: in function 'obj'
    radiant/modules/events.luac:14: in function 'instance'
    radiant/modules/events.luac:59: in function <radiant/modules/events.luac:57>
    [C]: in function 'xpcall'
    radiant/modules/events.luac:57: in function <radiant/modules/events.luac:50>

```

Currently are my game in that status also in the beginning. Plan is build a castle.

 ![](https://us1.discourse-cdn.com/flex022/uploads/stonehearth/original/3X/4/4/44bb1c394c6a765cd97330c5d4c1d4aee7ffe22c.jpg)

Here the Log Files.  
[stonehearth.log](https://discourse.stonehearth.net/uploads/short-url/mJUE2S4niZEMXsufJphCHIp8z33.log) (60.0 KB)

I hope I can finish my castle 🙂 If the save game also needed let me know it.

Br RawEdge

PS: I hope you understand it but English is not my mother language.

Update: after try to place a new block for the building I get the follow Errors:

```auto
develop-2630 (x64)
radiant/modules/entities.luac:100: attempt to index local 'entity' (a nil value)
stack traceback:
    [C]: ?
    radiant/modules/entities.luac:100: in function 'get_world_grid_location'
    stonehearth/services/server/build/build_service.luac:130: in function '_subtract_region_from_floor'
    stonehearth/services/server/build/build_service.luac:91: in function '_add_floor_type'
    stonehearth/services/server/build/build_service.luac:81: in function 'add_floor'
    stonehearth/services/server/build/build_service.luac:50: in function 'cb'
    stonehearth/services/server/build/build_service.luac:304: in function 'do_command'
    stonehearth/services/server/build/build_service.luac:50: in function <stonehearth/services/server/build/build_service.luac:49>

```

* * *

```auto
develop-2630 (x64)
c++ exception: lua runtime error
stack traceback:

```

* * *

```auto
develop-2630 (x64)
...hearth/services/server/build/build_undo_manager.luac:6: assertion failed!
stack traceback:
    [C]: ?
    [C]: in function 'assert'
    ...hearth/services/server/build/build_undo_manager.luac:6: in function 'begin_transaction'
    stonehearth/services/server/build/build_service.luac:303: in function 'do_command'
    stonehearth/services/server/build/build_service.luac:50: in function <stonehearth/services/server/build/build_service.luac:49>

```

---

<div class="post-metadata">

**Author:** ![Albert](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/albert/32/45599_2.png) [@Albert](https://discourse.stonehearth.net/u/Albert)\
**Post date:** [October 8, 2015, 4:49pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/2 "2015-10-08T16:49:12Z")

</div>

@RawEdge - Welcome to the forum! Yes, I’d love to have your save for this bug if you still have it. Thanks!

---

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 8, 2015, 6:06pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/3 "2015-10-08T18:06:33Z")

</div>

Thanks for the nice welcome.

Here are the needed save game.

> **[Dropbox - Error](https://www.dropbox.com/s/50f88flkdddrea2/RawEdges%20Save%20Game.zip?dl=0)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

(When you downloaded the file, say it me to remove it from my dropbox 😉 )

greetings  
RawEdge

---

<div class="post-metadata">

**Author:** ![Albert](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/albert/32/45599_2.png) [@Albert](https://discourse.stonehearth.net/u/Albert)\
**Post date:** [October 8, 2015, 6:37pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/4 "2015-10-08T18:37:26Z")

</div>

Got it. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 8, 2015, 6:56pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/5 "2015-10-08T18:56:17Z")

</div>

Great thanks for the fast reply, I removed the files.

---

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 17, 2015, 12:13pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/6 "2015-10-17T12:13:23Z")

</div>

Any news there? Because the save game is still broken.  
No new buildings are possible also is it not possible to remove the planned building.

I tried also with the last version 2650 on steam.  
But same fault as before.

---

<div class="post-metadata">

**Author:** ![Relyss](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/relyss/32/41785_2.png) [@Relyss](https://discourse.stonehearth.net/u/Relyss)\
**Post date:** [October 17, 2015, 6:03pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/7 "2015-10-17T18:03:35Z")

</div>

Paging @Albert for news on this.

@RawEdge I’m not sure if this would work but you could try selecting the planned building, opening the console with ctrl-alt-c , typing _destroy_ and pressing Enter.

---

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 17, 2015, 8:06pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/8 "2015-10-17T20:06:09Z")

</div>

Hi Relyss, i know that function and its possible to “delete” the planned building.  
But also after that is it not possible to place new building parts.  
On any location.

If I don’t delete the old planned building and want to add new parts on it -\> klick on a position -\> the new planned part disappear … and the error message shows up again.

You cold follow me? I hope you can understand my English.

---

<div class="post-metadata">

**Author:** ![Albert](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/albert/32/45599_2.png) [@Albert](https://discourse.stonehearth.net/u/Albert)\
**Post date:** [October 18, 2015, 9:30am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/9 "2015-10-18T09:30:09Z")

</div>

> [@RawEdge](#):
>
> Any news there? Because the save game is still broken.  
> No new buildings are possible also is it not possible to remove the planned building.
> 
> I tried also with the last version 2650 on steam.  
> But same fault as before.

If I recall correctly, the bug that led to this error corrupted the building and we probably won’t be able to rescue this save game. Sorry for the bad news.

---

<div class="post-metadata">

**Author:** ![Dadrick](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@Dadrick](https://discourse.stonehearth.net/u/Dadrick)\
**Post date:** [October 18, 2015, 6:06pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/10 "2015-10-18T18:06:18Z")

</div>

I found a bug in game while designing a building. It happened while I was placing some individual voxels for decoration. After the bug occurred I could not edit the building any longer and my hearthlings refused to build it.

```auto
release-453 (x64)
...nehearth/components/building/building_component.luac:120: attempt to index local 'entity' (a nil value)
stack traceback:
	radiant/modules/events.luac:68: in function <radiant/modules/events.luac:65>
	...nehearth/components/building/building_component.luac:120: in function '_trace_entity'
	...nehearth/components/building/building_component.luac:33: in function '_restore_structure_traces'
	...nehearth/components/building/building_component.luac:17: in function 'obj'
	radiant/modules/events.luac:15: in function 'self'
	radiant/modules/events.luac:80: in function <radiant/modules/events.luac:78>
	[C]: in function 'xpcall'
	radiant/modules/events.luac:78: in function <radiant/modules/events.luac:70>

```

---

<div class="post-metadata">

**Author:** ![jomaxro](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/jomaxro/32/47935_2.png) [@jomaxro](https://discourse.stonehearth.net/u/jomaxro)\
**Post date:** [October 18, 2015, 6:05pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/11 "2015-10-18T18:05:23Z")

</div>

Hey there @Dadrick, welcome back to the discourse, it has been a while 😄!

Unfortunately, your error appears nearly identical to this one:

> **[Attempt to index local 'entity' (a nil value) - in function 'traceentity'](http://discourse.stonehearth.net/t/error-in-building-component-restore-structure-traces/16999)**
>
> Hi, I get the follow error after reloading my game. First time to get the error at once before I saved the game: develop-2630 (x64) ...nehearth/components/building/building\_component.luac:124: attempt to index local 'entity' (a nil value) stack...

  
Your issue is just in the function `self` instead of `instance.`@Albert already acknowledge the error in the above thread, and also mentioned that the save is likely to not be rescuable…☹

Paging @8BitCrab, @Relyss, or @SteveAdamo for a merge…also, the above thread needs “[Ack]”

---

<div class="post-metadata">

**Author:** ![RawEdge](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RawEdge](https://discourse.stonehearth.net/u/RawEdge)\
**Post date:** [October 19, 2015, 9:43pm UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/12 "2015-10-19T21:43:58Z")

</div>

> [@Albert](#):
>
> If I recall correctly, the bug that led to this error corrupted the building and we probably won’t be able to rescue this save game. Sorry for the bad news.

Its ok, was only a hope from me. 😄

I hope the save game / error report was helpful for the next versions so that not occurs again.

How can I find in the game data the map number?  
To restart the map again?

---

<div class="post-metadata">

**Author:** ![Albert](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/albert/32/45599_2.png) [@Albert](https://discourse.stonehearth.net/u/Albert)\
**Post date:** [October 20, 2015, 12:00am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/13 "2015-10-20T00:00:09Z")

</div>

> [@RawEdge](#):
>
> How can I find in the game data the map number?  
> To restart the map again?

Hit Ctrl-C to open the console and type _world\_seed_.

---

<div class="post-metadata">

**Author:** ![jomaxro](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/jomaxro/32/47935_2.png) [@jomaxro](https://discourse.stonehearth.net/u/jomaxro)\
**Post date:** [November 15, 2015, 10:38am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/14 "2015-11-15T10:38:06Z")

</div>

@Albert, has this been fixed?

---

<div class="post-metadata">

**Author:** ![Albert](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/albert/32/45599_2.png) [@Albert](https://discourse.stonehearth.net/u/Albert)\
**Post date:** [November 16, 2015, 5:44am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/15 "2015-11-16T05:44:52Z")

</div>

Unclear, but I’m leaning no.

---

<div class="post-metadata">

**Author:** ![Fralee](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/fralee/32/26466_2.png) [@Fralee](https://discourse.stonehearth.net/u/Fralee)\
**Post date:** [February 13, 2016, 5:02am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/17 "2016-02-13T05:02:39Z")

</div>

@seanparko welcome to the discourse ( I might be beating some of the mods to it but welcome anyway)

im sure @yshan and/or @sdee will like the log =]

---

<div class="post-metadata">

**Author:** ![James\_Pong](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@James\_Pong](https://discourse.stonehearth.net/u/James_Pong)\
**Post date:** [February 15, 2016, 3:56am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/18 "2016-02-15T03:56:31Z")

</div>

**Summary:**  
The slab will become invisible and can not be removed,also u cant build anything coz the block is actually here  
The worker cant aslo do anything to it but they can walk on it like walking on the air

**Steps to reproduce:**  
1)Create some slab in a house  
2) After the workers built the slab “you can actually see it”, use the slab erase function on the built slab  
3)save and load your game  
4)Go and check the slab you erased you will mention that they disappered  
5)now you have some invisible slab they the worker can do nothing on it (except walking on it)  
You cant even build slabs on the place

**Expected Results:**  
Idk what should it be if i erase the built slab

**Actual Results:**  
You got some bugged slab

**Notes:**  
""""""""""""“A error appear every time i load the game”"""""""""""

```auto
release-523 (x64)
...onehearth/components/building/building_component.lua:295: attempt to index local 'entity' (a nil value)
stack traceback:
	radiant/modules/common.lua:214: in function 'report_traceback'
	radiant/modules/common.lua:225: in function <radiant/modules/common.lua:219>
	...onehearth/components/building/building_component.lua:295: in function '_trace_entity'
	...onehearth/components/building/building_component.lua:105: in function '_restore_structure_traces'
	...onehearth/components/building/building_component.lua:66: in function 'obj'
	radiant/modules/events.lua:76: in function 'instance'
	radiant/modules/events.lua:209: in function <radiant/modules/events.lua:203>
	[C]: in function 'xpcall'
	radiant/modules/common.lua:234: in function 'xpcall'
	radiant/modules/events.lua:203: in function <radiant/modules/events.lua:174>

```

**Attachments:**

**Version Number and Mods in use:**  
Version release 523 and no mods using

**System Information:**  
Win 7 64bit  
8gb ram  
GTX970 display

Sorry for my poor english and bad presentation

---

<div class="post-metadata">

**Author:** ![jomaxro](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/jomaxro/32/47935_2.png) [@jomaxro](https://discourse.stonehearth.net/u/jomaxro)\
**Post date:** [February 15, 2016, 3:59am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/19 "2016-02-15T03:59:28Z")

</div>

Hey there @James_Pong, welcome to the Discourse!

I merged your post over here, thanks for confirming that this error is still occurring in release-523. As the error occurs each time you load the game, can you upload the save so the devs can review it?

To upload a save, locate the folder in `C:\Program Files (x86)\Steam\steamapps\common\Stonehearth\saved_games` (assuming a default Steam install), zip the individual save’s folder (not the entire `saved_games` folder), and upload it. If the `*.zip` is less than 10 MB, feel free to upload it directly to the Discourse. If larger, please upload it to a cloud storage site like Dropbox, Google Drive, File Dropper, etc. and post the sharing link here.

---

<div class="post-metadata">

**Author:** ![Kevin\_Swiecicki](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@Kevin\_Swiecicki](https://discourse.stonehearth.net/u/Kevin_Swiecicki)\
**Post date:** [February 15, 2016, 10:00am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/20 "2016-02-15T10:00:19Z")

</div>

Engine Error on Load Game

Hello, I get the following error every time I load my current game. I think it is save specific as I have not always received this error. The error isn’t fatal, it’s just annoying. Also, I don’t know if this is related, but my goblins seem to be permanently stuck in a peaceful state. That could be a separate issue though

```auto
release-491 (x64)
...nehearth/components/building/building_component.luac:124: attempt to index local 'entity' (a nil value)
stack traceback:
	radiant/modules/events.luac:84: in function <radiant/modules/events.luac:81>
	...nehearth/components/building/building_component.luac:124: in function '_trace_entity'
	...nehearth/components/building/building_component.luac:37: in function '_restore_structure_traces'
	...nehearth/components/building/building_component.luac:17: in function 'obj'
	radiant/modules/events.luac:44: in function 'instance'
	radiant/modules/events.luac:98: in function <radiant/modules/events.luac:96>
	[C]: in function 'xpcall'
	radiant/modules/events.luac:96: in function <radiant/modules/events.luac:86>

```

**Steps to reproduce:**

1. Load one of my save games (the forum won’t let me attach it)

**Expected Results:**  
Opens up my game error free

**Actual Results:**  
Getting the error pop-up after I load. Other than the goblins issue, I haven’t noticed anything out of the ordinary

**Notes:**  
It keeps happening whether I re-start the program or not

**Attachments:**  
I would attach a save, but the forum won’t let me

**Version Number and Mods in use:**  
release-491 (x64)

**System Information:**  
Windows 8.1 Pro 64 bit  
Intel Core i7-2600K  
AMD Radeon R9 200 series  
Windoes directory on single PCI Slot SDD  
Steam Folder on a Raid 1+0 with 4 SSDs

---

<div class="post-metadata">

**Author:** ![Powerclank](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/powerclank/32/48934_2.png) [@Powerclank](https://discourse.stonehearth.net/u/Powerclank)\
**Post date:** [January 13, 2016, 10:17am UTC](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999/21 "2016-01-13T10:17:08Z")

</div>

Try [this](http://discourse.stonehearth.net/t/bug-when-tapping-into-lakes-ponds/18781/5?u=powerclank) to upload your save 🙂  
@jomaxro

[Next page](https://discourse.stonehearth.net/t/attempt-to-index-local-entity-a-nil-value-in-function-traceentity/16999.md?page=2)
