I apologise if this question has already been answered. I did a few quick searches for the answer and came up with nothing. When writing code in control.Lua (or I suppose any Lua file executed by factorio) is there a way to see the error that has been thrown? (are there errors getting thrown?)
For now, i have just been inserting a log message between lines I believe are the offending errors but as you can imagine it becomes quite tedious.
Thank you guys in advance for any help
Reading Control.lua errors
Re: Reading Control.lua errors
You see any error thrown when it pops up and displays the error message with an "ok" button. It shows the line number and stack trace + what the error was.
If you want to get ahold of me I'm almost always on Discord.
Re: Reading Control.lua errors
Sorry, i guess I worded my question a bit poorly. Maby an example will help say I had the following script:
If I were to run this code the game would get to the 2nd line and then just stop. A simple error to make but hard to check if the logic is broken or if you made a simple mistake. It can take a long time to fix trivial mistakes. Thank you for the response, though.
Code: Select all
Event.register({defines.events.on_built_entity, defines.events.on_robot_built_entity}, function(event)
local entity = event.created_entity
local name = emtity.name
...
end
Re: Reading Control.lua errors
It would give you an error that said something along the lines of "error at line *line number*: Attempt to index 'emtity' a nil value."Tron842 wrote:Sorry, i guess I worded my question a bit poorly. Maby an example will help say I had the following script:
If I were to run this code the game would get to the 2nd line and then just stop. A simple error to make but hard to check if the logic is broken or if you made a simple mistake. It can take a long time to fix trivial mistakes. Thank you for the response, though.Code: Select all
Event.register({defines.events.on_built_entity, defines.events.on_robot_built_entity}, function(event) local entity = event.created_entity local name = emtity.name ... end
If you want to get ahold of me I'm almost always on Discord.
Re: Reading Control.lua errors
Hmm, well I had to test to make sure I wasn't going crazy. I tested what I said and the game just stopped running the script and carried on its way. Didn't print any error message that I can find (neither a pop-up of in the factorio-current.log.
Re: Reading Control.lua errors
Tron842 wrote:Hmm, well I had to test to make sure I wasn't going crazy. I tested what I said and the game just stopped running the script and carried on its way. Didn't print any error message that I can find (neither a pop-up of in the factorio-current.log.
Code: Select all
Event.register({defines.events.on_built_entity, defines.events.on_robot_built_entity}, function(event) ... end)
Code: Select all
/c script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity}, function(event) ... end)
When I test it, it works just fine:
If you want to get ahold of me I'm almost always on Discord.
Re: Reading Control.lua errors
I changed how the event was regestered as you suggested and it gave me the error. I didn't even realize there was multiple ways to regester events and will switch to this one. Thankyou
Re: Reading Control.lua errors
Darn I am an idiot. There isn't I was just useing someone's libary and didn't see theit events code.... there isn't two ways sigh pleas excuse my ignorance.