A very normal assignment fails in lua.

Place to get help with not working mods / modding interface.
Post Reply
yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

A very normal assignment fails in lua.

Post by yagaodirac »

https://github.com/YagaoDirac/Bug-repor ... t-download

Directly run the scenario.
The bug occurs within a second.
In log, it's very clear. A very strange behavior happens. Inside the add function of array_simple, a field of the added element is removed.

The array_simple is a container. It works properly. I used it in Ore Beach.

So, what can I do with the bug?

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2243
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: A very normal assignment fails in lua.

Post by boskid »

Things not to do when requesting help:
- making reproduction as unhelpful as possible (not providing direct zip, forcing to download git repo)
- not providing any details as to what error it produces, making it literally required to download whatever it is and run.
- providing full code without any size reduction, not narrowing onto the issue.
I would say it is really rude, if you want help, please be helpful from your side.

Only issue i see is this:

Code: Select all

Error while running event BiterOre::on_player_created (ID 25)
No character.
stack traceback:
	[C]: in function '__newindex'
	__BiterOre__/control.lua:315: in function 'set_character_modifier'
	__BiterOre__/control.lua:346: in function <__BiterOre__/control.lua:336>
And it literally says what is wrong: "No character".
This is common issue to solve due to freeplay starting cutscene.

After finally finding hints to move this to scenario, I get this error:

Code: Select all

Error while running event level::on_chunk_generated (ID 12)
...ly-playing/src/Component-bitore_source_content_biter.lua:13: attempt to perform arithmetic on field 'amount_per_minute' (a nil value)
stack traceback:
	...ly-playing/src/Component-bitore_source_content_biter.lua:13: in function <...ly-playing/src/Component-bitore_source_content_biter.lua:12>
But this looks like a programming issue on your side so i am not trying to debug that.

User avatar
jodokus31
Smart Inserter
Smart Inserter
Posts: 1603
Joined: Sun Feb 26, 2017 4:13 pm
Contact:

Re: A very normal assignment fails in lua.

Post by jodokus31 »

3 wrong bug reports, which are revealing themselves as modding help topics, in short time is also a bit taxing, i would assume.

yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Re: A very normal assignment fails in lua.

Post by yagaodirac »

boskid wrote:
Thu Apr 22, 2021 9:50 am
If you have looked at the log just lines above the final error info, you would find that, a table with a field named "amount_per_minute" is gone after a line like.

Code: Select all

cont[index] = this table.
The container should be very correct. Then what is the problem?
I don't believe it's possible to do "wild pointer" in lua.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: A very normal assignment fails in lua.

Post by Klonan »

yagaodirac wrote:
Thu Apr 22, 2021 11:48 am
The container should be very correct. Then what is the problem?
If you can post the whole code snippet related we can try to help

For many years and many thousands of Lua mods, nobody has had problems with the Lua, so generally if something is crashing is it most likely your own mistake

yagaodirac
Fast Inserter
Fast Inserter
Posts: 152
Joined: Sun Jun 16, 2019 4:04 pm
Contact:

Re: A very normal assignment fails in lua.

Post by yagaodirac »

Klonan wrote:
Thu Apr 22, 2021 4:47 pm
OK, thanks. I plan to assemble all the parts in that project again to see what goes wrong. By the way, I found that it's not practical to set the metatable in on_load when the data structure and relationship scale and get complex. Would you consider doing it in your cpp code?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: A very normal assignment fails in lua.

Post by eradicator »

yagaodirac wrote:
Fri Apr 23, 2021 3:02 am
it it's not practical to set the metatable in on_load
Recursive reattachment is far from impractical. Just look and learn how other mods do it.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”