Electric furnace with 2 in/output slots

Place to get help with not working mods / modding interface.
Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Electric furnace with 2 in/output slots

Post by Andrea88 »

Hello everyone!

i'm on 0.5.2 and i create a simple electric furnace mod.
In "entity.lua" i just added under

Code: Select all

...
type=burner
...
the line

Code: Select all

...
type=electric
...
and some minor edits, like the smelting speed process.
So it can work as a furnace and not as an assembly machine :D[/size]

The particularity of this furnace is that it has 2 input and 2 output slots. I was so happy when i see it works, but.... damn :(
i realize that only one slot per time is processed and not both together.

Question: how can i fix this "issue", if there's a way...
thanks


----- EDIT -----

i'm going crazy :evil: so i decided for a more deep search.
Here, https://forums.factorio.com/forum/vie ... slot#p2239 i found this:
Turns out the furnace only uses the extra input as a buffer and starts smelting the ore in the first slot.
in fact, it's exactly what's happening in my world. The thread is talking about of an assembly table, if i correctly translate, that craft an electronic circuit in other ways and with other materials.
it's not the same what i'm going to do. i just want smelt ore from 2 slots together. don't care if the ores are the same or not (slot 1=iron - slot 2=copper OR slot 1=iron - slot 2=iron) because, theoretically, input slot 1 goes in output slot 1 and the same for in/out slot 2.

I hope I explained myself well enough :mrgreen: in case, ask me :D

----- END EDIT -----

midnight109
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Thu Jun 27, 2013 3:59 pm
Contact:

Re: Electric furnace with 2 in/output slots

Post by midnight109 »

Well, im still new, only made one mod so far, but I think, key word here is think, that as it currently is the system is configured to work the way they intended it, and not having like a dual system in one. BUT the wonderfull thing is LUA scripting can, to a extent, make anything do anything with some coding. If you use LUA script to add a function to the game events, say the games ticks, that would work on your building(s) adding something like

Code: Select all

game.oninit(function()
	glob.myfurnace = {}
	glob.myfurncount= 0 
	glob.tickCount = 0
end)

game.onload(function()
	if glob.field == nil then
		glob.myfurncount= 0 
		glob.tickCount = 0
	end
end)

game.onevent(defines.events.onbuiltentity, function(event)
	if event.createdentity.name == "myFurnName" then
		glob.myfurncount = glob.myfurncount + 1    
		glob.myfurnace[glob.myfurncount] = event.createdentity
	end
end)

game.onevent(defines.events.ontick, function(event)
	glob.tickCount = glob.tickCount + 1
    
	if glob.tickCount % 60 == 0 and glob.myfurncount ~= 0 then						 -- called every sec if at least one of your furnaces are built, you add your commands as to how you want each one handeled

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: Electric furnace with 2 in/output slots

Post by n9103 »

I'm not sure about the slot 1 into slot 1 sort of idea, but having 2 working inputs in a furnace would allow for alloys. :)
Having one furnace processing non-identical (or compatible ores if alloys are put in) seems like a bad idea since the game is about mass production and assembly, and having disparate ores will lead to undesirable outputs should anything in the system leading to it change.

Question for you: What are you trying to accomplish with this 2 input/output of dissimilar materials furnace?
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Electric furnace with 2 in/output slots

Post by Andrea88 »

@midnight109 thanks! but unfortunately i'm not so good in scripting :oops: i haven't idea where to put this code...
n9103 yeah, meybe you're right.. Simply i wanted smelt, for example, a stack (or some) of iron in slot 1 and a stack (or some) of copper in slot 2 (or vice versa, as you want :D). The result i expected was iron bar in output slot 1 and copper bar in slot 2. So i was able to smelt 2 different ores at the same time: 2 inserters put in raw materials and 1 or 2 inserters that pick up the bars.
I repeat, maybe you're right; this is a process more useful with alloys and not to smelt 2 different raw ores :? At this point, i also can remove the slots 2 because my furnace has a smelting speed of 3 and a slot used as buffer is useless :P

midnight109
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Thu Jun 27, 2013 3:59 pm
Contact:

Re: Electric furnace with 2 in/output slots

Post by midnight109 »

The code itself would go into control.lua of the mod in the main dir along with the info.json and data.lua
the lua scripting is complicated if you dont know how to script but I never scripted with it before till now and it is a much easier learning curve then the regular ones like learning to program in C/C++ >.>
https://forums.factorio.com/wiki/inde ... tom_Events has some examples of how the scripts look, pretty easy on some of them, and other mods show more details and usually good comments on how it works so can learn pretty quick how to make stuff work out

User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Electric furnace with 2 in/output slots

Post by rk84 »

If recipes had secondary/waste result, two outputs would be usefull.
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela

Andrea88
Inserter
Inserter
Posts: 30
Joined: Mon Mar 04, 2013 6:15 pm
Contact:

Re: Electric furnace with 2 in/output slots

Post by Andrea88 »

@midnight109: ok, i'll try some scripting test soon :P i like these things :D
i know, i'll become crazy ahahahah!!

Post Reply

Return to “Modding help”