attempt to index field '' (a nil value)

4.4k Views Asked by At

I was trying to run this script done by SethBling, but it gives me this error:

LuaInterface.LuaScriptException: DP1.state

LuaInterface.LuaScriptException: [string "main"]:337: attempt to index field 'neurons' (a nil value)

This is the code

5

There are 5 best solutions below

2
On

A flamanis posted this comment on youtube. I followed the instructions and got it working.

HOW TO GET IT TO WORK! THIS ALL TAKES PLACE INSIDE THE FOLDER YOUR BIZHAWK EMULATOR IS IN.
Execpt this part: Before EVER opening the lua console on BizHawk, (If you have, instructions on how to reset your stuff will be at the bottom) go onto the level you want to have it learn, and when the level starts up, click on file. Go down and open the menu of save state, at the bottom click the create named state, and then finally name it DP1, however put it after all the slashes and whatever so just delete the gamestate.whatever jargon that it auto names it. After doing that, either move that file from the SNES/State folder to where you have your lua file, or the other way around. and then load up the lua file into the console, and boom you're good.
IF YOU ALREADY TRIED TO RUN THE LUA FILE AND IT ERRORS: You either need to delete your save, or edit the lua file slightly. If you want to do the delete save approach, then go into the SNES folder and then into the SaveRAM folder and delete your file for the game. THIS DOES NOT DELETE THE EMULATION, just the save.
If you want to edit the lua file, then at the top, the very top line, (create a new one if you want to, just make sure it's before any other text) add this: pool = nil that's it. It will reset the data so that it can run again. You still need that save state though. You will probably want to edit the file again after you've started running it and remove that line or it will restart every time you turn it on.

0
On

Move the savestate and lua script to the main folder for the emulator (where EmuHawk.exe is)

1
On

In case this didn't solve your problem try this:

"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load." from JaRetroYT over on reddit.

0
On

"If you are using a version of BizHawk that is over 2.0, go into the menu and Click Config then follow as such: Customize > Advanced > Lua Core > Lua+LuaINterface. This is why I wasn't able to load." from JaRetroYT over on reddit.

0
On

Alrighty, I said I'd answer this better, and sometimes people do just google randomly for their solutions.

Soo, Bizhawk emulator has a way to run Lua scripts, which is nice.

So Seth's program assumes a few things about how the game is set up, and how the user (that is you) has done certain things beforehand.

The main thing that you need to do beforehand is create what is known as a save state. This is a point in the game that you can instantly reload back to, and how the program restarts the level so that each 'run' is essentially the exact same. This differs slightly from normal games where you 'load' the game, because games back around SMB weren't as 'random' as games now. So saving the game and loading it should give the same exact result with the same inputs every time.

You should create the save state right at the very start of the level. To create this illustrious save state you want to click on the file button at the top of your screen to open the drop down, and then select save state and create a new one. This should create a save state that you can then load to return to that exact moment in the game.

To have the program be able to load your save state to run you can do one of two things

1: Rename the actual save state file name to be just DP1.savestate

2: Modify the Lua file and change the DP1.savestate part to be the name of your save state

Then you just need to move them into the same folder, and you should be golden.

If you attempted to run the file before making a save state, it will have tried to run and errored with attempt to index field 'neurons' (a nil value) or something similar. (It's been a while, it could have stopped on the first run because it couldn't find the save state, so this might just only happen on the 2nd and further runs)

What this means is that it essentially created it's "brain" but left it completely empty. Which is bad. There's two ways to fix this, and they're fairly straightforward.

1: You need to delete the actual game save, otherwise known as the SaveRAM. The file that you need to delete can be found in the folder for whatever console you're running, in Seth's video he was using the SNES, so that's the folder you'd want to go into. Inside that folder is then the SaveRAM folder, you can either just delete that folder, or go into it and delete the one for the game you were running.

2: You need to edit the Lua file to reset itself, all this requires is putting the text pool = nil at the very top. This will then delete the "brain" before anything else happens, which will let the program create a new one. Fair warning: This is not just a one time effect, if you restart the program at this point you will lose your entire progress. What you need to do is after it starts running, stop it and edit the file again, and remove the line you just added. This will stop it from deleting it's "brain" every time the program starts, and you should be able to freely run the game.

I do hope that there are still people who look at Seth's video and wants to make it run themselves, good luck to you guys, and happy gaming.