Page 2 of 2

Re: Spreading a table out over several ticks

Posted: Thu May 05, 2022 6:14 pm
by FuryoftheStars
Ok, so I've noticed that using the deepcopy hurts the ups greatly over ~4k planters (at ~8k, ups was ~30), so I've changed it to simply local planters = global.planters (and local saplings = global.saplings, respectively) and that fixed it. However, if someone could clarify something for me... I may be getting this confused with another language or even a different data type, but with tables, if I simply do a table2 = table1, am I actually making a copy of that table, or merely creating a reference to it? I'm worried that it's a reference and so if anything happens to trigger the add while it's looping, it'll still error.


------------------------------------------

Qon wrote:
Thu May 05, 2022 5:07 pm
FuryoftheStars wrote:
Thu May 05, 2022 3:04 pm
FuryoftheStars wrote:
Thu May 05, 2022 12:25 pm
I noticed that at ~2k planters with ~1.5k saplings growing I was taking a 5-10 ups hit.
Whoops. Meant ~4k planters and ~3k-3.5k saplings.
Use the edit button.
That was 3 hours later. If it'd only been a few minutes, I would've.

Re: Spreading a table out over several ticks

Posted: Thu May 05, 2022 7:32 pm
by Klonan
FuryoftheStars wrote:
Thu May 05, 2022 6:14 pm
with tables, if I simply do a table2 = table1, am I actually making a copy of that table, or merely creating a reference to it?
You're creating a reference to it, with strings and numbers would it make a copy

Re: Spreading a table out over several ticks

Posted: Thu May 05, 2022 8:29 pm
by FuryoftheStars
Klonan wrote:
Thu May 05, 2022 7:32 pm
FuryoftheStars wrote:
Thu May 05, 2022 6:14 pm
with tables, if I simply do a table2 = table1, am I actually making a copy of that table, or merely creating a reference to it?
You're creating a reference to it, with strings and numbers would it make a copy
Thanks, Klonan!


Hmm, ok. Maybe I'd be better off using this other method, then:
FuryoftheStars wrote:
Thu May 05, 2022 3:49 am
setting of a variable to true when the add event is called, and checking that var's state on each iteration of the loop, breaking if true (and then setting back to false for the next tick).
I realize the chances of the error occurring are remote (probably even theoretically not supposed to happen), but as I was able to trigger it once, I don't want to have to field bug reports on it later. :P