local result_items_list = {} --Get all craftable items in game script.on_load(function() local item_prototypes = prototypes.get_item_filtered({}) local recipes = prototypes.get_recipe_filtered({}) local valid_recipes = {} for recipe_name, recipe in pairs(recipes) do if not recipe.hidden_from_player_crafting then valid_recipes[recipe_name] = true end end for _, item_prototype in pairs(item_prototypes) do local name = item_prototype.name if valid_recipes[name] or string.find(name, "ore") then table.insert(result_items_list, name) end end end) --Debug output script.on_load(function() print( "Mod loaded") print( valid_recipes[0]) print( result_items_list[0]) end) --Give random item on ore mined script.on_event(defines.events.on_player_mined_entity, function(event) local entity = event.entity if entity and entity.valid and entity.type == "resource" then event.buffer.clear() local item_count = math.random(1, 10) local item_name = result_items_list[math.random(0, #result_items_list)] local player = game.get_player(event.player_index) local quality_enabled = script.active_mods["quality"] or false local quality = nil if quality_enabled then quality = "normal" end if player.can_insert{name = item_name, count = item_count, quality = quality} then player.insert{name = item_name, count = item_count, quality = quality} else message(player, "inventory-full") end end end)