Skip to content

Commit

Permalink
Fix pirates
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Aug 23, 2024
1 parent 077e200 commit 1eb85d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
5 changes: 4 additions & 1 deletion maps/pirates/api_events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ local function damage_to_players_changes(event)

-- if not (event.cause.name == 'small-biter') or (event.cause.name == 'small-spitter') or (event.cause.name == 'medium-biter') or (event.cause.name == 'medium-spitter') or (event.cause.name == 'big-biter') or (event.cause.name == 'big-spitter') or (event.cause.name == 'behemoth-biter') or (event.cause.name == 'behemoth-spitter') then return end

if not event.entity then return end
if not event.entity.player or not event.entity.player.valid then return end

local player_index = event.entity.player.index
local player = game.players[player_index]

Expand Down Expand Up @@ -2281,4 +2284,4 @@ event.add(defines.events.on_market_item_purchased, event_on_market_item_purchase
event.add(defines.events.on_player_respawned, event_on_player_respawned)
event.add(defines.events.on_entity_spawned, event_on_entity_spawned)

return Public
return Public
40 changes: 21 additions & 19 deletions maps/pirates/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local _inspect = require 'utils.inspect'.inspect
-- local Modifers = require 'player_modifiers'
local BottomFrame = require 'utils.gui.bottom_frame'
local Autostash = require 'modules.autostash'
local AntiGrief = require 'utils.antigrief'
require 'modules.inserter_drops_pickup'


Expand Down Expand Up @@ -78,27 +79,29 @@ local Public = {}
-- parrot sprites from https://elthen.itch.io/2d-pixel-art-parrot-sprites, licensed appropriately

local jetty_delayed = Token.register(
-- function(data)
function()
-- function(data)
function ()
Surfaces.Lobby.place_lobby_jetty_and_boats()
end
)
local function on_init()
Memory.global_reset_memory()
local global_memory = Memory.get_global_memory()

AntiGrief.enable_capsule_cursor_warning(false)

game.reset_time_played()

-- local spectator = game.create_force('spectator')
-- local spectator_permissions = game.permissions.create_group('spectator')
-- spectator_permissions.set_allows_action(defines.input_action.start_walking,false)

Autostash.insert_into_furnace(true)
-- Autostash.insert_into_wagon(true)
Autostash.bottom_button(true)
BottomFrame.reset()
BottomFrame.activate_custom_buttons(true)
-- BottomFrame.bottom_right(true)
Autostash.insert_into_furnace(true)
-- Autostash.insert_into_wagon(true)
Autostash.bottom_button(true)
BottomFrame.reset()
BottomFrame.activate_custom_buttons(true)
-- BottomFrame.bottom_right(true)

local mgs = game.surfaces['nauvis'].map_gen_settings
mgs.width = 16
Expand Down Expand Up @@ -135,7 +138,6 @@ local function on_init()

-- Delay.global_add(Delay.global_enum.PLACE_LOBBY_JETTY_AND_BOATS)
Task.set_timeout_in_ticks(2, jetty_delayed, {})

end

local event = require 'utils.event'
Expand Down Expand Up @@ -276,11 +278,11 @@ local function crew_tick()
if memory.crew_disband_tick_message < tick then
memory.crew_disband_tick_message = nil

local message1 = {'pirates.crew_disband_tick_message', 30}
local message1 = { 'pirates.crew_disband_tick_message', 30 }

Common.notify_force(memory.force, message1)

Server.to_discord_embed_raw({'', '[' .. memory.name .. '] ', message1}, true)
Server.to_discord_embed_raw({ '', '[' .. memory.name .. '] ', message1 }, true)
end
end

Expand Down Expand Up @@ -342,16 +344,16 @@ event.add(defines.events.on_chunk_generated, PiratesApiEvents.event_on_chunk_gen
----- FOR DESYNC BUGFIXING -----
local gMeta = getmetatable(_ENV)
if not gMeta then
gMeta = {}
setmetatable(_ENV, gMeta)
gMeta = {}
setmetatable(_ENV, gMeta)
end

gMeta.__newindex = function(_, n, v)
log('Desync warning: attempt to write to undeclared var ' .. n)
global[n] = v
gMeta.__newindex = function (_, n, v)
log('Desync warning: attempt to write to undeclared var ' .. n)
global[n] = v
end
gMeta.__index = function(_, n)
return global[n]
gMeta.__index = function (_, n)
return global[n]
end

return Public
return Public
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ function Public.tick_quest_structure_entry_price_check()
local count = 1
for k, v in pairs(entry_price.batchRawMaterials) do
local item_count = v * removed / entry_price.batchSize
item_count = math.floor(item_count)
if item_count > 0 then
red_invs[count].insert({name = k, count = item_count});
count = count + 1
Expand All @@ -407,4 +408,4 @@ function Public.tick_quest_structure_entry_price_check()
end


return Public
return Public

0 comments on commit 1eb85d2

Please sign in to comment.