mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
.
This commit is contained in:
@@ -62,24 +62,14 @@ end)
|
|||||||
--- @param silo LuaEntity Rocket silo entity
|
--- @param silo LuaEntity Rocket silo entity
|
||||||
--- @return table # Data table for this silo, contains rockets launch, silo status, and its force
|
--- @return table # Data table for this silo, contains rockets launch, silo status, and its force
|
||||||
function Rockets.get_silo_data(silo)
|
function Rockets.get_silo_data(silo)
|
||||||
local position = silo.position
|
return rocket_silos[silo.unit_number]
|
||||||
local silo_name = math.floor(position.x) .. ":" .. math.floor(position.y)
|
|
||||||
return rocket_silos[silo_name]
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Gets the silo data for a given silo entity
|
|
||||||
--- @param silo_name string Silo name that is stored in its data
|
|
||||||
--- @return table # Data table for this silo, contains rockets launch, silo status, and its force
|
|
||||||
function Rockets.get_silo_data_by_name(silo_name)
|
|
||||||
return rocket_silos[silo_name]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Gets the silo entity from its silo name, reverse to get_silo_data
|
--- Gets the silo entity from its silo name, reverse to get_silo_data
|
||||||
--- @param silo_name string Silo name that is stored in its data
|
--- @param silo_name string Silo name that is stored in its data
|
||||||
--- @return LuaEntity # Rocket silo entity
|
--- @return LuaEntity # Rocket silo entity
|
||||||
function Rockets.get_silo_entity(silo_name)
|
function Rockets.get_silo_entity(silo_name)
|
||||||
local data = rocket_silos[silo_name]
|
return rocket_silos[tonumber(silo_name)].entity
|
||||||
return data.entity
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Gets the rocket stats for a force
|
--- Gets the rocket stats for a force
|
||||||
@@ -151,6 +141,7 @@ end
|
|||||||
--- @param event EventData.on_rocket_launch_ordered
|
--- @param event EventData.on_rocket_launch_ordered
|
||||||
Event.add(defines.events.on_rocket_launch_ordered, function(event)
|
Event.add(defines.events.on_rocket_launch_ordered, function(event)
|
||||||
local silo_data = Rockets.get_silo_data(event.rocket_silo)
|
local silo_data = Rockets.get_silo_data(event.rocket_silo)
|
||||||
|
assert(silo_data, "Rocket silo missing data: " .. tostring(event.rocket_silo))
|
||||||
silo_data.launched = silo_data.launched + 1
|
silo_data.launched = silo_data.launched + 1
|
||||||
silo_data.awaiting_reset = true
|
silo_data.awaiting_reset = true
|
||||||
end)
|
end)
|
||||||
@@ -196,14 +187,9 @@ end)
|
|||||||
local function on_built(event)
|
local function on_built(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if entity.valid and entity.name == "rocket-silo" then
|
if entity.valid and entity.name == "rocket-silo" then
|
||||||
local force = entity.force
|
rocket_silos[entity.unit_number] = {
|
||||||
local force_name = force.name
|
name = tostring(entity.unit_number),
|
||||||
local position = entity.position
|
force = entity.force.name,
|
||||||
local silo_name = math.floor(position.x) .. ":" .. math.floor(position.y)
|
|
||||||
|
|
||||||
rocket_silos[silo_name] = {
|
|
||||||
name = silo_name,
|
|
||||||
force = force_name,
|
|
||||||
entity = entity,
|
entity = entity,
|
||||||
launched = 0,
|
launched = 0,
|
||||||
awaiting_reset = false,
|
awaiting_reset = false,
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ Gui.on_click(
|
|||||||
element.style.font_color = Color.orange
|
element.style.font_color = Color.orange
|
||||||
data.selected_header = element
|
data.selected_header = element
|
||||||
|
|
||||||
input_text_box.text = concat{ "storage.exp_storage[", token_id, "]" }
|
input_text_box.text = concat{ "storage.exp_storage['", token_id, "']" }
|
||||||
input_text_box.style.font_color = Color.black
|
input_text_box.style.font_color = Color.black
|
||||||
|
|
||||||
local content = dump(storage.exp_storage[token_id]) or "nil"
|
local content = dump(storage.exp_storage[token_id]) or "nil"
|
||||||
|
|||||||
Reference in New Issue
Block a user