init
This commit is contained in:
commit
43086ea1eb
553 changed files with 20250 additions and 0 deletions
84
scripts/SE/data-final-fixes.lua
Normal file
84
scripts/SE/data-final-fixes.lua
Normal file
|
@ -0,0 +1,84 @@
|
|||
local function config(name)
|
||||
return settings.startup['el_ki_beacon_'..name].value
|
||||
end
|
||||
|
||||
--techs
|
||||
table.insert(data.raw.lab["gr_lab_entity"].inputs, "se-deep-space-science-pack-1")
|
||||
table.insert(data.raw.lab["gr_lab_entity"].inputs, "se-material-science-pack-2")
|
||||
table.insert(data.raw.lab["gr_lab_entity"].inputs, "se-rocket-science-pack")
|
||||
--se-energy-science-pack-1
|
||||
table.insert(data.raw.technology["fu_energy_tech"].unit.ingredients, {"se-energy-science-pack-1", 1})
|
||||
table.insert(data.raw.technology["fu_reactor_tech"].unit.ingredients, {"se-energy-science-pack-1", 1})
|
||||
table.insert(data.raw.technology["fu_tokamak_tech"].unit.ingredients, {"se-energy-science-pack-2", 1})
|
||||
table.insert(data.raw.technology["fu_star_engine_tech"].unit.ingredients, {"se-energy-science-pack-3", 1})
|
||||
--se-energy-material-pack-1
|
||||
table.insert(data.raw.technology["fu_star_engine_copper_tech"].unit.ingredients, {"se-material-science-pack-1", 1})
|
||||
table.insert(data.raw.technology["fu_star_engine_iron_tech"].unit.ingredients, {"se-material-science-pack-1", 1})
|
||||
table.insert(data.raw.technology["fu_star_engine_sulfur_tech"].unit.ingredients, {"se-material-science-pack-1", 1})
|
||||
--ki
|
||||
table.insert(data.raw.technology["fu_ki_plus_1_tech"].unit.ingredients, {"se-deep-space-science-pack-2", 1})
|
||||
table.insert(data.raw.technology["fu_ki_plus_2_tech"].unit.ingredients, {"se-deep-space-science-pack-4", 1})
|
||||
table.insert(data.raw.technology["el_ki_sup_2_tech"].unit.ingredients, {"se-energy-science-pack-1", 1})
|
||||
table.insert(data.raw.technology["el_ki_sup_3_tech"].unit.ingredients, {"se-energy-science-pack-2", 1})
|
||||
table.insert(data.raw.technology["el_ki_sup_4_tech"].unit.ingredients, {"se-energy-science-pack-3", 1})
|
||||
|
||||
--modules
|
||||
table.insert(data.raw.technology["fi_modules_4_tech"].unit.ingredients, {"se-deep-space-science-pack-2", 1})
|
||||
table.insert(data.raw.technology["fi_modules_5_tech"].unit.ingredients, {"se-deep-space-science-pack-3", 1})
|
||||
table.insert(data.raw.technology["fi_modules_6_tech"].unit.ingredients, {"se-deep-space-science-pack-4", 1})
|
||||
|
||||
|
||||
data.raw.technology["gr_stage_tech"].prerequisites = {
|
||||
'fu_space_probe_3_tech',
|
||||
'fu_hydrogen_3_tech',
|
||||
'fu_lead_tech'
|
||||
}
|
||||
|
||||
for i,v in pairs(data.raw.beacon) do
|
||||
if (i == "el_ki_beacon_entity-spaced") or (i == "fi_ki_beacon_entity-spaced") or (i == "fu_ki_beacon_entity-spaced") then
|
||||
data.raw.beacon[i] = nil
|
||||
end
|
||||
end
|
||||
|
||||
--buff beacons
|
||||
data.raw.beacon["el_ki_beacon_entity"].module_specification = {
|
||||
module_slots = 10,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
||||
data.raw.beacon["el_ki_beacon_entity"].energy_usage = '2MW'
|
||||
data.raw.beacon["el_ki_beacon_entity"].supply_area_distance = config('supply_area') + 2
|
||||
|
||||
data.raw.beacon["fi_ki_beacon_entity"].module_specification = {
|
||||
module_slots = 15,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
||||
data.raw.beacon["fi_ki_beacon_entity"].energy_usage = '8MW'
|
||||
data.raw.beacon["fi_ki_beacon_entity"].supply_area_distance = config('supply_area') + 6
|
||||
|
||||
data.raw.beacon["fu_ki_beacon_entity"].module_specification = {
|
||||
module_slots = 45,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
||||
data.raw.beacon["fu_ki_beacon_entity"].energy_usage = '80MW'
|
||||
data.raw.beacon["fu_ki_beacon_entity"].supply_area_distance = config('supply_area') + 15
|
||||
|
||||
|
||||
--buff cores
|
||||
data.raw.beacon["el_ki_core_slave_entity"].module_specification = {
|
||||
module_slots = 5,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
||||
data.raw.beacon["fi_ki_core_slave_entity"].module_specification = {
|
||||
module_slots = 5,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
||||
data.raw.beacon["fu_ki_core_slave_entity"].module_specification = {
|
||||
module_slots = 5,
|
||||
module_info_icon_shift = {0, 0.5},
|
||||
module_info_multi_row_initial_height_modifier = -0.3,
|
||||
}
|
34
scripts/SE/data.lua
Normal file
34
scripts/SE/data.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
--on space station
|
||||
data.raw["assembling-machine"]["el_ki_memory_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["el_ki_cpu_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["el_ki_core_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["fi_ki_circuit_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fi_ki_core_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["fu_ki_circuit_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_ki_core_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["beacon"]["el_ki_beacon_entity"].se_allow_in_space = true
|
||||
data.raw["beacon"]["fi_ki_beacon_entity"].se_allow_in_space = true
|
||||
data.raw["beacon"]["fu_ki_beacon_entity"].se_allow_in_space = true
|
||||
data.raw["beacon"]["el_ki_beacon_entity"].allow_in_space = true
|
||||
data.raw["beacon"]["fi_ki_beacon_entity"].allow_in_space = true
|
||||
data.raw["beacon"]["fu_ki_beacon_entity"].allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["fi_crafter_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fi_crusher_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["fu_star_engine_core_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_star_engine_cooler_up_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_star_engine_cooler_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_star_engine_heater_left_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_star_engine_heater_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["fu_fusor_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_tokamak_reactor_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_stelar_reactor_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_activator_entity"].se_allow_in_space = true
|
||||
data.raw["assembling-machine"]["fu_exchanger_entity"].se_allow_in_space = true
|
||||
|
||||
data.raw["assembling-machine"]["gr_crafter_entity"].se_allow_in_space = true
|
141
scripts/bk_main.lua
Normal file
141
scripts/bk_main.lua
Normal file
File diff suppressed because one or more lines are too long
831
scripts/electronic/el_ki_script.lua
Normal file
831
scripts/electronic/el_ki_script.lua
Normal file
|
@ -0,0 +1,831 @@
|
|||
local util = require("util")
|
||||
local gui = require('scripts/gui')
|
||||
|
||||
--=================================================================================
|
||||
--init
|
||||
--=================================================================================
|
||||
|
||||
function el_ki_init(e)
|
||||
global.ki = {}
|
||||
global.ki.dirty = false
|
||||
global.ki.total = 0
|
||||
global.ki.channel = {}
|
||||
global.ki.core = {}
|
||||
global.ki.beacon = {}
|
||||
global.ki.buffer1 = {}
|
||||
global.ki.buffer2 = {}
|
||||
global.ki.supported = 100
|
||||
global.ki.supported1 = false
|
||||
global.ki.supported2 = false
|
||||
global.ki.supported3 = false
|
||||
global.ki.supported4 = false
|
||||
|
||||
--base channel
|
||||
global.ki.channel[0] = {}
|
||||
global.ki.channel[0].beacons = {}
|
||||
global.ki.channel[0].core = {}
|
||||
global.ki.channel[0].buffer1 = {}
|
||||
global.ki.channel[0].buffer2 = {}
|
||||
|
||||
global.ki.standardchannel = 0
|
||||
global.ki.selectchannel = 0
|
||||
|
||||
--gui stuff
|
||||
global.ki.gui = {}
|
||||
global.ki.gui.core = {}
|
||||
global.ki.gui.main = {}
|
||||
global.ki.gui.buffer1 = {}
|
||||
global.ki.gui.buffer2 = {}
|
||||
end
|
||||
|
||||
|
||||
--=================================================================================
|
||||
--on built
|
||||
--=================================================================================
|
||||
|
||||
function el_ki_on_built(e)
|
||||
|
||||
if e['created_entity'] then
|
||||
if e['created_entity'].name == 'el_ki_core_entity' then
|
||||
make_ki_core(e['created_entity'])
|
||||
end
|
||||
if e['created_entity'].name == 'el_ki_beacon_entity' then
|
||||
make_ki_beacon(e['created_entity'])
|
||||
end
|
||||
|
||||
if e['created_entity'].name == 'fi_ki_core_entity' then
|
||||
make_ki_buffer1(e['created_entity'])
|
||||
end
|
||||
if e['created_entity'].name == 'fi_ki_beacon_entity' then
|
||||
make_ki_beacon(e['created_entity'])
|
||||
end
|
||||
|
||||
if e['created_entity'].name == 'fu_ki_core_entity' then
|
||||
make_ki_buffer2(e['created_entity'])
|
||||
end
|
||||
if e['created_entity'].name == 'fu_ki_beacon_entity' then
|
||||
make_ki_beacon(e['created_entity'])
|
||||
end
|
||||
end
|
||||
|
||||
if e['entity'] then
|
||||
if e['entity'].name == 'el_ki_core_entity' then
|
||||
make_ki_core(e['entity'])
|
||||
end
|
||||
if e['entity'].name == 'el_ki_beacon_entity' then
|
||||
make_ki_beacon(e['entity'])
|
||||
end
|
||||
|
||||
if e['entity'].name == 'fi_ki_core_entity' then
|
||||
make_ki_buffer1(e['entity'])
|
||||
end
|
||||
if e['entity'].name == 'fi_ki_beacon_entity' then
|
||||
make_ki_beacon(e['entity'])
|
||||
end
|
||||
|
||||
if e['entity'].name == 'fu_ki_core_entity' then
|
||||
make_ki_buffer2(e['entity'])
|
||||
end
|
||||
if e['entity'].name == 'fu_ki_beacon_entity' then
|
||||
make_ki_beacon(e['entity'])
|
||||
end
|
||||
end
|
||||
|
||||
if e['entity'] then
|
||||
if e['entity'].name == "entity-ghost" then
|
||||
remove_request_ghost(e['entity'])
|
||||
end
|
||||
end
|
||||
|
||||
if e['created_entity'] then
|
||||
if e['created_entity'].name == "entity-ghost" then
|
||||
remove_request_ghost(e['created_entity'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--on remove
|
||||
--=================================================================================
|
||||
|
||||
function el_ki_on_remove(e)
|
||||
if e["entity"] then
|
||||
if e["entity"].name == "el_ki_core_entity" then
|
||||
if e["player_index"] then
|
||||
destroy_ki_core(e["entity"],e["player_index"],nil)
|
||||
elseif e["robot"] then
|
||||
destroy_ki_core(e["entity"],nil,e["robot"])
|
||||
else
|
||||
destroy_ki_core(e["entity"],nil,nil)
|
||||
end
|
||||
end
|
||||
|
||||
if e["entity"].name == "fi_ki_core_entity" then
|
||||
if e["player_index"] then
|
||||
destroy_fi_core(e["entity"],e["player_index"],nil)
|
||||
elseif e["robot"] then
|
||||
destroy_fi_core(e["entity"],nil,e["robot"])
|
||||
else
|
||||
destroy_fi_core(e["entity"],nil,nil)
|
||||
end
|
||||
end
|
||||
|
||||
if e["entity"].name == "fu_ki_core_entity" then
|
||||
if e["player_index"] then
|
||||
destroy_fu_core(e["entity"],e["player_index"],nil)
|
||||
elseif e["robot"] then
|
||||
destroy_fu_core(e["entity"],nil,e["robot"])
|
||||
else
|
||||
destroy_fu_core(e["entity"],nil,nil)
|
||||
end
|
||||
end
|
||||
|
||||
if (e["entity"].name == "el_ki_beacon_entity") or (e["entity"].name == "fi_ki_beacon_entity") or (e["entity"].name == "fu_ki_beacon_entity") then
|
||||
destroy_ki_beacon(e["entity"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--make
|
||||
--=================================================================================
|
||||
|
||||
function make_ki_core(entity)
|
||||
register_ki_core(entity)
|
||||
make_slave_ki_core(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function make_ki_buffer1(entity)
|
||||
register_ki_buffer1(entity)
|
||||
make_slave_ki_buffer1(entity)
|
||||
make_container_ki_buffer1(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function make_ki_buffer2(entity)
|
||||
register_ki_buffer2(entity)
|
||||
make_slave_ki_buffer2(entity)
|
||||
make_container_ki_buffer2(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function make_ki_beacon(entity)
|
||||
register_ki_beacon(entity)
|
||||
el_ki_single_beacon_update(entity.unit_number)
|
||||
gui.update_main()
|
||||
end
|
||||
|
||||
function destroy_ki_core(entity,player_index,robot)
|
||||
if not global.ki.core[entity.unit_number] then
|
||||
return
|
||||
end
|
||||
if not global.ki.core[entity.unit_number].slave then
|
||||
return
|
||||
end
|
||||
destroy_slave_ki_core(entity,global.ki.core[entity.unit_number].slave,player_index,robot)
|
||||
unregister_ki_core(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function destroy_fi_core(entity,player_index,robot)
|
||||
if not global.ki.buffer1[entity.unit_number] then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer1[entity.unit_number].slave then
|
||||
return
|
||||
end
|
||||
destroy_slave_ki_core(entity,global.ki.buffer1[entity.unit_number].slave,player_index,robot)
|
||||
destroy_slave_ki_core(entity,global.ki.buffer1[entity.unit_number].container,player_index,robot)
|
||||
unregister_ki_buffer1(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function destroy_fu_core(entity,player_index,robot)
|
||||
if not global.ki.buffer2[entity.unit_number] then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer2[entity.unit_number].slave then
|
||||
return
|
||||
end
|
||||
destroy_slave_ki_core(entity,global.ki.buffer2[entity.unit_number].slave,player_index,robot)
|
||||
destroy_slave_ki_core(entity,global.ki.buffer2[entity.unit_number].container,player_index,robot)
|
||||
unregister_ki_buffer2(entity)
|
||||
global.ki.dirty = true
|
||||
--gui.update_main()
|
||||
end
|
||||
|
||||
function destroy_ki_beacon(entity)
|
||||
clear_ki_beacon(entity)
|
||||
unregister_ki_beacon(entity)
|
||||
count_supported_beacons()
|
||||
gui.update_main()
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--register
|
||||
--=================================================================================
|
||||
|
||||
function register_ki_core(entity)
|
||||
local unit = entity.unit_number
|
||||
local channel = make_channel(unit)
|
||||
|
||||
global.ki.core[unit] = {}
|
||||
global.ki.core[unit].entity = entity
|
||||
global.ki.core[unit].channel = channel
|
||||
global.ki.core[unit].modules = {}
|
||||
global.ki.core[unit].oldmodules = {}
|
||||
global.ki.core[unit].active = false
|
||||
|
||||
if global.ki.standardchannel == 0 then
|
||||
global.ki.standardchannel = channel
|
||||
end
|
||||
end
|
||||
|
||||
function register_ki_buffer1(entity)
|
||||
local unit = entity.unit_number
|
||||
local standardchannel = global.ki.standardchannel
|
||||
|
||||
global.ki.buffer1[unit] = {}
|
||||
global.ki.buffer1[unit].entity = entity
|
||||
global.ki.buffer1[unit].channel = 0
|
||||
global.ki.buffer1[unit].modules = {}
|
||||
global.ki.buffer1[unit].oldmodules = {}
|
||||
global.ki.buffer1[unit].active = false
|
||||
|
||||
if not (standardchannel == 0) then
|
||||
if not global.ki.channel[standardchannel].buffer1 then
|
||||
global.ki.channel[standardchannel].buffer1 = unit
|
||||
global.ki.buffer1[unit].channel = standardchannel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function register_ki_buffer2(entity)
|
||||
local unit = entity.unit_number
|
||||
local standardchannel = global.ki.standardchannel
|
||||
|
||||
global.ki.buffer2[unit] = {}
|
||||
global.ki.buffer2[unit].entity = entity
|
||||
global.ki.buffer2[unit].channel = 0
|
||||
global.ki.buffer2[unit].modules = {}
|
||||
global.ki.buffer2[unit].oldmodules = {}
|
||||
global.ki.buffer2[unit].totalmodules = {}
|
||||
global.ki.buffer2[unit].active = false
|
||||
|
||||
if not (standardchannel == 0) then
|
||||
if not global.ki.channel[standardchannel].buffer2 then
|
||||
global.ki.channel[standardchannel].buffer2 = unit
|
||||
global.ki.buffer2[unit].channel = standardchannel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function register_ki_beacon(entity)
|
||||
local unit = entity.unit_number
|
||||
|
||||
global.ki.beacon[unit] = {}
|
||||
global.ki.beacon[unit].entity = entity
|
||||
global.ki.beacon[unit].channel = global.ki.standardchannel
|
||||
|
||||
add_to_supported(unit)
|
||||
global.ki.beacon[unit].supported = is_beacon_supported()
|
||||
|
||||
entity.operable = false
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--unregister
|
||||
--=================================================================================
|
||||
|
||||
function unregister_ki_core(entity)
|
||||
local id = entity.unit_number
|
||||
|
||||
if not global.ki then
|
||||
return
|
||||
end
|
||||
if not global.ki.core then
|
||||
return
|
||||
end
|
||||
if not global.ki.core[id] then
|
||||
return
|
||||
end
|
||||
if not global.ki.core[id].channel then
|
||||
return
|
||||
end
|
||||
|
||||
local channel = global.ki.core[id].channel
|
||||
|
||||
global.ki.core[id] = nil
|
||||
global.ki.channel[channel].core = nil
|
||||
end
|
||||
|
||||
function unregister_ki_buffer1(entity)
|
||||
local id = entity.unit_number
|
||||
|
||||
if not global.ki then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer1 then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer1[id] then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer1[id].channel then
|
||||
return
|
||||
end
|
||||
|
||||
local channel = global.ki.buffer1[id].channel
|
||||
|
||||
global.ki.buffer1[id] = nil
|
||||
global.ki.channel[channel].buffer1 = nil
|
||||
end
|
||||
|
||||
function unregister_ki_buffer2(entity)
|
||||
local id = entity.unit_number
|
||||
|
||||
if not global.ki then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer2 then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer2[id] then
|
||||
return
|
||||
end
|
||||
if not global.ki.buffer2[id].channel then
|
||||
return
|
||||
end
|
||||
|
||||
local channel = global.ki.buffer2[id].channel
|
||||
|
||||
global.ki.buffer2[id] = nil
|
||||
global.ki.channel[channel].buffer2 = nil
|
||||
end
|
||||
|
||||
function unregister_ki_beacon(entity)
|
||||
local id = entity.unit_number
|
||||
|
||||
if not global.ki then
|
||||
return
|
||||
end
|
||||
if not global.ki.beacon then
|
||||
return
|
||||
end
|
||||
if not global.ki.beacon[id] then
|
||||
return
|
||||
end
|
||||
if not global.ki.beacon[id].channel then
|
||||
return
|
||||
end
|
||||
|
||||
local channel = global.ki.beacon[id].channel
|
||||
|
||||
global.ki.beacon[id] = nil
|
||||
for i,v in pairs(global.ki.channel[channel].beacons) do
|
||||
if v == id then
|
||||
table.remove(global.ki.channel[channel].beacons, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--update
|
||||
--=================================================================================
|
||||
function el_ki_core_working()
|
||||
for i in pairs(global.ki.core) do
|
||||
if global.ki.core[i].entity.valid then
|
||||
local oldactive = global.ki.core[i].active
|
||||
global.ki.core[i].active = global.ki.core[i].entity.is_crafting()
|
||||
|
||||
if not oldactive == global.ki.core[i].active then
|
||||
global.ki.dirty = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_buffer1_working()
|
||||
for i in pairs(global.ki.buffer1) do
|
||||
if global.ki.buffer1[i].entity.valid then
|
||||
local oldactive = global.ki.buffer1[i].active
|
||||
global.ki.buffer1[i].active = global.ki.buffer1[i].entity.is_crafting()
|
||||
|
||||
if not oldactive == global.ki.buffer1[i].active then
|
||||
global.ki.dirty = true
|
||||
end
|
||||
|
||||
if global.ki.buffer1[i].entity.products_finished >= 3 then
|
||||
if global.ki.buffer1[i].container then
|
||||
local container = global.ki.buffer1[i].container
|
||||
local container_inv = container.get_inventory(defines.inventory.chest)
|
||||
|
||||
if container_inv.can_insert({name='fi_ki_science', count=1}) then
|
||||
container_inv.insert({name='fi_ki_science', count=1})
|
||||
global.ki.buffer1[i].entity.products_finished = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_buffer2_working()
|
||||
for i in pairs(global.ki.buffer2) do
|
||||
if global.ki.buffer2[i].entity.valid then
|
||||
local oldactive = global.ki.buffer2[i].active
|
||||
global.ki.buffer2[i].active = global.ki.buffer2[i].entity.is_crafting()
|
||||
|
||||
if not oldactive == global.ki.buffer2[i].active then
|
||||
global.ki.dirty = true
|
||||
end
|
||||
|
||||
if global.ki.buffer2[i].entity.products_finished >= 3 then
|
||||
if global.ki.buffer2[i].container then
|
||||
local container = global.ki.buffer2[i].container
|
||||
local container_inv = container.get_inventory(defines.inventory.chest)
|
||||
|
||||
if container_inv.can_insert({name='fu_ki_science', count=1}) then
|
||||
container_inv.insert({name='fu_ki_science', count=1})
|
||||
global.ki.buffer2[i].entity.products_finished = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_core_update()
|
||||
for i in pairs(global.ki.core) do
|
||||
|
||||
global.ki.core[i].oldmodules = util.table.deepcopy(global.ki.core[i].modules)
|
||||
|
||||
if global.ki.core[i].slave then
|
||||
if global.ki.core[i].slave.valid then
|
||||
local slaveinv = global.ki.core[i].slave.get_module_inventory()
|
||||
local slavemodules = slaveinv.get_contents()
|
||||
global.ki.core[i].modules = {}
|
||||
|
||||
for x,v in pairs(slavemodules) do
|
||||
for f=1,v,1 do
|
||||
table.insert(global.ki.core[i].modules,x)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not (#global.ki.core[i].modules == #global.ki.core[i].oldmodules) then
|
||||
global.ki.dirty = true
|
||||
else
|
||||
for x,v in pairs(global.ki.core[i].modules) do
|
||||
if not v == global.ki.core[i].oldmodules[x] then
|
||||
global.ki.dirty = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_buffer1_update()
|
||||
for i in pairs(global.ki.buffer1) do
|
||||
|
||||
global.ki.buffer1[i].oldmodules = util.table.deepcopy(global.ki.buffer1[i].modules)
|
||||
|
||||
if global.ki.buffer1[i].slave then
|
||||
if global.ki.buffer1[i].slave.valid then
|
||||
local slaveinv = global.ki.buffer1[i].slave.get_module_inventory()
|
||||
local slavemodules = slaveinv.get_contents()
|
||||
global.ki.buffer1[i].modules = {}
|
||||
|
||||
for x,v in pairs(slavemodules) do
|
||||
for f=1,v,1 do
|
||||
table.insert(global.ki.buffer1[i].modules,x)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not (#global.ki.buffer1[i].modules == #global.ki.buffer1[i].oldmodules) then
|
||||
global.ki.dirty = true
|
||||
else
|
||||
for x,v in pairs(global.ki.buffer1[i].modules) do
|
||||
if not v == global.ki.buffer1[i].oldmodules[x] then
|
||||
global.ki.dirty = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_buffer2_update()
|
||||
for i in pairs(global.ki.buffer2) do
|
||||
|
||||
global.ki.buffer2[i].oldmodules = util.table.deepcopy(global.ki.buffer2[i].modules)
|
||||
|
||||
if global.ki.buffer2[i].slave then
|
||||
if global.ki.buffer2[i].slave.valid then
|
||||
local slaveinv = global.ki.buffer2[i].slave.get_module_inventory()
|
||||
local slavemodules = slaveinv.get_contents()
|
||||
global.ki.buffer2[i].modules = {}
|
||||
|
||||
for x,v in pairs(slavemodules) do
|
||||
for f=1,v,1 do
|
||||
table.insert(global.ki.buffer2[i].modules,x)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not (#global.ki.buffer2[i].modules == #global.ki.buffer2[i].oldmodules) then
|
||||
global.ki.dirty = true
|
||||
else
|
||||
for x,v in pairs(global.ki.buffer2[i].modules) do
|
||||
if not v == global.ki.buffer2[i].oldmodules[x] then
|
||||
global.ki.dirty = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_beacon_update()
|
||||
el_ki_buffer1_adder()
|
||||
for i,v in pairs(global.ki.beacon) do
|
||||
el_ki_single_beacon_update(i)
|
||||
end
|
||||
end
|
||||
|
||||
function el_ki_single_beacon_update(id)
|
||||
if global.ki.beacon[id].supported then
|
||||
if global.ki.beacon[id].entity.valid then
|
||||
local beacon_entity = global.ki.beacon[id].entity
|
||||
local beacon_inv = beacon_entity.get_module_inventory()
|
||||
local channel = global.ki.beacon[id].channel
|
||||
|
||||
beacon_inv.clear()
|
||||
|
||||
if global.ki.channel[channel].core then
|
||||
local coreunit = global.ki.channel[channel].core
|
||||
if global.ki.core[coreunit] then
|
||||
if global.ki.core[coreunit].active then
|
||||
for i,v in pairs(global.ki.core[coreunit].totalmodules) do
|
||||
if beacon_inv.can_insert({name=global.ki.core[coreunit].totalmodules[i], count=1}) then
|
||||
beacon_inv.insert({name=global.ki.core[coreunit].totalmodules[i], count=1})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--util
|
||||
--=================================================================================
|
||||
function remove_request_ghost(entity)
|
||||
if (entity.ghost_name == "el_ki_beacon_entity") or (entity.ghost_name == "fi_ki_beacon_entity") or (entity.ghost_name == "fu_ki_beacon_entity") then
|
||||
if entity.item_requests then
|
||||
entity.item_requests = {}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function el_ki_buffer1_adder()
|
||||
for i,v in pairs(global.ki.channel) do
|
||||
if not (i == 0) then
|
||||
if global.ki.channel[i].core then
|
||||
|
||||
local coreid = global.ki.channel[i].core
|
||||
global.ki.core[coreid].totalmodules = {}
|
||||
|
||||
|
||||
for x,f in pairs(global.ki.core[coreid].modules) do
|
||||
table.insert(global.ki.core[coreid].totalmodules,f)
|
||||
end
|
||||
|
||||
|
||||
if global.ki.channel[i].buffer1 then
|
||||
local buffer1id = global.ki.channel[i].buffer1
|
||||
if global.ki.buffer1[buffer1id].active == true then
|
||||
for x,f in pairs(global.ki.buffer1[buffer1id].modules) do
|
||||
table.insert(global.ki.core[coreid].totalmodules,f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.ki.channel[i].buffer2 then
|
||||
local buffer2id = global.ki.channel[i].buffer2
|
||||
if global.ki.buffer2[buffer2id].active == true then
|
||||
for x,f in pairs(global.ki.buffer2[buffer2id].modules) do
|
||||
table.insert(global.ki.core[coreid].totalmodules,f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if game.forces[1] then
|
||||
if game.forces[1].technologies['fu_ki_plus_2_tech'].researched then
|
||||
local moduletable = {}
|
||||
for _,v in pairs(global.ki.core[coreid].totalmodules) do
|
||||
table.insert(moduletable, v)
|
||||
table.insert(moduletable, v)
|
||||
table.insert(moduletable, v)
|
||||
end
|
||||
|
||||
global.ki.core[coreid].totalmodules = moduletable
|
||||
elseif game.forces[1].technologies['fu_ki_plus_1_tech'].researched then
|
||||
local moduletable = {}
|
||||
for _,v in pairs(global.ki.core[coreid].totalmodules) do
|
||||
table.insert(moduletable, v)
|
||||
table.insert(moduletable, v)
|
||||
end
|
||||
|
||||
global.ki.core[coreid].totalmodules = moduletable
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function make_channel(unit)
|
||||
if global.ki.channel then
|
||||
local max = #global.ki.channel + 1
|
||||
|
||||
global.ki.channel[max] = {}
|
||||
global.ki.channel[max].core = unit
|
||||
global.ki.channel[max].buffer1 = nil
|
||||
global.ki.channel[max].buffer2 = nil
|
||||
global.ki.channel[max].beacons = {}
|
||||
|
||||
return max
|
||||
end
|
||||
end
|
||||
|
||||
function count_supported_beacons()
|
||||
local count = 0
|
||||
for i,v in pairs(global.ki.channel) do
|
||||
--if not (i == 0) then
|
||||
if #global.ki.channel[i].beacons then
|
||||
count = count + #global.ki.channel[i].beacons
|
||||
end
|
||||
--end
|
||||
end
|
||||
global.ki.total = count
|
||||
return count
|
||||
end
|
||||
|
||||
function is_beacon_supported()
|
||||
if global.ki.supported >= count_supported_beacons() then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function add_to_supported(id)
|
||||
local channel = global.ki.beacon[id].channel
|
||||
table.insert(global.ki.channel[channel].beacons, id)
|
||||
end
|
||||
|
||||
function el_ki_supported_adder()
|
||||
if global.ki.supported1 == false then
|
||||
if game.forces[1] then
|
||||
if game.forces[1].technologies['el_ki_sup_1_tech'].researched then
|
||||
global.ki.supported1 = true
|
||||
global.ki.supported = global.ki.supported + 150
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.ki.supported2 == false then
|
||||
if game.forces[1] then
|
||||
if game.forces[1].technologies['el_ki_sup_2_tech'].researched then
|
||||
global.ki.supported2 = true
|
||||
global.ki.supported = global.ki.supported + 250
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.ki.supported3 == false then
|
||||
if game.forces[1] then
|
||||
if game.forces[1].technologies['el_ki_sup_3_tech'].researched then
|
||||
global.ki.supported3 = true
|
||||
global.ki.supported = global.ki.supported + 500
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.ki.supported4 == false then
|
||||
if game.forces[1] then
|
||||
if game.forces[1].technologies['el_ki_sup_4_tech'].researched then
|
||||
global.ki.supported4 = true
|
||||
global.ki.supported = 65535
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--slaves
|
||||
--=================================================================================
|
||||
|
||||
function make_slave_ki_core(entity)
|
||||
local pos = entity.position
|
||||
local slave = entity.surface.create_entity{
|
||||
name = 'el_ki_core_slave_entity',
|
||||
position = pos,
|
||||
force = entity.force
|
||||
}
|
||||
slave.destructible = false
|
||||
global.ki.core[entity.unit_number]["slave"] = slave
|
||||
end
|
||||
|
||||
function make_slave_ki_buffer1(entity)
|
||||
local pos = entity.position
|
||||
local slave = entity.surface.create_entity{
|
||||
name = 'fi_ki_core_slave_entity',
|
||||
position = pos,
|
||||
force = entity.force
|
||||
}
|
||||
slave.destructible = false
|
||||
global.ki.buffer1[entity.unit_number]["slave"] = slave
|
||||
end
|
||||
|
||||
function make_container_ki_buffer1(entity)
|
||||
local pos = {entity.position.x, entity.position.y + 2}
|
||||
local container = entity.surface.create_entity{
|
||||
name = 'fi_ki_core_slave_container_entity',
|
||||
position = pos,
|
||||
force = entity.force
|
||||
}
|
||||
container.destructible = false
|
||||
global.ki.buffer1[entity.unit_number]["container"] = container
|
||||
end
|
||||
|
||||
function make_slave_ki_buffer2(entity)
|
||||
local pos = entity.position
|
||||
local slave = entity.surface.create_entity{
|
||||
name = 'fu_ki_core_slave_entity',
|
||||
position = pos,
|
||||
force = entity.force
|
||||
}
|
||||
slave.destructible = false
|
||||
global.ki.buffer2[entity.unit_number]["slave"] = slave
|
||||
end
|
||||
|
||||
function make_container_ki_buffer2(entity)
|
||||
local pos = {entity.position.x, entity.position.y + 2}
|
||||
local container = entity.surface.create_entity{
|
||||
name = 'fu_ki_core_slave_container_entity',
|
||||
position = pos,
|
||||
force = entity.force
|
||||
}
|
||||
container.destructible = false
|
||||
global.ki.buffer2[entity.unit_number]["container"] = container
|
||||
end
|
||||
|
||||
function destroy_slave_ki_core(entity,slave,plyer_index,robot)
|
||||
local id = entity.unit_number
|
||||
local success = false
|
||||
|
||||
if player_index then
|
||||
if game.get_player(player_index).character then
|
||||
if game.get_player(player_index).character.get_main_inventory() then
|
||||
success = slave.mine({inventory=game.get_player(player_index).character.get_main_inventory()})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if robot then
|
||||
if robot.get_inventory(defines.inventory.robot_cargo) then
|
||||
success = slave.mine({inventory=robot.get_inventory(defines.inventory.robot_cargo)})
|
||||
end
|
||||
end
|
||||
|
||||
if not success then
|
||||
slave.get_inventory(defines.inventory.chest).clear()
|
||||
slave.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function clear_ki_beacon(entity)
|
||||
entity.get_module_inventory().clear()
|
||||
end
|
364
scripts/gravitation/gr_black_hole_script.lua
Normal file
364
scripts/gravitation/gr_black_hole_script.lua
Normal file
|
@ -0,0 +1,364 @@
|
|||
--local gr_gui = require('scripts/gravitation/gui')
|
||||
--===================================================================================================================
|
||||
--TODO
|
||||
--===================================================================================================================
|
||||
|
||||
--init global
|
||||
--when builded register
|
||||
--when destroyed unregister
|
||||
|
||||
--build gui when base opend
|
||||
--start button
|
||||
|
||||
--spawn, register energy
|
||||
--check nth tick for stabilizer and other
|
||||
|
||||
--calc output, stable
|
||||
--write in global
|
||||
|
||||
--output power, clear inv
|
||||
|
||||
--===================================================================================================================
|
||||
--init
|
||||
--===================================================================================================================
|
||||
|
||||
function gr_black_hole_init()
|
||||
global.black_hole = {}
|
||||
global.black_hole.base = {}
|
||||
global.black_hole.energy = {}
|
||||
global.black_hole.dirty = false
|
||||
global.black_hole.counter = 0
|
||||
|
||||
global.black_hole.gui = {}
|
||||
global.black_hole.gui.frame = nil
|
||||
global.black_hole.gui.id = nil
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--on built
|
||||
--===================================================================================================================
|
||||
|
||||
function gr_black_hole_on_built(e)
|
||||
if e['entity'] then
|
||||
if e['entity'].name == "gr_black_hole_base_entity" then
|
||||
make_black_hole(e['entity'])
|
||||
--game.print("make")
|
||||
end
|
||||
end
|
||||
|
||||
if e['created_entity'] then
|
||||
if e['created_entity'].name == "gr_black_hole_base_entity" then
|
||||
make_black_hole(e['created_entity'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--on remove
|
||||
--===================================================================================================================
|
||||
|
||||
function gr_black_hole_on_remove(e)
|
||||
if e["entity"] then
|
||||
if e["entity"].name == "gr_black_hole_base_entity" then
|
||||
if e["player_index"] then
|
||||
destroy_black_hole(e["entity"],e["player_index"],nil)
|
||||
elseif e["robot"] then
|
||||
destroy_black_hole(e["entity"],nil,e["robot"])
|
||||
else
|
||||
destroy_black_hole(e["entity"],nil,nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--make
|
||||
--===================================================================================================================
|
||||
|
||||
function make_black_hole(entity)
|
||||
register_black_hole_base(entity)
|
||||
|
||||
global.black_hole.dirty = true
|
||||
--gr_gui.update_main()
|
||||
end
|
||||
|
||||
function make_black_hole_energy(base_entity)
|
||||
local slave = create_black_hole_energy(base_entity)
|
||||
register_black_hole_energy(slave)
|
||||
link_base_energy(base_entity,slave)
|
||||
--game.print("from make: "..slave.unit_number)
|
||||
|
||||
global.black_hole.dirty = true
|
||||
--gr_gui.update_main()
|
||||
end
|
||||
--===================================================================================================================
|
||||
--destoy
|
||||
--===================================================================================================================
|
||||
|
||||
function destroy_black_hole(entity,player,robot)
|
||||
local slave = nil
|
||||
|
||||
if global.black_hole.base then
|
||||
if global.black_hole.base[entity.unit_number] then
|
||||
|
||||
if global.black_hole.base[entity.unit_number].energy then
|
||||
if global.black_hole.energy[global.black_hole.base[entity.unit_number].energy] then
|
||||
if global.black_hole.energy[global.black_hole.base[entity.unit_number].energy].entity then
|
||||
slave = global.black_hole.energy[global.black_hole.base[entity.unit_number].energy].entity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unregister_black_hole(entity)
|
||||
if slave then
|
||||
destroy_energy(slave)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
global.black_hole.dirty = true
|
||||
--gr_gui.update_main()
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--register
|
||||
--===================================================================================================================
|
||||
|
||||
function register_black_hole_base(entity)
|
||||
local unit = entity.unit_number
|
||||
|
||||
global.black_hole.base[unit] = {}
|
||||
global.black_hole.base[unit].entity = entity
|
||||
global.black_hole.base[unit].energy = nil
|
||||
|
||||
global.black_hole.base[unit].active = false
|
||||
|
||||
--game.print("register base: "..unit)
|
||||
end
|
||||
|
||||
function register_black_hole_energy(entity)
|
||||
local unit = entity.unit_number
|
||||
|
||||
global.black_hole.energy[unit] = {}
|
||||
global.black_hole.energy[unit].entity = entity
|
||||
global.black_hole.energy[unit].base = nil
|
||||
global.black_hole.energy[unit].total = 0
|
||||
global.black_hole.energy[unit].stabilizers = 100
|
||||
global.black_hole.energy[unit].power_gen = 0
|
||||
global.black_hole.energy[unit].matter_consumption = 0
|
||||
global.black_hole.energy[unit].stable = 0
|
||||
|
||||
--game.print("from erngy make: "..unit)
|
||||
end
|
||||
|
||||
function link_base_energy(base_entity,energy)
|
||||
local unit_base = base_entity.unit_number
|
||||
local unit_energy = energy.unit_number
|
||||
if global.black_hole.base[unit_base] then
|
||||
if global.black_hole.energy[unit_energy] then
|
||||
global.black_hole.base[unit_base].energy = unit_energy
|
||||
global.black_hole.energy[unit_energy].base = unit_base
|
||||
global.black_hole.base[unit_base].active = true
|
||||
end
|
||||
end
|
||||
end
|
||||
--===================================================================================================================
|
||||
--unregister
|
||||
--===================================================================================================================
|
||||
|
||||
function unregister_black_hole(entity)
|
||||
local unit = entity.unit_number
|
||||
if global.black_hole.base[unit].energy then
|
||||
--game.print("unregister base.energy: "..global.black_hole.base[unit].energy)
|
||||
unregister_black_hole_energy(nil,global.black_hole.base[unit].energy)
|
||||
unregister_black_hole_base(entity,nil)
|
||||
else
|
||||
--game.print("2")
|
||||
unregister_black_hole_base(entity,nil)
|
||||
end
|
||||
end
|
||||
|
||||
function unregister_black_hole_base(entity,unitin)
|
||||
local unit = nil
|
||||
if entity then
|
||||
unit = entity.unit_number
|
||||
else
|
||||
unit = unitin
|
||||
end
|
||||
global.black_hole.base[unit] = nil
|
||||
|
||||
--game.print(unit)
|
||||
|
||||
if global.black_hole.energy then
|
||||
for i,v in pairs(global.black_hole.energy) do
|
||||
if global.black_hole.energy[i].base == unit then
|
||||
global.black_hole.energy[i].base = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function unregister_black_hole_energy(entity,unitin)
|
||||
local unit = nil
|
||||
if entity then
|
||||
unit = entity.unit_number
|
||||
--game.print("entity")
|
||||
else
|
||||
unit = unitin
|
||||
--game.print("unitin")
|
||||
end
|
||||
global.black_hole.energy[unit] = nil
|
||||
|
||||
if global.black_hole.base then
|
||||
for i,v in pairs(global.black_hole.base) do
|
||||
if global.black_hole.base[i].energy == unit then
|
||||
global.black_hole.base[i].energy = nil
|
||||
global.black_hole.base[i].active = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--slaves
|
||||
--===================================================================================================================
|
||||
|
||||
function create_black_hole_energy(base_entity)
|
||||
local pos = base_entity.position
|
||||
local slave = base_entity.surface.create_entity{
|
||||
name = 'gr_black_hole_energy_entity',
|
||||
position = pos,
|
||||
force = base_entity.force
|
||||
}
|
||||
slave.destructible = false
|
||||
return slave
|
||||
end
|
||||
|
||||
function destroy_energy(entity)
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
|
||||
--===================================================================================================================
|
||||
--update
|
||||
--===================================================================================================================
|
||||
|
||||
function black_hole_base_update()
|
||||
if global.black_hole then
|
||||
if global.black_hole.base then
|
||||
for i,v in pairs(global.black_hole.base) do
|
||||
if global.black_hole.base[i].entity then
|
||||
if global.black_hole.base[i].entity.valid then
|
||||
if global.black_hole.base[i].energy then
|
||||
local energy = global.black_hole.base[i].energy
|
||||
local entity = global.black_hole.base[i].entity
|
||||
local inv = entity.get_inventory(defines.inventory.chest)
|
||||
|
||||
local total = global.black_hole.energy[energy].total
|
||||
local stable = global.black_hole.energy[energy].stable
|
||||
local power_gen, matter_consumption = calc_black_hole_stats(stable)
|
||||
|
||||
|
||||
local new_matter = inv.get_item_count() - inv.get_item_count("gr_materials_stabilizer_item")
|
||||
local new_stabilizer = inv.get_item_count("gr_materials_stabilizer_item")
|
||||
|
||||
stable = stable - 1
|
||||
if total then
|
||||
if stabilizer then
|
||||
stable = stable + new_stabilizer
|
||||
end
|
||||
end
|
||||
if stable >= 100 then
|
||||
stable = 100
|
||||
end
|
||||
|
||||
total = total - matter_consumption + new_matter
|
||||
|
||||
global.black_hole.energy[energy].power_gen = power_gen
|
||||
global.black_hole.energy[energy].matter_consumption = matter_consumption
|
||||
global.black_hole.energy[energy].stable = stable
|
||||
global.black_hole.energy[energy].total = total
|
||||
|
||||
--game.print(stable.." "..power_gen.." "..total)
|
||||
|
||||
black_hole_make_energy(energy, power_gen)
|
||||
|
||||
inv.clear()
|
||||
|
||||
if (total <= 0) or (stable <= 0) then
|
||||
global.black_hole.counter = global.black_hole.counter + 1
|
||||
if global.black_hole.counter == 10 then
|
||||
local energy_entity = global.black_hole.energy[energy].entity
|
||||
unregister_black_hole_energy(energy_entity)
|
||||
energy_entity.destroy()
|
||||
global.black_hole.counter = 0
|
||||
end
|
||||
end
|
||||
global.black_hole.dirty = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--===================================================================================================================
|
||||
--util
|
||||
--===================================================================================================================
|
||||
|
||||
function can_make_black_hole_energy(entity)
|
||||
if entity.valid then
|
||||
inv = entity.get_inventory(defines.inventory.chest)
|
||||
total = inv.get_item_count() - inv.get_item_count("gr_materials_stabilizer_item")
|
||||
stabilizer = inv.get_item_count("gr_materials_stabilizer_item")
|
||||
if (stabilizer >= 100) and (total >= 1000) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function calc_black_hole_stats(stable)
|
||||
-- power_gen: Power gen/s in MW
|
||||
-- matter_consumption: matter consumed/s
|
||||
-- stable: max 100, each stabilizer put in will add 1 stable regardless
|
||||
-- every 10 ticks - 1
|
||||
|
||||
local matter_consumption_rate = black_hole_stable_function(stable)
|
||||
local power_gen = black_hole_energy_function(matter_consumption_rate)
|
||||
return power_gen, matter_consumption_rate
|
||||
end
|
||||
|
||||
function black_hole_stable_function(stable)
|
||||
--stable from 0 to 100
|
||||
if stable <= 0 then
|
||||
return 0
|
||||
end
|
||||
return stable
|
||||
end
|
||||
|
||||
function black_hole_energy_function(matter_consumption_rate)
|
||||
if matter_consumption_rate <= 0 then
|
||||
return 0
|
||||
end
|
||||
return (matter_consumption_rate * matter_consumption_rate * matter_consumption_rate) * 64 * 1000 * 0.3
|
||||
end
|
||||
|
||||
function black_hole_make_energy(energy, power_gen)
|
||||
if global.black_hole.energy[energy].entity then
|
||||
if global.black_hole.energy[energy].entity.valid then
|
||||
--game.print("spawn energy: "..power_gen.."W")
|
||||
local entity = global.black_hole.energy[energy].entity
|
||||
entity.power_production = power_gen
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--TODO
|
||||
|
||||
--k2 fix
|
||||
--KI tech description
|
36
scripts/gravitation/gr_make_white_hole_recipes.lua
Normal file
36
scripts/gravitation/gr_make_white_hole_recipes.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
function gr_make_white_hole_recipe(item)
|
||||
local blank = {
|
||||
name = 'blank',
|
||||
type = 'recipe',
|
||||
enabled = 'true',
|
||||
hidden = 'true',
|
||||
allow_as_intermediate = 'false',
|
||||
category = 'gr_white_hole_category',
|
||||
ingredients = {
|
||||
{'blank',1}
|
||||
},
|
||||
result = 'blank',
|
||||
result_count = 2,
|
||||
energy_required = 10,
|
||||
}
|
||||
blank["name"] = "gr_white_hole_cycle_"..item.."_recipe"
|
||||
blank["ingredients"] = {
|
||||
{item,1}
|
||||
}
|
||||
blank["result"] = item
|
||||
|
||||
--table.insert(data.raw.recipe, base)
|
||||
data:extend({blank})
|
||||
end
|
||||
|
||||
function gr_white_hole_recipe_generator()
|
||||
local items = data.raw.item
|
||||
for i,v in pairs(items) do
|
||||
if data.raw.item[i].stack_size > 1 then
|
||||
gr_make_white_hole_recipe(data.raw.item[i].name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
gr_white_hole_recipe_generator()
|
305
scripts/gravitation/gui.lua
Normal file
305
scripts/gravitation/gui.lua
Normal file
|
@ -0,0 +1,305 @@
|
|||
require('scripts/gravitation/gr_black_hole_script')
|
||||
local mod_gui = require("mod-gui")
|
||||
local gr_gui = {}
|
||||
|
||||
function gr_gui.add_black_hole_gui(e,update)
|
||||
local player = nil
|
||||
local id = nil
|
||||
local active = true
|
||||
local total = nil
|
||||
local stabilizer = nil
|
||||
|
||||
local power_gen = 0
|
||||
local matter_consumption = 0
|
||||
local stable = 0
|
||||
local totalmatter = 0
|
||||
|
||||
if update then
|
||||
player = e
|
||||
id = global.black_hole.gui.id
|
||||
if global.black_hole.base[id] then
|
||||
active = global.black_hole.base[id].active
|
||||
local entity = global.black_hole.base[id].entity
|
||||
local inv = entity.get_inventory(defines.inventory.chest)
|
||||
total = inv.get_item_count() - inv.get_item_count("gr_materials_stabilizer_item")
|
||||
stabilizer = inv.get_item_count("gr_materials_stabilizer_item")
|
||||
|
||||
if global.black_hole.base[id].energy then
|
||||
local energy = global.black_hole.base[id].energy
|
||||
power_gen = global.black_hole.energy[energy].power_gen
|
||||
matter_consumption = global.black_hole.energy[energy].matter_consumption
|
||||
stable = global.black_hole.energy[energy].stable
|
||||
totalmatter = global.black_hole.energy[energy].total
|
||||
end
|
||||
end
|
||||
else
|
||||
player = game.get_player(e["player_index"])
|
||||
id = e["entity"].unit_number
|
||||
if global.black_hole.base[id] then
|
||||
active = global.black_hole.base[id].active
|
||||
local entity = global.black_hole.base[id].entity
|
||||
local inv = entity.get_inventory(defines.inventory.chest)
|
||||
total = inv.get_item_count() - inv.get_item_count("gr_materials_stabilizer_item")
|
||||
stabilizer = inv.get_item_count("gr_materials_stabilizer_item")
|
||||
|
||||
if global.black_hole.base[id].energy then
|
||||
local energy = global.black_hole.base[id].energy
|
||||
power_gen = global.black_hole.energy[energy].power_gen
|
||||
matter_consumption = global.black_hole.energy[energy].matter_consumption
|
||||
stable = global.black_hole.energy[energy].stable
|
||||
totalmatter = global.black_hole.energy[energy].total
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--====================================
|
||||
--destroy and clear
|
||||
--====================================
|
||||
|
||||
if player.gui.left["main248kblackholeframe"] then
|
||||
player.gui.left["main248kblackholeframe"].destroy()
|
||||
global.black_hole.gui = {}
|
||||
return
|
||||
end
|
||||
|
||||
if global.black_hole then
|
||||
if global.black_hole.base then
|
||||
if not global.black_hole.base[id] then
|
||||
if player.gui.left["main248kblackholeframe"] then
|
||||
player.gui.left["main248kblackholeframe"].destroy()
|
||||
global.black_hole.gui = {}
|
||||
return
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local main248kblackholeframe = player.gui.left.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholeframe",
|
||||
caption = "Black hole generator: "
|
||||
})
|
||||
main248kblackholeframe.style.minimal_height = 10
|
||||
main248kblackholeframe.style.minimal_width = 10
|
||||
main248kblackholeframe.style.maximal_width = 320
|
||||
|
||||
local main248kblackholecontentframe = main248kblackholeframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholecontentframe",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding"
|
||||
})
|
||||
|
||||
local main248kblackholeonframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholeonframe",
|
||||
caption = "Status ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
|
||||
--local main248kblackholeontextfield = main248kblackholeonframe.add({
|
||||
-- type = "textfield",
|
||||
-- name = "main248kblackholeontextfield",
|
||||
-- numeric = "true",
|
||||
-- text = channel
|
||||
--})
|
||||
--main248kblackholeontextfield.style.maximal_width = 30
|
||||
|
||||
local main248kblackholeonbutton = nil
|
||||
if active == false then
|
||||
main248kblackholeonbutton = main248kblackholeonframe.add({
|
||||
type = "button",
|
||||
name = "main248kblackholeonbutton",
|
||||
caption = "Start",
|
||||
style = "confirm_button"
|
||||
})
|
||||
else
|
||||
main248kblackholeonbutton = main248kblackholeonframe.add({
|
||||
type = "button",
|
||||
name = "main248kblackholeonbutton",
|
||||
caption = "Stop",
|
||||
style = "red_confirm_button"
|
||||
})
|
||||
end
|
||||
|
||||
local main248kblackholestabilizerframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholestabilizerframe",
|
||||
caption = "Core stabilizers: ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kblackholestabilizerbar = main248kblackholestabilizerframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholestatstabilizerbar",
|
||||
--caption = "Core stabilizers: ",
|
||||
value = stabilizer/100,
|
||||
direction = "horizontal",
|
||||
style = "electric_satisfaction_in_description_progressbar"
|
||||
})
|
||||
|
||||
local main248kblackholetotalframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholetotalframe",
|
||||
caption = "Consumable matter: ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
local main248kblackholetotalbar = nil
|
||||
if active == false then
|
||||
main248kblackholetotalbar = main248kblackholetotalframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholetotalbar",
|
||||
--caption = "Consumable matter: ",
|
||||
value = total/1000,
|
||||
direction = "horizontal",
|
||||
style = "electric_satisfaction_in_description_progressbar"
|
||||
})
|
||||
else
|
||||
main248kblackholetotalbar = main248kblackholetotalframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholetotalbar",
|
||||
--caption = "Consumable matter: ",
|
||||
value = totalmatter/10000,
|
||||
direction = "horizontal",
|
||||
style = "electric_satisfaction_in_description_progressbar"
|
||||
})
|
||||
end
|
||||
|
||||
local main248kblackholestableframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholestableframe",
|
||||
caption = "Reactor stability: ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kblackholestablebar = main248kblackholestableframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholestablebar",
|
||||
--caption = "Consumable matter: ",
|
||||
value = stable/100,
|
||||
direction = "horizontal",
|
||||
style = "electric_satisfaction_statistics_progressbar"
|
||||
})
|
||||
|
||||
local main248kblackholeconsumptionframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholeconsumptionframe",
|
||||
caption = "Matter consumption: ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kblackholeconsumptionbar = main248kblackholeconsumptionframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholeconsumptionbar",
|
||||
--caption = "Consumable matter: ",
|
||||
value = matter_consumption/100,
|
||||
direction = "horizontal",
|
||||
style = "production_progressbar"
|
||||
})
|
||||
|
||||
local main248kblackholepowerframe = main248kblackholecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kblackholepowerframe",
|
||||
caption = "Power gen. rate: ",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kblackholepowerbar = main248kblackholepowerframe.add({
|
||||
type = "progressbar",
|
||||
name = "main248kblackholepowerbar",
|
||||
--caption = "Consumable matter: ",
|
||||
value = power_gen/19000000000,
|
||||
direction = "horizontal",
|
||||
style = "production_progressbar"
|
||||
})
|
||||
|
||||
global.black_hole.gui.frame = main248kblackholeframe
|
||||
global.black_hole.gui.id = id
|
||||
global.black_hole.gui.active = active
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--on click
|
||||
--=================================================================================
|
||||
|
||||
function gr_gui.on_change(e)
|
||||
local player = game.get_player(e["player_index"])
|
||||
if e["element"] then
|
||||
if e["element"].valid then
|
||||
local element = e["element"].name
|
||||
|
||||
if element == "main248kblackholeonbutton" then
|
||||
if global.black_hole then
|
||||
if global.black_hole.gui then
|
||||
if not global.black_hole.gui.active then
|
||||
if global.black_hole.gui.id then
|
||||
local id = global.black_hole.gui.id
|
||||
|
||||
if global.black_hole.base then
|
||||
if global.black_hole.base[id] then
|
||||
if global.black_hole.base[id].entity then
|
||||
if can_make_black_hole_energy(global.black_hole.base[id].entity) then
|
||||
make_black_hole_energy(global.black_hole.base[id].entity)
|
||||
gr_gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.black_hole.gui.active then
|
||||
if global.black_hole.gui.id then
|
||||
local id = global.black_hole.gui.id
|
||||
|
||||
if global.black_hole.base then
|
||||
if global.black_hole.base[id] then
|
||||
if global.black_hole.base[id].entity then
|
||||
if global.black_hole.base[id].active then
|
||||
if global.black_hole.base[id].energy then
|
||||
local energy_unit = global.black_hole.base[id].energy
|
||||
local energy_entity = global.black_hole.energy[energy_unit].entity
|
||||
unregister_black_hole_energy(energy_entity)
|
||||
energy_entity.destroy()
|
||||
global.black_hole.counter = 0
|
||||
gr_gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--update
|
||||
--=================================================================================
|
||||
|
||||
function gr_gui.update_main()
|
||||
for i,v in pairs(game.players) do
|
||||
if game.players[i].gui.left["main248kblackholeframe"] then
|
||||
game.players[i].gui.left["main248kblackholeframe"].destroy()
|
||||
gr_gui.add_black_hole_gui(game.players[i],true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return gr_gui
|
726
scripts/gui.lua
Normal file
726
scripts/gui.lua
Normal file
|
@ -0,0 +1,726 @@
|
|||
local mod_gui = require("mod-gui")
|
||||
local gui = {}
|
||||
|
||||
|
||||
--=================================================================================
|
||||
--add
|
||||
--=================================================================================
|
||||
|
||||
function gui.add_top_gui(player)
|
||||
local button_flow = mod_gui.get_button_flow(player)
|
||||
if not button_flow.top248kbutton then
|
||||
local button = button_flow.add({
|
||||
type = "sprite-button",
|
||||
name = "top248kbutton",
|
||||
sprite = "sprite_248kmainbutton",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function gui.add_core_gui(e,update)
|
||||
local player = nil
|
||||
local id = nil
|
||||
|
||||
if update then
|
||||
player = e
|
||||
id = global.ki.gui.core.id
|
||||
else
|
||||
player = game.get_player(e["player_index"])
|
||||
id = e["entity"].unit_number
|
||||
end
|
||||
|
||||
--====================================
|
||||
--destroy and clear
|
||||
--====================================
|
||||
|
||||
if player.gui.left["main248kcoreframe"] then
|
||||
player.gui.left["main248kcoreframe"].destroy()
|
||||
global.ki.gui.core = {}
|
||||
return
|
||||
end
|
||||
|
||||
if global.ki then
|
||||
if global.ki.core then
|
||||
if not global.ki.core[id] then
|
||||
if player.gui.left["main248kcoreframe"] then
|
||||
player.gui.left["main248kcoreframe"].destroy()
|
||||
global.ki.gui.core = {}
|
||||
return
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local channel = global.ki.core[id].channel
|
||||
local linked = #global.ki.channel[channel].beacons
|
||||
|
||||
local main248kcoreframe = player.gui.left.add({
|
||||
type = "frame",
|
||||
name = "main248kcoreframe",
|
||||
caption = "KI1 core: "
|
||||
})
|
||||
main248kcoreframe.style.minimal_height = 10
|
||||
main248kcoreframe.style.minimal_width = 10
|
||||
main248kcoreframe.style.maximal_width = 320
|
||||
|
||||
local main248kcorecontentframe = main248kcoreframe.add({
|
||||
type = "frame",
|
||||
name = "main248kcorecontentframe",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding"
|
||||
})
|
||||
|
||||
local main248kcorechannelframe = main248kcorecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kcorechannelframe",
|
||||
caption = "core channel",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kcorechannelslider = main248kcorechannelframe.add({
|
||||
type = "slider",
|
||||
name = "main248kcorechannelslider",
|
||||
value = channel,
|
||||
minimun_value = 1,
|
||||
maximum_value = #global.ki.channel + 1,
|
||||
style = "notched_slider"
|
||||
})
|
||||
|
||||
local main248kcorechanneltextfield = main248kcorechannelframe.add({
|
||||
type = "textfield",
|
||||
name = "main248kcorechanneltextfield",
|
||||
numeric = "true",
|
||||
text = channel
|
||||
})
|
||||
main248kcorechanneltextfield.style.maximal_width = 30
|
||||
|
||||
local main248kcorechannelbutton = main248kcorechannelframe.add({
|
||||
type = "button",
|
||||
name = "main248kcorechannelbutton",
|
||||
caption = "Apply",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
|
||||
local main248klinkedframe = main248kcorecontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kkinkedframe",
|
||||
caption = "linked beacons",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248klinkedlabel = main248klinkedframe.add({
|
||||
type = "label",
|
||||
name = "main248klinkedlabel",
|
||||
caption = linked
|
||||
})
|
||||
|
||||
global.ki.gui.core.frame = main248kcoreframe
|
||||
global.ki.gui.core.id = id
|
||||
end
|
||||
|
||||
function gui.add_main_gui(player)
|
||||
if player.gui.left["main248kframe"] then
|
||||
player.gui.left["main248kframe"].destroy()
|
||||
global.ki.gui.main = {}
|
||||
end
|
||||
|
||||
local main248kframe = player.gui.left.add({
|
||||
type = "frame",
|
||||
name = "main248kframe",
|
||||
caption = "248k KI overview: "
|
||||
})
|
||||
main248kframe.style.minimal_height = 10
|
||||
main248kframe.style.minimal_width = 10
|
||||
main248kframe.style.maximal_width = 320
|
||||
|
||||
local main248kcontentframe = main248kframe.add({
|
||||
type = "frame",
|
||||
name = "main248kcontentframe",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding"
|
||||
})
|
||||
|
||||
local main248kprefchannelframe = main248kcontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kprefchannelframe",
|
||||
caption = "standard channel",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kprefchannelslider = main248kprefchannelframe.add({
|
||||
type = "slider",
|
||||
name = "main248kprefchannelslider",
|
||||
value = global.ki.standardchannel,
|
||||
minimun_value = 0,
|
||||
maximum_value = #global.ki.channel + 1,
|
||||
style = "notched_slider"
|
||||
})
|
||||
|
||||
local main248kprefchanneltextfield = main248kprefchannelframe.add({
|
||||
type = "textfield",
|
||||
name = "main248kprefchanneltextfield",
|
||||
numeric = "true",
|
||||
text = global.ki.standardchannel
|
||||
})
|
||||
main248kprefchanneltextfield.style.maximal_width = 30
|
||||
|
||||
local main248kprefchannelbutton = main248kprefchannelframe.add({
|
||||
type = "button",
|
||||
name = "main248kprefchannelbutton",
|
||||
caption = "Apply",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
|
||||
local main248ksupportedframe = main248kcontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248ksupportedframe",
|
||||
caption = "max. supported beacons",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248ksupportedlabel = main248ksupportedframe.add({
|
||||
type = "label",
|
||||
name = "main248ksupportedlabel",
|
||||
caption = global.ki.supported
|
||||
})
|
||||
|
||||
local main248ktotalframe = main248kcontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248ktotalframe",
|
||||
caption = "total beacons",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248ktotallabel = main248ktotalframe.add({
|
||||
type = "label",
|
||||
name = "main248ktotallabel",
|
||||
caption = global.ki.total
|
||||
})
|
||||
|
||||
local main248kselectchannelframe = main248kcontentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kselectchannelframe",
|
||||
caption = "change beacon channel:",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kselectchannelslider = main248kselectchannelframe.add({
|
||||
type = "slider",
|
||||
name = "main248kselectchannelslider",
|
||||
value = global.ki.selectchannel,
|
||||
minimun_value = 0,
|
||||
maximum_value = #global.ki.channel + 1,
|
||||
style = "notched_slider"
|
||||
})
|
||||
|
||||
local main248kselectchanneltextfield = main248kselectchannelframe.add({
|
||||
type = "textfield",
|
||||
name = "main248kselectchanneltextfield",
|
||||
numeric = "true",
|
||||
text = global.ki.selectchannel
|
||||
})
|
||||
main248kselectchanneltextfield.style.maximal_width = 30
|
||||
|
||||
local main248kselectchannelbutton = main248kselectchannelframe.add({
|
||||
type = "button",
|
||||
name = "main248kselectchannelbutton",
|
||||
caption = "Apply",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
|
||||
global.ki.gui.main.frame = main248kframe
|
||||
end
|
||||
|
||||
function gui.add_buffer1_gui(e,update)
|
||||
local player = nil
|
||||
local id = nil
|
||||
|
||||
if update then
|
||||
player = e
|
||||
id = global.ki.gui.buffer1.id
|
||||
else
|
||||
player = game.get_player(e["player_index"])
|
||||
id = e["entity"].unit_number
|
||||
end
|
||||
|
||||
--====================================
|
||||
--destroy and clear
|
||||
--====================================
|
||||
|
||||
if player.gui.left["main248kbuffer1frame"] then
|
||||
player.gui.left["main248kbuffer1frame"].destroy()
|
||||
global.ki.gui.buffer1 = {}
|
||||
return
|
||||
end
|
||||
|
||||
if global.ki then
|
||||
if global.ki.buffer1 then
|
||||
if not global.ki.buffer1[id] then
|
||||
if player.gui.left["main248kbuffer1frame"] then
|
||||
player.gui.left["main248kbuffer1frame"].destroy()
|
||||
global.ki.gui.buffer1 = {}
|
||||
return
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local channel = global.ki.buffer1[id].channel
|
||||
|
||||
local main248kbuffer1frame = player.gui.left.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer1frame",
|
||||
caption = "KI2 amplifier: "
|
||||
})
|
||||
main248kbuffer1frame.style.minimal_height = 10
|
||||
main248kbuffer1frame.style.minimal_width = 10
|
||||
main248kbuffer1frame.style.maximal_width = 320
|
||||
|
||||
local main248kbuffer1contentframe = main248kbuffer1frame.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer1contentframe",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding"
|
||||
})
|
||||
|
||||
local main248kbuffer1channelframe = main248kbuffer1contentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer1channelframe",
|
||||
caption = "amplifier channel",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kbuffer1channelslider = main248kbuffer1channelframe.add({
|
||||
type = "slider",
|
||||
name = "main248kbuffer1channelslider",
|
||||
value = channel,
|
||||
minimun_value = 1,
|
||||
maximum_value = #global.ki.channel + 1,
|
||||
style = "notched_slider"
|
||||
})
|
||||
|
||||
local main248kbuffer1channeltextfield = main248kbuffer1channelframe.add({
|
||||
type = "textfield",
|
||||
name = "main248kbuffer1channeltextfield",
|
||||
numeric = "true",
|
||||
text = channel
|
||||
})
|
||||
main248kbuffer1channeltextfield.style.maximal_width = 30
|
||||
|
||||
local main248kbuffer1channelbutton = main248kbuffer1channelframe.add({
|
||||
type = "button",
|
||||
name = "main248kbuffer1channelbutton",
|
||||
caption = "Apply",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
|
||||
global.ki.gui.buffer1.frame = main248kbuffer1frame
|
||||
global.ki.gui.buffer1.id = id
|
||||
end
|
||||
|
||||
function gui.add_buffer2_gui(e,update)
|
||||
local player = nil
|
||||
local id = nil
|
||||
|
||||
if update then
|
||||
player = e
|
||||
id = global.ki.gui.buffer2.id
|
||||
else
|
||||
player = game.get_player(e["player_index"])
|
||||
id = e["entity"].unit_number
|
||||
end
|
||||
|
||||
--====================================
|
||||
--destroy and clear
|
||||
--====================================
|
||||
|
||||
if player.gui.left["main248kbuffer2frame"] then
|
||||
player.gui.left["main248kbuffer2frame"].destroy()
|
||||
global.ki.gui.buffer2 = {}
|
||||
return
|
||||
end
|
||||
|
||||
if global.ki then
|
||||
if global.ki.buffer2 then
|
||||
if not global.ki.buffer2[id] then
|
||||
if player.gui.left["main248kbuffer2frame"] then
|
||||
player.gui.left["main248kbuffer2frame"].destroy()
|
||||
global.ki.gui.buffer2 = {}
|
||||
return
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local channel = global.ki.buffer2[id].channel
|
||||
|
||||
local main248kbuffer2frame = player.gui.left.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer2frame",
|
||||
caption = "KI3 amplifier: "
|
||||
})
|
||||
main248kbuffer2frame.style.minimal_height = 10
|
||||
main248kbuffer2frame.style.minimal_width = 10
|
||||
main248kbuffer2frame.style.maximal_width = 320
|
||||
|
||||
local main248kbuffer2contentframe = main248kbuffer2frame.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer2contentframe",
|
||||
direction = "vertical",
|
||||
style = "inside_shallow_frame_with_padding"
|
||||
})
|
||||
|
||||
local main248kbuffer2channelframe = main248kbuffer2contentframe.add({
|
||||
type = "frame",
|
||||
name = "main248kbuffer2channelframe",
|
||||
caption = "amplifier channel",
|
||||
direction = "horizontal",
|
||||
style = "bordered_frame"
|
||||
})
|
||||
|
||||
local main248kbuffer2channelslider = main248kbuffer2channelframe.add({
|
||||
type = "slider",
|
||||
name = "main248kbuffer2channelslider",
|
||||
value = channel,
|
||||
minimun_value = 1,
|
||||
maximum_value = #global.ki.channel + 1,
|
||||
style = "notched_slider"
|
||||
})
|
||||
|
||||
local main248kbuffer2channeltextfield = main248kbuffer2channelframe.add({
|
||||
type = "textfield",
|
||||
name = "main248kbuffer2channeltextfield",
|
||||
numeric = "true",
|
||||
text = channel
|
||||
})
|
||||
main248kbuffer2channeltextfield.style.maximal_width = 30
|
||||
|
||||
local main248kbuffer2channelbutton = main248kbuffer2channelframe.add({
|
||||
type = "button",
|
||||
name = "main248kbuffer2channelbutton",
|
||||
caption = "Apply",
|
||||
style = mod_gui.button_style
|
||||
})
|
||||
|
||||
global.ki.gui.buffer2.frame = main248kbuffer2frame
|
||||
global.ki.gui.buffer2.id = id
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--on click
|
||||
--=================================================================================
|
||||
|
||||
function gui.on_change(e)
|
||||
local player = game.get_player(e["player_index"])
|
||||
|
||||
if e["element"] then
|
||||
if e["element"].valid then
|
||||
local element = e["element"].name
|
||||
|
||||
if element == "top248kbutton" then
|
||||
if player.gui.left["main248kframe"] then
|
||||
player.gui.left["main248kframe"].destroy()
|
||||
else
|
||||
gui.add_main_gui(player)
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kselectchannelbutton" then
|
||||
if player.cursor_stack.can_set_stack({name = "el_ki_selection_tool"}) then
|
||||
player.cursor_stack.set_stack({name = "el_ki_selection_tool"})
|
||||
|
||||
if global.ki.gui.main then
|
||||
if global.ki.gui.main.frame then
|
||||
local main248kframe = global.ki.gui.main.frame
|
||||
local slider_channel = main248kframe.main248kcontentframe.main248kselectchannelframe.main248kselectchannelslider.slider_value
|
||||
local text_channel = tonumber(main248kframe.main248kcontentframe.main248kselectchannelframe.main248kselectchanneltextfield.text)
|
||||
|
||||
change_valid_selectchannel(slider_channel,text_channel)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kcorechannelbutton" then
|
||||
if global.ki.gui.core then
|
||||
if (global.ki.gui.core.frame and global.ki.gui.core.id) then
|
||||
|
||||
local main248kcoreframe = global.ki.gui.core.frame
|
||||
local id = global.ki.gui.core.id
|
||||
local slider_channel = main248kcoreframe.main248kcorecontentframe.main248kcorechannelframe.main248kcorechannelslider.slider_value
|
||||
local text_channel = tonumber(main248kcoreframe.main248kcorecontentframe.main248kcorechannelframe.main248kcorechanneltextfield.text)
|
||||
|
||||
change_valid_channel(slider_channel,text_channel,id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kbuffer1channelbutton" then
|
||||
if global.ki.gui.buffer1 then
|
||||
if (global.ki.gui.buffer1.frame and global.ki.gui.buffer1.id) then
|
||||
|
||||
local main248kbuffer1frame = global.ki.gui.buffer1.frame
|
||||
local id = global.ki.gui.buffer1.id
|
||||
local slider_channel = main248kbuffer1frame.main248kbuffer1contentframe.main248kbuffer1channelframe.main248kbuffer1channelslider.slider_value
|
||||
local text_channel = tonumber(main248kbuffer1frame.main248kbuffer1contentframe.main248kbuffer1channelframe.main248kbuffer1channeltextfield.text)
|
||||
|
||||
change_valid_bufferchannel(slider_channel,text_channel,id,"buffer1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kbuffer2channelbutton" then
|
||||
if global.ki.gui.buffer2 then
|
||||
if (global.ki.gui.buffer2.frame and global.ki.gui.buffer2.id) then
|
||||
|
||||
local main248kbuffer2frame = global.ki.gui.buffer2.frame
|
||||
local id = global.ki.gui.buffer2.id
|
||||
local slider_channel = main248kbuffer2frame.main248kbuffer2contentframe.main248kbuffer2channelframe.main248kbuffer2channelslider.slider_value
|
||||
local text_channel = tonumber(main248kbuffer2frame.main248kbuffer2contentframe.main248kbuffer2channelframe.main248kbuffer2channeltextfield.text)
|
||||
|
||||
change_valid_bufferchannel(slider_channel,text_channel,id,"buffer2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kprefchannelbutton" then
|
||||
if global.ki.gui.main then
|
||||
if global.ki.gui.main.frame then
|
||||
local main248kframe = global.ki.gui.main.frame
|
||||
local slider_channel = main248kframe.main248kcontentframe.main248kprefchannelframe.main248kprefchannelslider.slider_value
|
||||
local text_channel = tonumber(main248kframe.main248kcontentframe.main248kprefchannelframe.main248kprefchanneltextfield.text)
|
||||
|
||||
change_valid_standardchannel(slider_channel,text_channel)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if element == "main248kcorechannelslider" then
|
||||
gui.update_main()
|
||||
end
|
||||
|
||||
if element == "main248kcorechanneltextfield" then
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function gui.on_selected(e)
|
||||
if e["item"] then
|
||||
if e["player_index"] then
|
||||
local player = game.get_player(e["player_index"])
|
||||
if player.cursor_stack then
|
||||
if player.cursor_stack.valid_for_read then
|
||||
if player.cursor_stack.name == "el_ki_selection_tool" then
|
||||
|
||||
for i,v in pairs(e["entities"]) do
|
||||
if (v.name == 'el_ki_beacon_entity') or (v.name == 'fi_ki_beacon_entity') or (v.name == 'fu_ki_beacon_entity') then
|
||||
local id = v.unit_number
|
||||
local oldchannel = global.ki.beacon[id].channel
|
||||
|
||||
for x,f in pairs(global.ki.channel[oldchannel].beacons) do
|
||||
if f == id then
|
||||
table.remove(global.ki.channel[oldchannel].beacons, x)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
global.ki.beacon[id].channel = global.ki.selectchannel
|
||||
table.insert(global.ki.channel[global.ki.selectchannel].beacons, id)
|
||||
end
|
||||
end
|
||||
|
||||
global.ki.dirty = true
|
||||
gui.update_main()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--=================================================================================
|
||||
--update
|
||||
--=================================================================================
|
||||
|
||||
function gui.update_main()
|
||||
for i,v in pairs(game.players) do
|
||||
if game.players[i].gui.left["main248kframe"] then
|
||||
game.players[i].gui.left["main248kframe"].destroy()
|
||||
gui.add_main_gui(game.players[i])
|
||||
end
|
||||
|
||||
if game.players[i].gui.left["main248kcoreframe"] then
|
||||
game.players[i].gui.left["main248kcoreframe"].destroy()
|
||||
gui.add_core_gui(game.players[i],true)
|
||||
end
|
||||
|
||||
if game.players[i].gui.left["main248kbuffer1frame"] then
|
||||
game.players[i].gui.left["main248kbuffer1frame"].destroy()
|
||||
gui.add_buffer1_gui(game.players[i],true)
|
||||
end
|
||||
|
||||
if game.players[i].gui.left["main248kbuffer2frame"] then
|
||||
game.players[i].gui.left["main248kbuffer2frame"].destroy()
|
||||
gui.add_buffer2_gui(game.players[i],true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--=================================================================================
|
||||
--util
|
||||
--=================================================================================
|
||||
|
||||
function change_valid_channel(slider_channel,text_channel,id)
|
||||
|
||||
if slider_channel == text_channel then
|
||||
if is_valid_channel(slider_channel,"core") then
|
||||
change_channel(id,slider_channel,"core")
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (slider_channel == global.ki.core[id].channel) then
|
||||
if is_valid_channel(slider_channel,"core") then
|
||||
change_channel(id,slider_channel,"core")
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (text_channel == global.ki.core[id].channel) then
|
||||
if is_valid_channel(text_channel,"core") then
|
||||
change_channel(id,text_channel,"core")
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function change_valid_bufferchannel(slider_channel,text_channel,id,object)
|
||||
|
||||
if slider_channel == text_channel then
|
||||
if is_valid_channel(slider_channel,object) then
|
||||
change_channel(id,slider_channel,object)
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (slider_channel == global.ki[object][id].channel) then
|
||||
if is_valid_channel(slider_channel,object) then
|
||||
change_channel(id,slider_channel,object)
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (text_channel == global.ki[object][id].channel) then
|
||||
if is_valid_channel(text_channel,object) then
|
||||
change_channel(id,slider_channel,object)
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function change_valid_standardchannel(slider_channel,text_channel)
|
||||
if slider_channel == text_channel then
|
||||
if is_valid_standardchannel(slider_channel) then
|
||||
global.ki.standardchannel = slider_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (slider_channel == global.ki.standardchannel) then
|
||||
if is_valid_standardchannel(slider_channel) then
|
||||
global.ki.standardchannel = slider_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (text_channel == global.ki.standardchannel) then
|
||||
if is_valid_standardchannel(text_channel) then
|
||||
global.ki.standardchannel = text_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function change_valid_selectchannel(slider_channel,text_channel)
|
||||
if slider_channel == text_channel then
|
||||
if is_valid_standardchannel(slider_channel) then
|
||||
global.ki.selectchannel = slider_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (slider_channel == global.ki.selectchannel) then
|
||||
if is_valid_standardchannel(slider_channel) then
|
||||
global.ki.selectchannel = slider_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
|
||||
if not (text_channel == global.ki.selectchannel) then
|
||||
if is_valid_standardchannel(text_channel) then
|
||||
global.ki.selectchannel = text_channel
|
||||
end
|
||||
gui.update_main()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function is_valid_channel(channel,object)
|
||||
if #global.ki.channel >= channel then
|
||||
if not global.ki.channel[channel][object] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function is_valid_standardchannel(channel)
|
||||
if #global.ki.channel >= channel then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function change_channel(id,new_channel,type)
|
||||
global.ki.channel[global.ki[type][id].channel][type] = nil
|
||||
global.ki[type][id].channel = new_channel
|
||||
global.ki.channel[new_channel][type] = id
|
||||
global.ki.dirty = true
|
||||
end
|
||||
|
||||
return gui
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
166
scripts/ind2/data-final-fixes.lua
Normal file
166
scripts/ind2/data-final-fixes.lua
Normal file
|
@ -0,0 +1,166 @@
|
|||
local function sprite(name)
|
||||
return '__248k__/ressources/techs/'..name
|
||||
end
|
||||
|
||||
data.raw["assembling-machine"]["oil-refinery"].fixed_recipe = nil
|
||||
data.raw["recipe"]["fi_materials_steel_recipe"].result = "steel-ingot"
|
||||
data.raw["recipe"]["fi_materials_steel_recipe"].result_count = 16
|
||||
data.raw["recipe"]["fu_robo_logistic_recipe"].ingredients = {
|
||||
{type="item", name="logistic-robot", amount=2},
|
||||
{type="item", name="fu_tech_sign_item", amount=2},
|
||||
{type="item", name="fi_energy_crystal_item", amount=3},
|
||||
{type="item", name="low-density-structure", amount=20},
|
||||
{type="item", name="el_lithium_battery", amount=10},
|
||||
{type="item", name="gyroscope", amount=8},
|
||||
}
|
||||
data.raw["recipe"]["fu_robo_construction_recipe"].ingredients = {
|
||||
{type="item", name="logistic-robot", amount=2},
|
||||
{type="item", name="fu_tech_sign_item", amount=2},
|
||||
{type="item", name="fi_energy_crystal_item", amount=3},
|
||||
{type="item", name="low-density-structure", amount=20},
|
||||
{type="item", name="el_lithium_battery", amount=10},
|
||||
{type="item", name="gyroscope", amount=8},
|
||||
}
|
||||
data.raw["recipe"]["fu_star_engine_caster_1_recipe"].results = {{type="item", name="iron-ingot", amount=500}}
|
||||
data.raw["recipe"]["fu_star_engine_caster_2_recipe"].results = {{type="item", name="copper-ingot", amount=500}}
|
||||
data.raw["recipe"]["gr_steel_recipe"].results = {{type="item", name="steel-ingot", amount=500}}
|
||||
data:extend({
|
||||
{
|
||||
name = 'gr_stainless_steel_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="stainless-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_invar_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="invar-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_nickel_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="cupronickel-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_chrome_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="chromium-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_gold_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="gold-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_tellerium_recipe',
|
||||
type = 'recipe',
|
||||
category = 'crafting-with-fluid',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_e',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="tellurium-ingot", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 6,
|
||||
},
|
||||
{
|
||||
name = 'gr_ind2_tech',
|
||||
type = 'technology',
|
||||
icon = sprite('fu_star_engine_tech.png'),
|
||||
icon_size = 128,
|
||||
prerequisites = {
|
||||
'gr_star_engine_2_tech'
|
||||
},
|
||||
effects = {
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_stainless_steel_recipe',
|
||||
},
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_invar_recipe',
|
||||
},
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_nickel_recipe',
|
||||
},
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_chrome_recipe',
|
||||
},
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_gold_recipe',
|
||||
},
|
||||
{
|
||||
type = 'unlock-recipe',
|
||||
recipe = 'gr_tellerium_recipe',
|
||||
}
|
||||
},
|
||||
unit = {
|
||||
count = '8000',
|
||||
ingredients = {
|
||||
{'chemical-science-pack',1},
|
||||
{'automation-science-pack',1},
|
||||
{'logistic-science-pack',1},
|
||||
{'production-science-pack',1},
|
||||
{'utility-science-pack',1},
|
||||
{'space-science-pack',1},
|
||||
{'fu_space_probe_science_item',1}
|
||||
},
|
||||
time = 100,
|
||||
},
|
||||
},
|
||||
})
|
0
scripts/ind2/data.lua
Normal file
0
scripts/ind2/data.lua
Normal file
81
scripts/informatron/inf_main.lua
Normal file
81
scripts/informatron/inf_main.lua
Normal file
|
@ -0,0 +1,81 @@
|
|||
remote.add_interface("inf_248k", {
|
||||
informatron_menu = function(data)
|
||||
return inf_248k_menu(data.player_index)
|
||||
end,
|
||||
informatron_page_content = function(data)
|
||||
return inf_248k_page_content(data.page_name, data.player_index, data.element)
|
||||
end
|
||||
})
|
||||
|
||||
function inf_248k_menu(player_index)
|
||||
return {
|
||||
ki1core=1,
|
||||
diesel=1,
|
||||
fusion=1,
|
||||
starengine=1,
|
||||
exoticscience=1,
|
||||
blackhole=1
|
||||
}
|
||||
end
|
||||
|
||||
function inf_248k_page_content(page_name, player_index, element)
|
||||
-- main page
|
||||
if page_name == "inf_248k" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_about"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_about_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_1"}
|
||||
|
||||
element.add{type="label", name="text_3", caption={"gui.bk_248k_first_steps"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_4", caption={"gui.bk_248k_first_steps_text"}}
|
||||
end
|
||||
|
||||
if page_name == "ki1core" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_ki1_core"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_ki1_core_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_3"}
|
||||
|
||||
element.add{type="label", name="text_4", caption={"gui.bk_248k_ki2_core"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_3", caption={"gui.bk_248k_ki2_core_text"}}
|
||||
element.add{type="button", name="image_2", style="inf_248k_image_7"}
|
||||
end
|
||||
|
||||
if page_name == "diesel" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_diesel_train"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_diesel_train_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_8"}
|
||||
end
|
||||
|
||||
if page_name == "fusion" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_fusion"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_fusion_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_4"}
|
||||
|
||||
element.add{type="label", name="text_3", caption={"gui.bk_248k_fusion_1_text"}}
|
||||
element.add{type="button", name="image_2", style="inf_248k_image_5"}
|
||||
|
||||
element.add{type="label", name="text_4", caption={"gui.bk_248k_fusion_2_text"}}
|
||||
end
|
||||
|
||||
if page_name == "starengine" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_star_engine"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_star_engine_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_6"}
|
||||
|
||||
element.add{type="label", name="text_3", caption={"gui.bk_248k_star_engine_1_text"}}
|
||||
element.add{type="button", name="image_2", style="inf_248k_image_9"}
|
||||
end
|
||||
|
||||
if page_name == "exoticscience" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_exotic_science"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_exotic_science_text"}}
|
||||
end
|
||||
|
||||
if page_name == "blackhole" then
|
||||
element.add{type="label", name="text_1", caption={"gui.bk_248k_black_hole"}, style="heading_1_label"}
|
||||
element.add{type="label", name="text_2", caption={"gui.bk_248k_black_hole_text"}}
|
||||
element.add{type="button", name="image_1", style="inf_248k_image_10"}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
16
scripts/informatron/inf_sprites.lua
Normal file
16
scripts/informatron/inf_sprites.lua
Normal file
|
@ -0,0 +1,16 @@
|
|||
local function sprite(name)
|
||||
return '__248k__/ressources/booktorio/bk_sprite_'..name
|
||||
end
|
||||
-- style_name, filename, width, height -- style_name MUST be a completely unique name
|
||||
informatron_make_image("inf_248k_image_1", sprite('1.png'), 1117, 948)
|
||||
informatron_make_image("inf_248k_image_2", sprite('2.png'), 1044, 826)
|
||||
informatron_make_image("inf_248k_image_3", sprite('3.png'), 988, 696)
|
||||
informatron_make_image("inf_248k_image_4", '__248k__/ressources/fusion/fu_fusor/fu_fusor_entity_animation.png', 512*2, 512*2)
|
||||
informatron_make_image("inf_248k_image_5", '__248k__/ressources/fusion/fu_boiler/fu_boiler_entity_animation.png', 512, 512)
|
||||
informatron_make_image("inf_248k_image_6", sprite('6.png'), 1190, 1020)
|
||||
informatron_make_image("inf_248k_image_7", sprite('7.png'), 1292, 627)
|
||||
|
||||
informatron_make_image("inf_248k_image_8", sprite('8.PNG'), 493, 124)
|
||||
informatron_make_image("inf_248k_image_9", sprite('9.PNG'), 279, 317)
|
||||
informatron_make_image("inf_248k_image_10", sprite('10.PNG'), 994, 630)
|
||||
|
263
scripts/krastorio2/data-final-fixes.lua
Normal file
263
scripts/krastorio2/data-final-fixes.lua
Normal file
|
@ -0,0 +1,263 @@
|
|||
local function config(name)
|
||||
return settings.startup['override_'..name].value
|
||||
end
|
||||
|
||||
data:extend({
|
||||
{
|
||||
type = "recipe",
|
||||
name = "fi_lithium_to_k2",
|
||||
energy_required = 30,
|
||||
enabled = false,
|
||||
always_show_made_in = true,
|
||||
ingredients =
|
||||
{
|
||||
{"fi_crushed_lithium_item", 10},
|
||||
{type="fluid", name="mineral-water", amount=100}
|
||||
},
|
||||
result = "lithium-chloride",
|
||||
result_count = 10,
|
||||
category = "chemistry"
|
||||
},
|
||||
{
|
||||
name = 'fu_boiler_hydrogen_oxygen_3_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_boiler_crafting_category',
|
||||
main_product = 'hydrogen',
|
||||
enabled = false,
|
||||
ingredients = {
|
||||
{type="fluid", name="water", amount=1100},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="hydrogen", amount=1000, temperature=40},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'a-a',
|
||||
},
|
||||
{
|
||||
name = 'fu_boiler_hydrogen_oxygen_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_boiler_crafting_category',
|
||||
main_product = 'hydrogen',
|
||||
enabled = false,
|
||||
ingredients = {
|
||||
{type="fluid", name="water", amount=150},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="hydrogen", amount=100, temperature=40},
|
||||
{type="fluid", name="oxygen", amount=50, temperature=40}
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'a-a',
|
||||
},
|
||||
{
|
||||
name = 'fu_boiler_hydrogen_oxygen_1_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_boiler_crafting_category',
|
||||
main_product = 'hydrogen',
|
||||
enabled = false,
|
||||
ingredients = {
|
||||
{type="fluid", name="water", amount=300},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="hydrogen", amount=200, temperature=40},
|
||||
{type="fluid", name="oxygen", amount=100, temperature=40}
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'a-a',
|
||||
},
|
||||
{
|
||||
name = 'fu_boiler_hydrogen_oxygen_2_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_boiler_crafting_category',
|
||||
main_product = 'hydrogen',
|
||||
enabled = false,
|
||||
ingredients = {
|
||||
{type="fluid", name="water", amount=650},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="hydrogen", amount=500, temperature=40},
|
||||
{type="fluid", name="oxygen", amount=150, temperature=40},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'a-a',
|
||||
},
|
||||
{
|
||||
name = 'fu_hydrogen_recipe',
|
||||
type = 'recipe',
|
||||
category = 'oil-processing',
|
||||
main_product = 'fu_protium',
|
||||
enabled = false,
|
||||
ingredients = {
|
||||
{type="fluid", name="hydrogen", amount=100000},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="fu_protium", amount=99998},
|
||||
{type="fluid", name="fu_deuterium", amount=10},
|
||||
{type="fluid", name="fu_tritium", amount=1}
|
||||
},
|
||||
result_count = '0.5',
|
||||
energy_required = 100,
|
||||
},
|
||||
{
|
||||
name = 'fu_exchanger_1_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_exchanger_crafting_category',
|
||||
main_product = 'steam',
|
||||
enabled = 'false',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_lead_fluid", amount=50, temperature=1500},
|
||||
{type="fluid", name="water", amount=1000/2},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="fu_lead_fluid", amount=50, temperature=500},
|
||||
{type="fluid", name="steam", amount=1000/2, temperature=425},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'b-a',
|
||||
always_show_made_in = true,
|
||||
},
|
||||
{
|
||||
name = 'fu_exchanger_2_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_exchanger_crafting_category',
|
||||
main_product = 'steam',
|
||||
enabled = 'false',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_lead_fluid", amount=100, temperature=1500},
|
||||
{type="fluid", name="water", amount=1000/4},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="fu_lead_fluid", amount=100, temperature=500},
|
||||
{type="fluid", name="steam", amount=1000/4, temperature=975},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
subgroup = 'fu_item_subgroup_e',
|
||||
order = 'b-a',
|
||||
always_show_made_in = true,
|
||||
},
|
||||
{
|
||||
name = 'fu_star_engine_cooler_7_recipe',
|
||||
type = 'recipe',
|
||||
category = 'fu_star_engine_cooler_crafting_category',
|
||||
enabled = 'false',
|
||||
subgroup = 'fu_star_engine_subgroup_c',
|
||||
ingredients = {
|
||||
{type="fluid", name="fu_iron_heated", amount=500},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="matter", amount=500},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 1,
|
||||
},
|
||||
{
|
||||
name = 'fu_activator_3_recipe',
|
||||
type = 'recipe',
|
||||
category = 'chemistry',
|
||||
main_product = 'fu_deuterium',
|
||||
enabled = 'false',
|
||||
ingredients = {
|
||||
{type="fluid", name="heavy-water", amount=10},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="fu_deuterium", amount=4},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 10,
|
||||
always_show_made_in = true,
|
||||
},
|
||||
{
|
||||
name = 'fu_activator_4_recipe',
|
||||
type = 'recipe',
|
||||
category = 'chemistry',
|
||||
main_product = 'fu_tritium',
|
||||
enabled = 'false',
|
||||
ingredients = {
|
||||
{type="item", name="tritium", amount=1},
|
||||
},
|
||||
results = {
|
||||
{type="fluid", name="fu_tritium", amount=10},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 10,
|
||||
always_show_made_in = true,
|
||||
},
|
||||
{
|
||||
name = 'fu_ki_core_recipe',
|
||||
type = 'recipe',
|
||||
enabled = 'false',
|
||||
category = 'crafting',
|
||||
ingredients = {
|
||||
{type="item", name="steel-plate", amount=100},
|
||||
{type="item", name="concrete", amount=500},
|
||||
{type="item", name="electronic-circuit", amount=100},
|
||||
{type="item", name="advanced-circuit", amount=100},
|
||||
{type="item", name="processing-unit", amount=100},
|
||||
{type="item", name="fu_space_probe_down_matter_item", amount=10},
|
||||
{type="item", name="fu_space_probe_up_matter_item", amount=10},
|
||||
{type="item", name="fu_exchanger_item", amount=10},
|
||||
{type="item", name="fu_tech_sign_item", amount=100},
|
||||
{type="item", name="fu_boiler_item", amount=10},
|
||||
--{type="item", name="fu_burner_item", amount=10},
|
||||
},
|
||||
results = {
|
||||
{type="item", name="fu_ki_core_item", amount=1},
|
||||
},
|
||||
result_count = 1,
|
||||
energy_required = 60,
|
||||
},
|
||||
})
|
||||
|
||||
--techs
|
||||
table.insert(data.raw.technology["kr-lithium-processing"].effects, {type ="unlock-recipe", recipe ="fi_lithium_to_k2"})
|
||||
table.insert(data.raw.technology["kr-matter-processing"].effects, {type ="unlock-recipe", recipe ="fu_star_engine_cooler_7_recipe"})
|
||||
if (not mods["RealisticFusionPower"]) then
|
||||
table.insert(data.raw.technology["kr-fusion-energy"].effects, {type ="unlock-recipe", recipe ="fu_activator_4_recipe"})
|
||||
table.insert(data.raw.technology["kr-fusion-energy"].effects, {type ="unlock-recipe", recipe ="fu_activator_3_recipe"})
|
||||
end
|
||||
data.raw.recipe["fu_burner_recipe"].hidden = true
|
||||
|
||||
table.insert(data.raw.technology["gr_stage_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_train_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_train_plus_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_star_engine_1_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_star_engine_2_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_crafter_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_materials_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_compact_fusion_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_charger_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_kovarex_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["gr_black_hole_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["fi_modules_4_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["fi_modules_5_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
table.insert(data.raw.technology["fi_modules_6_tech"].unit.ingredients, {"fu_space_probe_science_item", 1})
|
||||
|
||||
table.insert(data.raw.technology["fu_ki_plus_1_tech"].unit.ingredients, {"fi_ki_science", 1})
|
||||
table.insert(data.raw.technology["fu_ki_plus_1_tech"].unit.ingredients, {"fu_ki_science", 1})
|
||||
table.insert(data.raw.technology["fu_ki_plus_2_tech"].unit.ingredients, {"fi_ki_science", 1})
|
||||
table.insert(data.raw.technology["fu_ki_plus_2_tech"].unit.ingredients, {"fu_ki_science", 1})
|
||||
|
||||
table.insert(data.raw["generator-equipment"]["fi_train_equipment_generator_item"].categories,"vehicle-equipment")
|
||||
|
||||
if (config("krastorio_endgame")) then
|
||||
table.insert(data.raw.recipe["kr-intergalactic-transceiver"].ingredients ,{type="item", name="gr_materials_stack_down_item", amount=100})
|
||||
table.insert(data.raw.recipe["kr-intergalactic-transceiver"].ingredients ,{type="item", name="gr_materials_stack_up_item", amount=100})
|
||||
table.insert(data.raw.recipe["kr-antimatter-reactor"].ingredients ,{type="item", name="gr_materials_stack_down_item", amount=40})
|
||||
table.insert(data.raw.recipe["kr-antimatter-reactor"].ingredients ,{type="item", name="gr_materials_stack_up_item", amount=40})
|
||||
end
|
||||
table.insert(data.raw.lab['kr-singularity-lab'].inputs, 'fu_space_probe_science_item')
|
||||
table.insert(data.raw.lab['kr-singularity-lab'].inputs, 'fi_ki_science')
|
||||
table.insert(data.raw.lab['kr-singularity-lab'].inputs, 'fu_ki_science')
|
||||
|
||||
data.raw.tool["fu_space_probe_science_item"].icon = "__248k__/ressources/fusion/fu_space_probe/fu_space_probe_science_item_krastorio.png"
|
0
scripts/krastorio2/data.lua
Normal file
0
scripts/krastorio2/data.lua
Normal file
Loading…
Add table
Add a link
Reference in a new issue