[MOD] Deadlock's Stacking Beltboxes & Compact Loaders

Topics and discussion about specific mods
mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by mrvn »

Can I suggest login the problematic icon_size in the error message in case the problem comes back?

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Villfuk02 »

Thanks for quick response!
I dug trough your code for hours and also found the varible c not assigned, but still used. I thought it's some modding/lua trick I don't know yet, because otherwise it would be null.
Do I need to make variables inside functions and loops local too?

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

Villfuk02 wrote:Do I need to make variables inside functions and loops local too?
It's not so much "need" as just being a good idea, especially in situations like Factorio modding where you have no clue what randoms like me are doing (or not doing). When I started modding with Lua I was doing pretty much the same thing as you, and it didn't bite me on the arse until I started providing functions for other mods to use - then you have situations where you've declared a set of global variables, which some other mod then changes because they were global, then those mods or some other third mod calls your function, and nothing works like anyone expected. Making absolutely everything local unless there's a good reason not to eliminates 99% of these problems. But hey, this is amateur modding done for fun, I have no regrets, I'm not doing this for a living. Leaving that c in there was just an outright mistake that never showed up until it interacted with a mod that declares a global c.

My understanding is that if it wasn't initially declared as local then it's not local, no matter where you're doing the declaring. Functions can (/should) also be local unless they need not to be. Some would argue there is never any need for a global function, you can declare functions as local in one file and use require and return to get another local copy of them in another file - see my loaders mod (DCL) for a better implementation of that, DSB still suffers from some less-than-ideal practices (*shrug*). In Factorio the only good reason I can think of is if you're wanting to provide functions for other mods to use in the data phase (like I do) - in the control phase you can use all that fancy remote call stuff instead, which is safer.

This helped me: http://lua-users.org/wiki/ScopeTutorial
Image

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

---------------------------------------------------------------------------------------------------
Deadlock's Stacking Beltboxes version: 1.6.2
Date: 15. 05. 2018
Bugfixes:
- Corrected the main internal call to stacked item recipe gen for vanilla items, which unintentionally used an uninitialised global variable for reasons lost in the mists of time.
- Corrected a typo in a variable name while sanity checking for a rare situation (unusual icon size).
---------------------------------------------------------------------------------------------------
Image

shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by shanemadden »

A minor addendum to the advantages of locals: in addition to avoiding the potential for other mods stepping on your variables, there's some slight performance advantages to local variables.

A handy way to check for where all you're using globals in a file with the luac executable.

Find all the times any global is set in a file so that you can make sure all instances are intended:

Code: Select all

$ luac -p -l prototypes/public.lua | grep SETTABUP.*_ENV
        5       [4]     SETTABUP        0 -3 1  ; _ENV "deadlock_stacking"
Find all the global lookups done in a file (which shows a bunch of expected stuff for language functions but also locates that errant c):

Code: Select all

$ luac -p -l prototypes/recipes.lua | grep GETTABUP.*_ENV
        1       [1]     GETTABUP        0 0 -1  ; _ENV "require"
        4       [4]     GETTABUP        1 0 -3  ; _ENV "data"
        ...
        206     [96]    GETTABUP        4 0 -21 ; _ENV "pairs"
        212     [97]    GETTABUP        11 0 -76        ; _ENV "c"

User avatar
Xagros
Inserter
Inserter
Posts: 40
Joined: Thu Jul 20, 2017 4:11 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Xagros »

Hi, Deadlock989.

I am sorry if I have offended you with my lack of English skills. I am using your mods well. Thank you for providing good mods.

I found a bug, so I leave a report. When I activate the "Re-style belts" option of your loader mod, Belt mod with no "hr_version" graphics will detect errors. If a mod does not have "hr_version" graphics, can you let your mod handle that part? Attach a picture of the error below.

I am immature in how to write credits and licenses in English. Can you tell me what you need to fix my mod? And can you recognize my mode as your third-party mod?
Attachments
캡처.PNG
캡처.PNG (12.94 KiB) Viewed 5448 times
ImageImage

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

Xagros, your English is good, there is no problem there. There was a problem in the past that we discussed privately and that is solved and no longer an issue.

Regarding your MoreBobs mod, my issue is that it is not really an "add-on". It is a very big mod, nearly nine times as big as DCL. It collects all kinds of different things together, most of them I don't recognise. It is more of an overhaul or unification mod than an add-on. When I provided support for other mods, I assumed that these "helper" or "bridge" mods would be very simple and small, like the ones that orzelek and The_Ghost and others have made. I am reluctant to recommend something when I don't understand even half of what it does, and I'm not playing Factorio at the moment so I don't have time to find out.

Edited to add:

I have investigated the error that RubberBelts is throwing. It is a problem created by the assumptions that RubberBelts makes about vanilla transport belt entities. It makes its "crappybelt" out of a copy of the yellow belt, and it assumes that the yellow belt has a single layer of HR graphics (e.g. belt.animations.hr_version, belt.belt_horizontal.hr_version etc.). When DCL's belt styling is on, those graphics are replaced with layered animations (e.g. belt.animations.layers[0].hr_version etc.), which mean the .hr_version fields are all one level deeper and not where RubberBelts assumes they are. There is nothing I can do about that because this is literally what the belt styling is designed to do: create any arbitrary colour of belt by replacing the single layer graphic with multi-layer tinted animations. This was quite a piece of work, I had to ask the devs to tweak some rendering to make it happen.

The only method within my power to stop RubberBelts breaking is to make DCL depend on RubberBelts so that it loads first, but I'm not going to do that.

Workaround: don't use belt styling when RubberBelts is installed, it's not compatible.

Real fix: RubberBelts should build its new entity from scratch rather than copy a vanilla one and then reference fields which may no longer exist.
Image

User avatar
Xagros
Inserter
Inserter
Posts: 40
Joined: Thu Jul 20, 2017 4:11 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Xagros »

Deadlock989 wrote:Xagros, your English is good, there is no problem there. There was a problem in the past that we discussed privately and that is solved and no longer an issue.

Regarding your MoreBobs mod, my issue is that it is not really an "add-on". It is a very big mod, nearly nine times as big as DCL. It collects all kinds of different things together, most of them I don't recognise. It is more of an overhaul or unification mod than an add-on. When I provided support for other mods, I assumed that these "helper" or "bridge" mods would be very simple and small, like the ones that orzelek and The_Ghost and others have made. I am reluctant to recommend something when I don't understand even half of what it does, and I'm not playing Factorio at the moment so I don't have time to find out.

Edited to add:

I have investigated the error that RubberBelts is throwing. It is a problem created by the assumptions that RubberBelts makes about vanilla transport belt entities. It makes its "crappybelt" out of a copy of the yellow belt, and it assumes that the yellow belt has a single layer of HR graphics (e.g. belt.animations.hr_version, belt.belt_horizontal.hr_version etc.). When DCL's belt styling is on, those graphics are replaced with layered animations (e.g. belt.animations.layers[0].hr_version etc.), which mean the .hr_version fields are all one level deeper and not where RubberBelts assumes they are. There is nothing I can do about that because this is literally what the belt styling is designed to do: create any arbitrary colour of belt by replacing the single layer graphic with multi-layer tinted animations. This was quite a piece of work, I had to ask the devs to tweak some rendering to make it happen.

The only method within my power to stop RubberBelts breaking is to make DCL depend on RubberBelts so that it loads first, but I'm not going to do that.

Workaround: don't use belt styling when RubberBelts is installed, it's not compatible.

Real fix: RubberBelts should build its new entity from scratch rather than copy a vanilla one and then reference fields which may no longer exist.
Thank you for your detailed explanation. As you say, I think my mod really includes a lot of features. :oops:
And thank you for checking the problem of the rubber belt. I am sorry to have to give up one of the options.
I'll let you know if you find any other issues. Thank you. :)
ImageImage

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

Xagros wrote:And thank you for checking the problem of the rubber belt. I am sorry to have to give up one of the options.
I'll let you know if you find any other issues. Thank you. :)
OK, but if it's a problem with another mod, don't let me know, let the other mod know.
Image

Alkumist
Burner Inserter
Burner Inserter
Posts: 7
Joined: Mon Feb 12, 2018 11:38 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Alkumist »

Are you planning on changing the graphics of splitters as well? :D

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

Alkumist wrote:Are you planning on changing the graphics of splitters as well? :D
No plans, and I'm taking a break from Factorio until 0.17/1.0. I did start tinkering with splitters but they are a lot more complicated and I don't have anywhere near the skill of the Factorio artists, so it would probably just look worse in the end. I don't think the vanilla splitter and the DCM style entities clash particularly so there's no real need for it.
Image

TRauMa
Inserter
Inserter
Posts: 40
Joined: Fri Jan 15, 2016 3:48 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by TRauMa »

I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by orzelek »

TRauMa wrote:I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs
Please take it down. You violated the license thats attached to the mod itself.
It was not posted on mod portal partially because I was not happy with how it works with bob's only (wrong stacked icons then).

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

TRauMa wrote:I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs
You could easily have used it without MoreBobs ... by just using it without MoreBobs.

Instead, what you've done is take someone else's work and upload it to the mod portal, against their wishes, without asking them, while also disrespecting the license included in that mod.

I'm not impressed.
Image

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by orzelek »

Deadlock989 wrote:
TRauMa wrote:I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs
You could easily have used it without MoreBobs ... by just using it without MoreBobs.

Instead, what you've done is take someone else's work and upload it to the mod portal, against their wishes, without asking them, while also disrespecting the license included in that mod.

I'm not impressed.
He removed the generated icons so all is ok now.
That was my main concern there since icons were used with permissions of other mod authors and those are not transferrable I think.
And since I've been playing less recently I did not get to updating this mod properly and adding correct bob's stuff.

User avatar
Xagros
Inserter
Inserter
Posts: 40
Joined: Thu Jul 20, 2017 4:11 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Xagros »

TRauMa wrote:I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs
Well... If you only want to be in a standalone form in my mod, see my mod code. My mod code is also written in Bob's Extended Kaorhil. Instead, please leave a link in your mod that connects to my mod.
ImageImage

SplitSilver
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Jun 07, 2018 1:25 am
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by SplitSilver »

Thanks for the great mod! I saw in the code that you mentioned not to change the STACK_SIZE of the beltbox because "bad stuff happens." I tested it anyway and the mod seemed to correct itself for pretty much everything. I saw elsewhere in this forum that the reason you chose 5 over 4 is because of the stack size of ore in vanilla. So I'm aware of that issue, but aside from stack sizes that don't divide well by 4, do you know what other problems might come with changing the STACK_SIZE to 4 for my own use? Thanks!

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

SplitSilver wrote:Thanks for the great mod! I saw in the code that you mentioned not to change the STACK_SIZE of the beltbox because "bad stuff happens." I tested it anyway and the mod seemed to correct itself for pretty much everything. I saw elsewhere in this forum that the reason you chose 5 over 4 is because of the stack size of ore in vanilla. So I'm aware of that issue, but aside from stack sizes that don't divide well by 4, do you know what other problems might come with changing the STACK_SIZE to 4 for my own use? Thanks!
You're welcome.

4 is probably the safest value after 5, it should be OK, except that stacked ore will lose some efficiency if its natural stack size is still 50 (50 doesn't have 4 as a factor). If you change ores to have a natural stack size of 100 (with Restack or many other mods which can do this) then it should all work. The value actually was 4 in the very earliest versions, it only got changed to 5 once ores became stackable. 4 makes more sense because so many people organise their buses in bands of 4 belts, but it had to be 5 in the end because it's such a common factor.

There were a lot of tweaks to beltbox crafting speed etc. after that - the code now checks for customised belt speeds in case you're using a mod like Bob's Logistics, and I never tested non-5 stacks after that - so check that the machines are running at the right speed (i.e. no backlogs, no idle time when fed a compressed belt of unstacked stuff). But I think it should be OK.
Image

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by Deadlock989 »

---------------------------------------------------------------------------------------------------
DSB version: 1.6.3
Date: 18. 06. 2018
Changes:
- Updated the stacked battery icon to match the new vanilla battery.
- Factorio base 0.16.51 stable is required.
---------------------------------------------------------------------------------------------------
Image

TRauMa
Inserter
Inserter
Posts: 40
Joined: Fri Jan 15, 2016 3:48 pm
Contact:

Re: [MOD 0.16.x] Deadlock's Stacking Beltbox (& Compact Loaders)

Post by TRauMa »

Xagros wrote:
TRauMa wrote:I published orzolek's Angelbob support posted before, as I wanted to use it without MoreBobs.

https://mods.factorio.com/mod/deadlock- ... ating-bobs
Well... If you only want to be in a standalone form in my mod, see my mod code. My mod code is also written in Bob's Extended Kaorhil. Instead, please leave a link in your mod that connects to my mod.
Well, that's what happens when you let a month pass between doing your research and looking at the licenses, and actually doing something and publishing it. It seems I mixed up your and orzolek's mod licenses. I also was under the (wrong?) impression that you used orzolek's as base for yours.

I should have a bit of time in the next days and will look at MoreBobs, to incorporate item definitions I'm missing, and using imagemagick or something alike to create the stacked icons automatically, now that I have permission by bobingabout at least (Arch666Angel seems absent for now).

From then, it'll probably be maintenance.

Post Reply

Return to “Mods”