#Beacon interface - Factorio Mods
1 messages ยท Page 1 of 1 (latest)
#mod-dev-showcase message
How was this implemented? I ask because one of my mods (modular beacon power) modifies a beacon's power consumption at runtime, but it does it in a janky way by making lots of different beacon entities in the data stage and switching between them as needed once in game.
If there's a better way that you're using here, that could be quite useful.
well essentially with binary modules, each of the 5 effects has 16 module prototypes, they give levels 1 2 4 8 16 32 64 and so on (with the 16th one being negative) and with those you can make up any number within the supported range, this wouldn't work for beacon power consumption itself tho, but you can use this trick to modify the power usage of non-beacon entities
Ah, gotchya
I've also toyed around with inserting modules into beacons (https://mods.factorio.com/mod/promethium-crafting-rework). I do even have more plans involving this mechanic. I'm skimming through the source code for the beacon interface, and I don't see how you're doing it? I am always looking for ways to improve how I do it
which part specifically are you looking for?
Insertion and removal of modules. I see you also have varying levels of module prototypes for each effect too
yeah 16 per effect
that way i can make up any combination under the sun
this is the function that refreshes the beacon contents:
https://github.com/Quezler/glutenfree/blob/main/mods_2.0/055_beacon-interface/control.lua#L249
Seems to be a lot more clever than how I did it. I also did it in powers of 10 rather than binary. I think binary would be easier to do, but powers of 10 definitely do allow the inventory to remain small greatly reducing time needed to insert? Awesome to see
i wouldn't really be worried about insertion speed
Let me reword that: the performance impact of accessing a beacons inventory and inserting/removing modules with several thousand slots vs just a few.
Oh true, yeah that's much smarter lol
how many slots does yours have?
400 lmao. The performance is actually not bad, but I have definitely seen that there is room for improvement. I knowingly didn't put as much effort into that optimization as I could
damn that's a lot 
Hey it started off as like 32767 or something, and the only module I had was a prod mod that adds +1%.
I knew I would be optimizing that, and just wanted to get it functional but maaaan it was laggy
๐คฃ
the joys of the prototyping stage
interesting mod though ๐
ps, the beacon interface mod also has an api in case you want to use it directly, but i can understand your desire to tinker with your own setup ๐
I will definitely draw inspiration (the binary modules is genius) but yes tinkering will be great to expand my skills. Being self taught I know I have a lot to learn still ๐
fully understandable
I do learn best from example though, so this is awesome
let me know if you're running into issues or wondering why i did things a certain way
๐ซก Will do, I appreciate the offer
authorized to ping ๐
have you stress tested this mod for performance?
im thinking of running similar types of effects for a different mod, not quite fully controlled beacons but still having variable effects
Not OP but I have been working on a mod that involves updating modules in a beacons inventory (with possibly hundreds of beacons) every 15 ticks. I implimented Quezlers way of doing the effects, and with 100 beacons updating each quarter of a second (without any extra optimizations) it uses about 0.02ms
Meant to ping
And I could slow it down further if I wanted, and impliment staggered updating but it feels pretty unnecessary as it stands. Even have another idea I could do if I felt like it
how involved are your effects? like tens of modules per beacon or just a couple?
The main bottleneck seems to be the range of the effect strength. If your range is only like +200% of something, then that requires very few modules, but if it's 30000%, that involves a couple more
Quezler does it by generating modules where the effects scale by powers of 2, effectively using binary in modules lol. I don't have any negative effects so I only use 15 modules max myself, but a 16th could be used to make it all negative
do you use multiple effects per beacon or just one type?
For my use case I just put the effects onto one module, but if I wanted fine control over each individual effect it would probably require another beacon or more inventory slots, whichever is least laggy
aight, thanks
Np!
tbh the only measurable performance comes from changing the effects with lua, at any other time they're just vanilla beacons and you know how well those are optimised