1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00

Merge pull request #25 from M3wM3w/master

update from main
This commit is contained in:
hanakocz 2020-07-29 19:31:51 +02:00 committed by GitHub
commit 6e0359cebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 90 deletions

View File

@ -55,6 +55,11 @@ local ammo_names = {
['rocket'] = true
}
local chests = {
['container'] = true,
['logistic-container'] = true
}
Global.register(
this,
function(t)
@ -367,10 +372,27 @@ local function on_entity_died(event)
this.friendly_fire_history[cause.player.index] = {}
end
local chest
if chests[event.entity.type] then
local entity = event.entity
local inv = entity.get_inventory(1)
local contents = inv.get_contents()
local item_types = ''
for n, count in pairs(contents) do
if n == 'explosives' then
item_types = item_types .. n .. ' count: ' .. count .. '. '
end
end
chest = event.entity.name .. ' with content ' .. item_types
else
chest = event.entity.name
end
local t = math.abs(math.floor((game.tick) / 3600))
local str = '[' .. t .. '] '
str = str .. name .. ' destroyed '
str = str .. event.entity.name
str = str .. chest
str = str .. ' at X:'
str = str .. math.floor(event.entity.position.x)
str = str .. ' Y:'

View File

@ -59,11 +59,12 @@ local entity_type = {
['tree'] = true
}
local wagon_types = {
local protect_types = {
['cargo-wagon'] = true,
['artillery-wagon'] = true,
['fluid-wagon'] = true,
['locomotive'] = true
['locomotive'] = true,
['reactor'] = true
}
local function set_objective_health(final_damage_amount)
@ -129,7 +130,7 @@ local function protect_entities(event)
if string.sub(e.surface.name, 0, #map_name) ~= map_name then
return true
end
if wagon_types[e.type] then
if protect_types[e.type] then
return true
end
return false

View File

@ -28,7 +28,6 @@ function Public.extra_settings(player)
local rpg_extra = RPG.get('rpg_extra')
local rpg_t = RPG.get('rpg_t')
local trusted = Session.get_trusted_table()
local conjure_items = RPG.get_spells()
local main_frame =
player.gui.screen.add(
{
@ -397,13 +396,8 @@ function Public.extra_settings(player)
}
)
local names = {}
for _, items in pairs(conjure_items) do
if items.enabled then
names[#names + 1] = items.name
end
end
local new_spells, names = RPG.rebuild_spells()
RPG.set_spells_table(new_spells)
local conjure_label_style = conjure_label.style
conjure_label_style.horizontally_stretchable = true
@ -417,7 +411,7 @@ function Public.extra_settings(player)
conjure_gui_input =
create_input_element(conjure_input, 'dropdown', false, names, rpg_t[player.index].dropdown_select_index)
for _, entity in pairs(conjure_items) do
for _, entity in pairs(new_spells) do
if entity.type == 'item' then
conjure_label.tooltip =
conjure_label.tooltip ..

View File

@ -1,88 +1,91 @@
local Public = {}
Public.conjure_items = {
[1] = {
function Public.conjure_items()
local spells = {}
spells[#spells + 1] = {
name = 'Stone Wall',
obj_to_create = 'stone-wall',
level = 10,
type = 'item',
mana_cost = 35,
tick = 100,
enabled = true
},
[2] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Wooden Chest',
obj_to_create = 'wooden-chest',
level = 2,
type = 'item',
mana_cost = 30,
tick = 100,
enabled = true
},
[3] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Iron Chest',
obj_to_create = 'iron-chest',
level = 10,
type = 'item',
mana_cost = 40,
tick = 200,
enabled = true
},
[4] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Steel Chest',
obj_to_create = 'steel-chest',
level = 15,
type = 'item',
mana_cost = 50,
tick = 300,
enabled = true
},
[5] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Transport Belt',
obj_to_create = 'transport-belt',
level = 3,
type = 'item',
mana_cost = 40,
tick = 100,
enabled = true
},
[6] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Fast Transport Belt',
obj_to_create = 'fast-transport-belt',
level = 20,
type = 'item',
mana_cost = 50,
tick = 200,
enabled = true
},
[7] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Express Transport Belt',
obj_to_create = 'express-transport-belt',
level = 60,
type = 'item',
mana_cost = 60,
tick = 300,
enabled = true
},
[8] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Underground Belt',
obj_to_create = 'underground-belt',
level = 3,
type = 'item',
mana_cost = 40,
tick = 100,
enabled = true
},
[9] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Fast Underground Belt',
obj_to_create = 'fast-underground-belt',
level = 20,
type = 'item',
mana_cost = 50,
tick = 200,
enabled = true
},
[10] = {
enabled = false
}
spells[#spells + 1] = {
name = 'Express Underground Belt',
obj_to_create = 'express-underground-belt',
level = 60,
@ -90,8 +93,8 @@ Public.conjure_items = {
mana_cost = 60,
tick = 300,
enabled = true
},
[11] = {
}
spells[#spells + 1] = {
name = 'Sandy Rock',
obj_to_create = 'sand-rock-big',
level = 80,
@ -99,8 +102,8 @@ Public.conjure_items = {
mana_cost = 80,
tick = 350,
enabled = true
},
[12] = {
}
spells[#spells + 1] = {
name = 'Smol Biter',
obj_to_create = 'small-biter',
level = 50,
@ -109,8 +112,8 @@ Public.conjure_items = {
mana_cost = 55,
tick = 100,
enabled = true
},
[13] = {
}
spells[#spells + 1] = {
name = 'Smol Spitter',
obj_to_create = 'small-spitter',
level = 50,
@ -119,8 +122,8 @@ Public.conjure_items = {
mana_cost = 55,
tick = 100,
enabled = true
},
[14] = {
}
spells[#spells + 1] = {
name = 'Medium Biter',
obj_to_create = 'medium-biter',
level = 70,
@ -129,8 +132,8 @@ Public.conjure_items = {
mana_cost = 100,
tick = 200,
enabled = true
},
[15] = {
}
spells[#spells + 1] = {
name = 'Medium Spitter',
obj_to_create = 'medium-spitter',
level = 70,
@ -138,8 +141,8 @@ Public.conjure_items = {
mana_cost = 100,
tick = 200,
enabled = true
},
[16] = {
}
spells[#spells + 1] = {
name = 'Bitter Spawner',
obj_to_create = 'biter-spawner',
level = 100,
@ -148,8 +151,8 @@ Public.conjure_items = {
mana_cost = 600,
tick = 1420,
enabled = true
},
[17] = {
}
spells[#spells + 1] = {
name = 'Spitter Spawner',
obj_to_create = 'spitter-spawner',
level = 100,
@ -158,8 +161,8 @@ Public.conjure_items = {
mana_cost = 600,
tick = 1420,
enabled = true
},
[18] = {
}
spells[#spells + 1] = {
name = 'AOE Grenade',
obj_to_create = 'grenade',
target = true,
@ -171,8 +174,8 @@ Public.conjure_items = {
mana_cost = 100,
tick = 150,
enabled = true
},
[19] = {
}
spells[#spells + 1] = {
name = 'Big AOE Grenade',
obj_to_create = 'cluster-grenade',
target = true,
@ -184,8 +187,8 @@ Public.conjure_items = {
mana_cost = 150,
tick = 200,
enabled = true
},
[20] = {
}
spells[#spells + 1] = {
name = 'Pointy Rocket',
obj_to_create = 'rocket',
range = 240,
@ -198,8 +201,8 @@ Public.conjure_items = {
mana_cost = 60,
tick = 320,
enabled = true
},
[21] = {
}
spells[#spells + 1] = {
name = 'Bitter Spew',
obj_to_create = 'acid-stream-spitter-big',
target = true,
@ -212,8 +215,8 @@ Public.conjure_items = {
mana_cost = 90,
tick = 100,
enabled = true
},
[22] = {
}
spells[#spells + 1] = {
name = 'Shoop Da Whoop!!',
obj_to_create = 'railgun-beam',
target = false,
@ -226,8 +229,8 @@ Public.conjure_items = {
mana_cost = 66,
tick = 200,
enabled = true
},
[23] = {
}
spells[#spells + 1] = {
name = 'Conjure Raw-fish',
obj_to_create = 'fish',
target = false,
@ -240,8 +243,8 @@ Public.conjure_items = {
mana_cost = 120,
tick = 320,
enabled = true
},
[24] = {
}
spells[#spells + 1] = {
name = 'Suicidal Comfylatron',
obj_to_create = 'suicidal_comfylatron',
target = false,
@ -254,8 +257,8 @@ Public.conjure_items = {
mana_cost = 250,
tick = 320,
enabled = true
},
[25] = {
}
spells[#spells + 1] = {
name = 'Distractor Capsule',
obj_to_create = 'distractor-capsule',
target = true,
@ -268,8 +271,8 @@ Public.conjure_items = {
mana_cost = 200,
tick = 320,
enabled = true
},
[26] = {
}
spells[#spells + 1] = {
name = 'Warp Gate',
obj_to_create = 'warp-gate',
target = true,
@ -280,7 +283,24 @@ Public.conjure_items = {
tick = 2000,
enabled = true
}
}
return spells
end
function Public.rebuild_spells()
local spells = Public.conjure_items()
local new_spells = {}
local spell_names = {}
for i = 1, #spells do
if spells[i].enabled then
new_spells[#new_spells + 1] = spells[i]
spell_names[#spell_names + 1] = spells[i].name
end
end
return new_spells, spell_names
end
Public.projectile_types = {
['explosives'] = {name = 'grenade', count = 0.5, max_range = 32, tick_speed = 1},

View File

@ -122,7 +122,7 @@ function Public.reset_table()
['small-worm-turret'] = 16,
['spitter-spawner'] = 64
}
this.rpg_spells = Spells.conjure_items
this.rpg_spells = {}
end
--- Gets value from table
@ -299,6 +299,14 @@ function Public.set_spells(key, value)
end
end
--- Defines the spell table
---@param tbl <table>
function Public.set_spells_table(tbl)
if tbl then
this.rpg_spells = tbl
end
end
Public.get_projectiles = Spells.projectile_types
Public.settings_frame_name = settings_frame_name
Public.save_button_name = save_button_name
@ -306,6 +314,7 @@ Public.discard_button_name = discard_button_name
Public.draw_main_frame_name = draw_main_frame_name
Public.main_frame_name = main_frame_name
Public.settings_button_name = settings_button_name
Public.rebuild_spells = Spells.rebuild_spells
local on_init = function()
Public.reset_table()

View File

@ -16,16 +16,6 @@ local set_data = Server.set_data
local try_get_data = Server.try_get_data
local concat = table.concat
local jail_messages = {
'You´re done bud!',
'Busted!'
}
local freedom_messages = {
'Yaay!',
'Welcome back!'
}
local valid_commands = {
['free'] = true,
['jail'] = true
@ -174,7 +164,7 @@ local jail = function(player, griefer)
permission_group.set_allows_action(defines.input_action.gui_selection_state_changed, true)
end
permission_group.add_player(griefer)
local message = griefer .. ' has been jailed by ' .. player .. '. ' .. jail_messages[math.random(1, #jail_messages)]
local message = griefer .. ' has been jailed by ' .. player .. '.'
if
game.players[griefer].character and game.players[griefer].character.valid and
@ -208,9 +198,7 @@ local free = function(player, griefer)
local permission_group = game.permissions.get_group('Default')
permission_group.add_player(griefer)
local message =
griefer ..
' was set free from jail by ' .. player .. '. ' .. freedom_messages[math.random(1, #freedom_messages)]
local message = griefer .. ' was set free from jail by ' .. player .. '.'
jailed[griefer] = nil