Page 1 of 1

A very normal assignment fails in lua.

Posted: Thu Apr 22, 2021 9:34 am
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?

Re: A very normal assignment fails in lua.

Posted: Thu Apr 22, 2021 9:50 am
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.

Re: A very normal assignment fails in lua.

Posted: Thu Apr 22, 2021 10:40 am
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.

Re: A very normal assignment fails in lua.

Posted: Thu Apr 22, 2021 11:48 am
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.

Re: A very normal assignment fails in lua.

Posted: Thu Apr 22, 2021 4:47 pm
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

Re: A very normal assignment fails in lua.

Posted: Fri Apr 23, 2021 3:02 am
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?

Re: A very normal assignment fails in lua.

Posted: Fri Apr 23, 2021 9:20 am
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.