Feedback appreciated about mod concept

Place to get help with not working mods / modding interface.
Post Reply
ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Feedback appreciated about mod concept

Post by ajranney »

I wanted to make a mod that created an entity that would provide the player with endless slow iron/copper/coal/stone. Something like a Endless Deep Driller that was expensive and would slowly provide some resources but not enough to run a base on usually. Anyhow I was starting to make the item and realized that it was not going to work the way I wanted if it was under the Prototype: Mining Drill. I wanted some feedback as to what would be the easiest way to accomplish my mod. I was thinking an assembler that ran a recipe might work better but i wanted the output to be like a miner. I wanted to randomly generate the resource that it would mine by random number generation. I also wanted it to generate bobs/dytechs ores if those mods are active at a very low chance. Something like 5%iron/5%copper/5%coal/84%stone/1%misc random ore. I was also considering running the machine on concrete (to support the underground operation). What would be the simplest or most straightforward way for me to start?

Flux Faraday
Long Handed Inserter
Long Handed Inserter
Posts: 66
Joined: Sat May 10, 2014 8:48 am
Contact:

Re: Feedback appreciated about mod concept

Post by Flux Faraday »

I think you should take a look at how FMOD does its underground drills. You have similar goals, I think.

johanwanderer
Fast Inserter
Fast Inserter
Posts: 157
Joined: Fri Jun 26, 2015 11:13 pm

Re: Feedback appreciated about mod concept

Post by johanwanderer »

Just use an assembly machine instead, and every so often (use on_tick()) just add something to its output slot (if there is room).

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Feedback appreciated about mod concept

Post by L0771 »

johanwanderer wrote:Just use an assembly machine instead, and every so often (use on_tick()) just add something to its output slot (if there is room).
why on_tick?
first, a recipe to make this item (like iron-ore) without ingredients, with category = "your_category", this category is to craft the recipe, now in a custom assembling machine set crafting_categories = {"your_category"}, and this assembler machine only can craft yours recipes, this assembler machine like replicators i think.

johanwanderer
Fast Inserter
Fast Inserter
Posts: 157
Joined: Fri Jun 26, 2015 11:13 pm

Re: Feedback appreciated about mod concept

Post by johanwanderer »

L0771 wrote:
johanwanderer wrote:Just use an assembly machine instead, and every so often (use on_tick()) just add something to its output slot (if there is room).
why on_tick?
first, a recipe to make this item (like iron-ore) without ingredients, with category = "your_category", this category is to craft the recipe, now in a custom assembling machine set crafting_categories = {"your_category"}, and this assembler machine only can craft yours recipes, this assembler machine like replicators i think.
That would be even better. I wasn't sure if you're allowed to have recipes without input or not. If that's the case, the only reason you would need scripting is to produce random elements.

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Feedback appreciated about mod concept

Post by L0771 »

johanwanderer wrote:
L0771 wrote:
johanwanderer wrote:Just use an assembly machine instead, and every so often (use on_tick()) just add something to its output slot (if there is room).
why on_tick?
first, a recipe to make this item (like iron-ore) without ingredients, with category = "your_category", this category is to craft the recipe, now in a custom assembling machine set crafting_categories = {"your_category"}, and this assembler machine only can craft yours recipes, this assembler machine like replicators i think.
That would be even better. I wasn't sure if you're allowed to have recipes without input or not. If that's the case, the only reason you would need scripting is to produce random elements.
a bit very hard :P
I think the recipes have a probability, maybe is you have more than 1 result, this probability is for every result.

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

Thanks for the idea. I think I know how to start now.

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

Where is a good site to get syntax information for LUA? I was having trouble setting up a for loop to make the table for possible ores to choose from. Here is what I have and if anyone wants to debug/fix it that would be nice but i still want to learn how to fix my own code. The tick event that handles generation of ores is full of bugs and not even worth having another person look at yet.

Code: Select all

function Init()
	global.MinerList = {}
	global.OreList={}
	for i = 1 , 50 do
		OreList[i] = "stone"
	end
	for i = 51 , 55 do
		OreList[i] = "coal"
	end
	for i = 56 , 60 do
		OreList[i] = "copper-ore"
	end
	for i = 61 , 66 do
		OreList[i] = "iron-ore"
	end	
--[[if dytech --need to define this
		add dytech ores
	end
	if bobsmods --need to define this
		add bobs ores
	end]]
end

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

nevermind, i forgot my global.OreList instead of OreList.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Feedback appreciated about mod concept

Post by Adil »

You could detect the creation of your miner with on_built and on_robot_built events, and then just use scripts to replace the built entity with tiny resource patch and a miner. It is possible to create dummy resources that don't spawn normally. See data.raw and other mods (off the top of my head I can name only mine) to get a hint how to generate an ore that could be anything from any mod when mined. You could use some of the autoplace values to programmatically decide the probabilities of the mining results.

Tile properties might be of use to determine whether the machine should be allowed to function. (That decision would have to be made during on_built events.)

There can hardly be a better lua starter than an e-book by the author of the language. (There are even more recent albeit less easy-to-read manuals there at lua.org)

edit: I must also say that while implementation might be an entertaining puzzle, I'm not very enthusiastic about the idea itself. The very idea of factorio is about expansion for resources and struggle to save enough of them to keep pushing forward against the unlimited flow of dangers the hostile world is throwing at you. Such eternal resources mods either completely devastate that aspect of the game thus taking out the reason for going on and playing the game, or are simply too ineffective and not worth bothering around. That's my opinion. There probably are people with exactly opposite thoughts.
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.

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

Ok I have most of my mod working however the belts in 12.* act different with regards to collisions. When the can_place_entity function finds items on a belt items on a belt do not take space so it allways returns true. If the belt that the ore outputs onto is full or has an item in the way the new one spawns because the can_place_entity returns TRUE regardless of items currently on the belt. Then the new ore fails to ever load onto the belt when it clears. This image shows a stone "stuck" in front of the "miner". Anyone know how to check for items ON a belt?
Attachments
itemonbelt.png
itemonbelt.png (877.25 KiB) Viewed 7894 times

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Feedback appreciated about mod concept

Post by ratchetfreak »

I believe you can use can_insert_at and insert_at to interract with the belt directly

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

I am struggling with how to use the "transportline" LUA functions. I have

Code: Select all

belt.get_transport_line.insert_at({0.5},{name=ore, count=1})
and factorio reports "Error while running the event handler: __Endless-Miner__/control.lua:132: attempt to index field 'get_transport_line' (a function value)"

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Feedback appreciated about mod concept

Post by ratchetfreak »

it's a function

Code: Select all

    belt.get_transport_line(1).insert_at({0.5},{name=ore, count=1})

ajranney
Inserter
Inserter
Posts: 30
Joined: Mon May 25, 2015 4:44 am
Contact:

Re: Feedback appreciated about mod concept

Post by ajranney »

Thank you! Also I found the {0.5} should be just 0.5 for the insert_at LUA.

Code: Select all

belt.get_transport_line(1).insert_at(0.5,{name=ore, count=1})
now to code for line 1 vs line 2

Post Reply

Return to “Modding help”