mirror of
https://github.com/Refactorio/RedMew.git
synced 2026-06-19 22:16:03 +02:00
Merge pull request #76 from Valansch/dev_forcetoggle_qol_fixes
Dev forcetoggle qol fixes
This commit is contained in:
+28
-6
@@ -24,15 +24,37 @@ require "tasklist"
|
||||
|
||||
local function player_joined(event)
|
||||
local player = game.players[event.player_index]
|
||||
player.insert { name = "raw-fish", count = 4 }
|
||||
player.insert { name = "iron-gear-wheel", count = 8 }
|
||||
player.insert { name = "iron-plate", count = 16 }
|
||||
player.print("Welcome to our Server. You can join our Discord at: discord.me/redmew")
|
||||
player.print("And remember.. Keep Calm And Spaghetti!")
|
||||
player.insert { name = "raw-fish", count = 4 }
|
||||
player.insert { name = "iron-gear-wheel", count = 8 }
|
||||
player.insert { name = "iron-plate", count = 16 }
|
||||
player.print("Welcome to our Server. You can join our Discord at: discord.me/redmew")
|
||||
player.print("And remember.. Keep Calm And Spaghetti!")
|
||||
end
|
||||
|
||||
function walkabout(player_name, distance)
|
||||
game.player.print("This command moved to /walkabout.")
|
||||
game.player.print("This command moved to /walkabout.")
|
||||
end
|
||||
|
||||
local hodor_messages = {{"Hodor.", 16}, {"Hodor?", 16},{"Hodor!", 16}, {"Hodor! Hodor! Hodor! Hodor!", 4}, {"Hodor :(",4}, {"Hodor :)",4}, {"HOOOODOOOR!", 4}, {"( ͡° ͜ʖ ͡°)",1}, {"☉ ‿ ⚆",1}}
|
||||
local message_weight_sum = 0
|
||||
for _,w in pairs(hodor_messages) do
|
||||
message_weight_sum = message_weight_sum + w[2]
|
||||
end
|
||||
|
||||
function hodor(event)
|
||||
local message = event.message:lower()
|
||||
if message:match("hodor") then
|
||||
local index = math.random(1, message_weight_sum)
|
||||
local message_weight_sum = 0
|
||||
for _,m in pairs(hodor_messages) do
|
||||
message_weight_sum = message_weight_sum + m[2]
|
||||
if message_weight_sum >= index then
|
||||
game.print("Hodor: " .. m[1])
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_player_created, player_joined)
|
||||
Event.register(defines.events.on_console_chat, hodor)
|
||||
|
||||
@@ -366,12 +366,18 @@ local function toggle_tp_mode(cmd)
|
||||
end
|
||||
|
||||
global.old_force = {}
|
||||
global.force_toggle_init = true
|
||||
local function forcetoggle(cmd)
|
||||
if not game.player or not (game.player.admin or is_mod(game.player.name)) then
|
||||
cant_run(cmd.name)
|
||||
return
|
||||
end
|
||||
|
||||
if global.force_toggle_init then
|
||||
game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration
|
||||
global.force_toggle_init = false
|
||||
end
|
||||
|
||||
if game.player.force.name == "enemy" then
|
||||
local old_force = global.old_force[game.player.name]
|
||||
if not old_force then
|
||||
@@ -385,6 +391,26 @@ local function forcetoggle(cmd)
|
||||
end
|
||||
end
|
||||
else
|
||||
--Put roboports into inventory
|
||||
inv = game.player.get_inventory(defines.inventory.player_armor)
|
||||
if inv[1].valid_for_read
|
||||
then
|
||||
local name = inv[1].name
|
||||
if name:match("power") or name:match("modular") then
|
||||
local equips = inv[1].grid.equipment
|
||||
for _,equip in pairs(equips) do
|
||||
if equip.name == "personal-roboport-equipment"
|
||||
or equip.name == "personal-roboport-mk2-equipment"
|
||||
or equip.name == "personal-laser-defense-equipment" then
|
||||
if game.player.insert{name = equip.name} == 0 then
|
||||
game.player.surface.spill_item_stack(game.player.position, {name = equip.name})
|
||||
end
|
||||
inv[1].grid.take(equip)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
global.old_force[game.player.name] = game.player.force.name
|
||||
game.player.force = "enemy"
|
||||
end
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ in this file and your run_*type*_module(event) function will be called.
|
||||
--require "locale.gen_shape.up"
|
||||
--require "locale.gen_shape.maze"
|
||||
--require "locale.gen_shape.spiral"
|
||||
--require "locale.gen_shape.threaded_spiral"
|
||||
--require "locale.gen_shape.threaded_spirals"
|
||||
--require "locale.gen_shape.spiral_tri"
|
||||
--require "locale.gen_shape.spiral2"
|
||||
--require "locale.gen_shape.donut"
|
||||
|
||||
+5
-1
@@ -29,8 +29,12 @@ local function on_player_deconstructed_area(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local init = true
|
||||
local function on_player_mined_item(event)
|
||||
if init then
|
||||
game.forces.enemy.research_all_technologies() --avoids losing logstics slot configuration on force toggle
|
||||
init = false
|
||||
end
|
||||
if event.entity.force.name ~= "enemy" and event.entity.force.name ~= "neutral" and event.entity.name ~= "entity-ghost" then
|
||||
local entity_name = event.entity.name
|
||||
if entity_name == "pipe-to-ground" then entity_name = "pipe" end
|
||||
|
||||
+2
-1
@@ -51,12 +51,13 @@ local function tasklist_show(player)
|
||||
end
|
||||
|
||||
if global.tasklist_author ~= nil then
|
||||
tasklist_panel_table.add { type = "label", caption = "-- updated by: " .. global.tasklist_author, single_line = false, name = "tasklist_author"}
|
||||
tasklist_panel_table.add { type = "label", caption = "Updated by: " .. global.tasklist_author, single_line = false, name = "tasklist_author"}
|
||||
local tasklist_label = tasklist_panel_table["tasklist_author"]
|
||||
tasklist_label.style.maximal_width = 208
|
||||
tasklist_label.style.minimal_width = 208
|
||||
tasklist_label.style.maximal_height = 165
|
||||
tasklist_label.style.font = "default"
|
||||
tasklist_label.style.font_color = {r = 0.55, g = 0.55, b = 0.55}
|
||||
end
|
||||
|
||||
frame.add { type = "table", name = "tasklist_panel_button_table", colspan = 3 }
|
||||
|
||||
Reference in New Issue
Block a user