1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-08 00:39:30 +02:00

Merge pull request #5 from Gerkiz/master

Added when looting corpse it sends it to discord.
New Module "burden"
This commit is contained in:
MewMew 2019-02-20 19:39:24 +01:00 committed by GitHub
commit 34c818ba46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 3 deletions

View File

@ -224,6 +224,7 @@ local function on_gui_opened(event)
if corpse_owner.force.name ~= player.force.name then return end
if player.name ~= corpse_owner.name then
game.print(player.name .. " is looting " .. corpse_owner.name .. "´s body.", { r=0.85, g=0.85, b=0.85})
server_commands.to_discord_bold(table.concat{player.name .. " is looting " .. corpse_owner.name .. "´s body."})
end
end
@ -233,7 +234,8 @@ local function on_pre_player_mined_item(event)
local corpse_owner = game.players[event.entity.character_corpse_player_index]
if corpse_owner.force.name ~= player.force.name then return end
if player.name ~= corpse_owner.name then
game.print(player.name .. " has looted " .. corpse_owner.name .. "´s body.", { r=0.85, g=0.85, b=0.85})
game.print(player.name .. " has looted " .. corpse_owner.name .. "´s body.", { r=0.85, g=0.85, b=0.85})
server_commands.to_discord_bold(table.concat{player.name .. " has looted " .. corpse_owner.name .. "´s body."})
end
end
@ -248,4 +250,4 @@ event.add(defines.events.on_player_demoted, on_player_demoted)
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_pre_player_mined_item, on_pre_player_mined_item)
event.add(defines.events.on_player_promoted, on_player_promoted)
event.add(defines.events.on_player_used_capsule, on_player_used_capsule)
event.add(defines.events.on_player_used_capsule, on_player_used_capsule)

View File

@ -27,6 +27,7 @@ require "poll"
--require "maps.modules.dynamic_landfill"
--require "maps.modules.players_trample_paths"
--require "maps.modules.hunger_games"
--require "maps.modules.burden"
-----------------------------
---- enable maps here ----
@ -59,4 +60,4 @@ local function on_player_created(event)
player.gui.left.style = 'slot_table_spacing_vertical_flow'
end
event.add(defines.events.on_player_created, on_player_created)
event.add(defines.events.on_player_created, on_player_created)

36
maps/modules/burden.lua Normal file
View File

@ -0,0 +1,36 @@
local event = require 'utils.event'
local function compute_fullness(player)
local inv = player.get_inventory(defines.inventory.player_main)
local max_stacks = #inv
local num_stacks = 0
local contents = inv.get_contents()
for item, count in pairs(contents) do
local stack_size = 1
if game.item_prototypes[item].stackable then
stack_size = game.item_prototypes[item].stack_size
end
num_stacks = num_stacks + count / stack_size
end
return num_stacks / max_stacks
end
local function check_burden(event)
local player = game.players[event.player_index]
local fullness = compute_fullness(player)
player.character_running_speed_modifier = 0.5 - fullness
end
local function on_init(event)
script.on_event(defines.events.on_player_main_inventory_changed, check_burden)
end
local function on_load(event)
script.on_event(defines.events.on_player_main_inventory_changed, check_burden)
end
event.on_init(on_init)
event.on_load(on_load)