Hello,
tl;dr: I want a Lamp that produces energy at day like a solar panel, stores the energy like an accumulator and consumes the energy at night like a lamp. How can i achieve that?
I'm new to Factorio Modding, started today. I've done some tutorials, but those were kind of outdated or very basic. Didn't help me much concerning this problem. As far as i know, every entity has a type. However, the SolarLamp i desire is basically a SolarPanel, Accumulator and Lamp at the same time. Can i assign multiple types to one entity, some kind of hybrid. Or is it possible to create new types?
Links and/or examples appreciated.
Thanks in advance, best regards.
Astarch
SolarLamp - Producer at day, consumer at Night.
Re: SolarLamp - Producer at day, consumer at Night.
No, you can't have mixed\multiple classes.
But you can have overlapping and invisible entities to emulate that when buildings are considered.
Most hybrid entities, like burner generators are actually several entities spawned together when a specific item is built.
I remember there were also some mods, dealing with composite electrics, wind turbines I believe.
On the other hand entity has "energy" field, if you don't need your lamp to double as a power source for main energy grid, I believe you could try simply giving it huge internal buffer and refilling it by script every once in a while.
But you can have overlapping and invisible entities to emulate that when buildings are considered.
Most hybrid entities, like burner generators are actually several entities spawned together when a specific item is built.
I remember there were also some mods, dealing with composite electrics, wind turbines I believe.
On the other hand entity has "energy" field, if you don't need your lamp to double as a power source for main energy grid, I believe you could try simply giving it huge internal buffer and refilling it by script every once in a while.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: SolarLamp - Producer at day, consumer at Night.
Thanks for your reply.
I tried to figure out what exactly has been done in the Burner Generator mod, but i don't get it.
1) Why is there an item "burner-generator-power"? It can never appear ingame.
2) Why is "burner-generator" (entity) of type "boiler"? Just to provide a fuel inventory?
3) Why does "burner-generator" (entity) consume 120kW as a generator?
4) Why does "burner-generator-power" (entity) use fluid per tick (0.005) of its initial amount of 100? When is it refilled? Based on these values it should be depleted within ~6min.
Thanks in advance.
Best regards.
Astarch
That sounds as a good idea. However, i am more interested in the "several entities spawned together" part, because i will use this more often.I believe you could try simply giving it huge internal buffer and refilling it by script every once in a while.
I tried to figure out what exactly has been done in the Burner Generator mod, but i don't get it.
TLDR
My questions are:1) Why is there an item "burner-generator-power"? It can never appear ingame.
2) Why is "burner-generator" (entity) of type "boiler"? Just to provide a fuel inventory?
3) Why does "burner-generator" (entity) consume 120kW as a generator?
4) Why does "burner-generator-power" (entity) use fluid per tick (0.005) of its initial amount of 100? When is it refilled? Based on these values it should be depleted within ~6min.
Thanks in advance.
Best regards.
Astarch
Re: SolarLamp - Producer at day, consumer at Night.
The way burner generator works is as follows:Astarch wrote:Thanks for your reply.That sounds as a good idea. However, i am more interested in the "several entities spawned together" part, because i will use this more often.I believe you could try simply giving it huge internal buffer and refilling it by script every once in a while.
I tried to figure out what exactly has been done in the Burner Generator mod, but i don't get it.TLDRMy questions are:
1) Why is there an item "burner-generator-power"? It can never appear ingame.
2) Why is "burner-generator" (entity) of type "boiler"? Just to provide a fuel inventory?
3) Why does "burner-generator" (entity) consume 120kW as a generator?
4) Why does "burner-generator-power" (entity) use fluid per tick (0.005) of its initial amount of 100? When is it refilled? Based on these values it should be depleted within ~6min.
Thanks in advance.
Best regards.
Astarch
Burner generator is a boiler
burner generator power is a steam engine
When you place the boiler, it spawn the steam engine on top.
The boiler is needed because it only accepts fuel, and also has a fluid box
The fluid box is filled with water by script
The boiler burns fuel to increase the temperature of the fluid
Every so often, some logic is done to determine whether to top up the steam engine
The steam engine's fluid box is then topped up by script, and the boilers fluid box is adjusted to compensate
The steam engine consumes the hot fluid to produce electricity, at a rate of 0.005 per tick
In essence is recreates a traditional steam engine/boiler/water pump setup as a single entity, with the fluid transfer being handled by script
Now for your mod, i think it is fairly simple, and i think you should look at Conrete lamppost for a better idea of just the entity spawning.
You would need to make:
A small solar panel entity
A small lamp entity
and when you place the solar panel, you spawn the lamp on top of it. Make sure the lamp is force neutral, make sure it is off grid, not selectable in game and stuff.. and yadda yadda
That pretty much the only way to make what i call a 'complex' entity in the game
Re: SolarLamp - Producer at day, consumer at Night.
I tried to implement your suggestions. First i had some problems caused by a little offset of the images which led to a double-vision of the entity in the world. At least i can assume that the trigger to plant the 2nd entity is works.
Now i have the following Problem: (see Pictures)
The (left) lamp is glowing when placed within the power grid. The other (right) lamp is not glowing (bottom image). But that' s low priority. More annoying is the blinking warning signs. How can i prevent this?
Edit: here is some source
Now i have the following Problem: (see Pictures)
The (left) lamp is glowing when placed within the power grid. The other (right) lamp is not glowing (bottom image). But that' s low priority. More annoying is the blinking warning signs. How can i prevent this?
Edit: here is some source
entities.lua
control.lua
- Attachments
-
- Warnings
- 02.png (366.75 KiB) Viewed 2554 times
-
- Lamps
- 01.png (362.14 KiB) Viewed 2554 times
Last edited by Astarch on Mon Feb 29, 2016 1:39 am, edited 1 time in total.
Re: SolarLamp - Producer at day, consumer at Night.
I'd suggest spawning a small invisible power pole, maybe a small accumulator too,
This will mean you can put the solar lamps outside the electric network,
and that they will be self-sufficient
This will also stop the annoying flashing icon for disconnected.
The electric pole should have a supply of 1x1, and wire connect of 0
This will mean you can put the solar lamps outside the electric network,
and that they will be self-sufficient
This will also stop the annoying flashing icon for disconnected.
The electric pole should have a supply of 1x1, and wire connect of 0