mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Merge branch 'develop'
# Conflicts: # control.lua # map_layout.lua
This commit is contained in:
commit
e2a7808dcf
12
band.lua
12
band.lua
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
-- SETTINGS
|
-- SETTINGS
|
||||||
local option_band_change_interval = 60 * 3 -- in ticks
|
local option_band_change_interval = 60 * 3 -- in ticks
|
||||||
|
if not global.band_last_change then global.band_last_change = {} end
|
||||||
|
|
||||||
-- Role list: "band_roles.lua"
|
-- Role list: "band_roles.lua"
|
||||||
local band_roles = require "band_roles"
|
local band_roles = require "band_roles"
|
||||||
@ -21,13 +22,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local expand_band_gui
|
local expand_band_gui
|
||||||
local band_last_change = -option_band_change_interval
|
|
||||||
|
|
||||||
-- store current role
|
-- store current role
|
||||||
local local_role
|
local local_role
|
||||||
|
|
||||||
local function create_band_gui(event)
|
local function create_band_gui(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
|
global.band_last_change[event.player_index] = game.tick
|
||||||
if player.gui.top.band_toggle_btn == nil then
|
if player.gui.top.band_toggle_btn == nil then
|
||||||
local button = player.gui.top.add { name = "band_toggle_btn", type = "sprite-button", caption = "Tag", style = "dialog_button_style" }
|
local button = player.gui.top.add { name = "band_toggle_btn", type = "sprite-button", caption = "Tag", style = "dialog_button_style" }
|
||||||
button.style.font = "default-bold"
|
button.style.font = "default-bold"
|
||||||
@ -384,8 +386,8 @@ local function on_gui_click(event)
|
|||||||
|
|
||||||
--role button clicked
|
--role button clicked
|
||||||
if name:find("band_role_") == 1 then
|
if name:find("band_role_") == 1 then
|
||||||
if not player.admin and event.tick - band_last_change < option_band_change_interval then
|
if not player.admin and event.tick - global.band_last_change[event.player_index] < option_band_change_interval then
|
||||||
player.print("Too fast! Please wait... " .. math.floor(1+(band_last_change + option_band_change_interval - event.tick)/60).." s.")
|
player.print("Too fast! Please wait... " .. math.floor(1+(global.band_last_change[event.player_index] + option_band_change_interval - event.tick)/60).." s.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local _,role_ind_start = name:find("band_role_")
|
local _,role_ind_start = name:find("band_role_")
|
||||||
@ -398,7 +400,7 @@ local function on_gui_click(event)
|
|||||||
|
|
||||||
for role, role_icons in pairs(roles) do
|
for role, role_icons in pairs(roles) do
|
||||||
if (name_role == role) then
|
if (name_role == role) then
|
||||||
band_last_change = event.tick
|
global.band_last_change[event.player_index] = event.tick
|
||||||
|
|
||||||
player.gui.top.band_toggle_btn.caption = ""
|
player.gui.top.band_toggle_btn.caption = ""
|
||||||
player.gui.top.band_toggle_btn.sprite = event.element.sprite --get_random_from_table(role_icons)
|
player.gui.top.band_toggle_btn.sprite = event.element.sprite --get_random_from_table(role_icons)
|
||||||
|
BIN
blueprint.dat
BIN
blueprint.dat
Binary file not shown.
34
chatlog.lua
Normal file
34
chatlog.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
function ternary (cond, T, F)
|
||||||
|
if cond then return T else return F end
|
||||||
|
end
|
||||||
|
|
||||||
|
function format_time(ticks)
|
||||||
|
local s = tostring(math.floor(ticks / 60) % 60)
|
||||||
|
local m = tostring(math.floor(ticks / 3600) % 60)
|
||||||
|
local h = tostring(math.floor(ticks / 216000))
|
||||||
|
h = ternary(h:len() == 1, "0" .. h, h)
|
||||||
|
m = ternary(m:len() == 1, "0" .. m, m)
|
||||||
|
s = ternary(s:len() == 1, "0" .. s, s)
|
||||||
|
print(tostring(h:len()))
|
||||||
|
return (h .. ":" .. m .. ":" ..s)
|
||||||
|
end
|
||||||
|
|
||||||
|
function log_chat_message(event, message)
|
||||||
|
game.write_file("chatlog.txt", "[" .. format_time(event.tick) .. "] " .. message .. "\n", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function player_send_command(event)
|
||||||
|
local silent = event.command == "silent-command"
|
||||||
|
if not silent then
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
log_chat_message(event, player.name .. " used command: " .. event.command .. " " .. event.parameters)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function player_send(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
log_chat_message(event, player.name .. ": " .. event.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Event.register(defines.events.on_console_command, player_send_command)
|
||||||
|
Event.register(defines.events.on_console_chat, player_send)
|
26
control.lua
26
control.lua
@ -3,13 +3,17 @@ require "locale/utils/event"
|
|||||||
require "config"
|
require "config"
|
||||||
require "locale/utils/utils"
|
require "locale/utils/utils"
|
||||||
require "base_data"
|
require "base_data"
|
||||||
|
require "chatlog"
|
||||||
require "info"
|
require "info"
|
||||||
|
require "player_list"
|
||||||
require "poll"
|
require "poll"
|
||||||
require "band"
|
require "band"
|
||||||
require "fish_market"
|
require "fish_market"
|
||||||
require "train_station_names"
|
require "train_station_names"
|
||||||
require "score"
|
require "score"
|
||||||
require "map_layout"
|
require "map_layout"
|
||||||
|
require "custom_commands"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function player_joined(event)
|
function player_joined(event)
|
||||||
@ -26,7 +30,7 @@ function player_joined(event)
|
|||||||
--player.insert { name = "substation", count = 16 }
|
--player.insert { name = "substation", count = 16 }
|
||||||
--player.insert { name = "logistic-chest-passive-provider", count = 16 }
|
--player.insert { name = "logistic-chest-passive-provider", count = 16 }
|
||||||
--player.insert { name = "power-armor", count = 1 }
|
--player.insert { name = "power-armor", count = 1 }
|
||||||
player.print("Welcome to our Server. You can join our Discord at: discord.gg/RedMew")
|
player.print("Welcome to our Server. You can join our Discord at: discord.me/redmew")
|
||||||
player.print("And remember.. Keep Calm And Spaghetti!")
|
player.print("And remember.. Keep Calm And Spaghetti!")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,14 +44,20 @@ function walkabout(player_name, distance)
|
|||||||
|
|
||||||
if distance == "close" then
|
if distance == "close" then
|
||||||
distance = math.random(3000, 7000)
|
distance = math.random(3000, 7000)
|
||||||
|
else
|
||||||
|
if distance == "far" then
|
||||||
|
distance = math.random(7000, 11000)
|
||||||
|
else
|
||||||
|
if distance == "very far" then
|
||||||
|
distance = math.random(11000, 15000)
|
||||||
|
else
|
||||||
|
game.print("Walkabout failed.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if distance == "far" then
|
|
||||||
distance = math.random(7000, 11000)
|
|
||||||
end
|
|
||||||
if distance == "very far" then
|
|
||||||
distance = math.random(11000, 15000)
|
|
||||||
end
|
|
||||||
|
|
||||||
local x = 1
|
local x = 1
|
||||||
while game.players[x] ~= nil do
|
while game.players[x] ~= nil do
|
||||||
local player = game.players[x]
|
local player = game.players[x]
|
||||||
|
67
custom_commands.lua
Normal file
67
custom_commands.lua
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
function cant_run(name)
|
||||||
|
game.player.print("Can't run command (" .. name .. ") - you are not an admin.")
|
||||||
|
end
|
||||||
|
|
||||||
|
function invoke(cmd)
|
||||||
|
if not game.player.admin then
|
||||||
|
cant_run(cmd.name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target = cmd["parameter"]
|
||||||
|
if target == nil or game.players[target] == nil then
|
||||||
|
game.player.print("Unknown player.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = game.surfaces[1].find_non_colliding_position("player", game.player.position, 0, 1)
|
||||||
|
game.players[target].teleport({pos.x, pos.y})
|
||||||
|
game.print(target .. ", get your ass over here!")
|
||||||
|
end
|
||||||
|
|
||||||
|
function teleport_player(cmd)
|
||||||
|
if not game.player.admin then
|
||||||
|
cant_run(cmd.name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local target = cmd["parameter"]
|
||||||
|
if target == nil or game.players[target] == nil then
|
||||||
|
game.player.print("Unknown player.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = game.surfaces[1].find_non_colliding_position("player", game.players[target].position, 0, 1)
|
||||||
|
game.player.teleport({pos.x, pos.y})
|
||||||
|
game.print(target .. "! watcha doin'?!")
|
||||||
|
end
|
||||||
|
|
||||||
|
function teleport_location(cmd)
|
||||||
|
if not game.player.admin then
|
||||||
|
cant_run(cmd.name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if game.player.selected == nil then
|
||||||
|
game.player.print("Nothing selected.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local pos = game.surfaces[1].find_non_colliding_position("player", game.player.selected.position, 0, 1)
|
||||||
|
game.player.teleport({pos.x, pos.y})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function detrain(param)
|
||||||
|
if not game.player.admin then
|
||||||
|
cant_run(param.name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local player_name = param["parameter"]
|
||||||
|
if player_name == nil or game.players[player_name] == nil then game.player.print("Unknown player.") return end
|
||||||
|
if game.players[player_name].vehicle == nil then game.player.print("Player not in vehicle.") return end
|
||||||
|
game.players[player_name].vehicle.passenger = game.player
|
||||||
|
game.print(string.format("%s kicked %s off the train. God damn!", game.player.name, player_name))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
commands.add_command("detrain", "<player> - Kicks the player off a train.", detrain)
|
||||||
|
commands.add_command("tpplayer", "<player> - Teleports you to the player.", teleport_player)
|
||||||
|
commands.add_command("invoke", "<player> - Teleports the player to you.", invoke)
|
||||||
|
commands.add_command("tppos", "Teleports you to a selected entity.", teleport_location)
|
284
fish_market.lua
284
fish_market.lua
@ -1,5 +1,5 @@
|
|||||||
--[[
|
--[[
|
||||||
Hello there script explorer!
|
Hello there script explorer!
|
||||||
|
|
||||||
With this you can add a "Fish Market" to your World
|
With this you can add a "Fish Market" to your World
|
||||||
You can earn fish by killing alot of biters or by mining wood, ores, rocks.
|
You can earn fish by killing alot of biters or by mining wood, ores, rocks.
|
||||||
@ -7,8 +7,18 @@ To spawn the market, do "/c market()" in your chat ingame as the games host.
|
|||||||
It will spawn a few tiles north of the current position where your character is.
|
It will spawn a few tiles north of the current position where your character is.
|
||||||
|
|
||||||
---MewMew---
|
---MewMew---
|
||||||
|
|
||||||
|
|
||||||
|
!! now with speed boost item addon from air20 !!
|
||||||
|
|
||||||
|
to be added(maybe)
|
||||||
|
fix pet health at refresh
|
||||||
|
make pet faster
|
||||||
|
make pet follow you moar
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function market()
|
function market()
|
||||||
local radius = 10
|
local radius = 10
|
||||||
local surface = game.surfaces[1]
|
local surface = game.surfaces[1]
|
||||||
@ -24,12 +34,12 @@ function market()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local player = game.players[1]
|
local player = game.players[1]
|
||||||
|
|
||||||
local market_location = {x = player.position.x, y = player.position.y}
|
local market_location = {x = player.position.x, y = player.position.y}
|
||||||
market_location.y = market_location.y - 4
|
market_location.y = market_location.y - 4
|
||||||
|
|
||||||
-- create water around market
|
-- create water around market
|
||||||
local waterTiles = {}
|
local waterTiles = {}
|
||||||
for i = -4, 4 do
|
for i = -4, 4 do
|
||||||
@ -40,45 +50,34 @@ function market()
|
|||||||
surface.set_tiles(waterTiles)
|
surface.set_tiles(waterTiles)
|
||||||
local market = surface.create_entity{name="market", position=market_location, force=force}
|
local market = surface.create_entity{name="market", position=market_location, force=force}
|
||||||
market.destructible = false
|
market.destructible = false
|
||||||
|
|
||||||
|
market.add_market_item{price={{"raw-fish", 10}}, offer={type="give-item", item="exoskeleton-equipment"}}
|
||||||
|
market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="small-plane"}}
|
||||||
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="rail", count=2}}
|
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="rail", count=2}}
|
||||||
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-signal"}}
|
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-signal"}}
|
||||||
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-chain-signal"}}
|
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="rail-chain-signal"}}
|
||||||
market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="train-stop"}}
|
market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="train-stop"}}
|
||||||
market.add_market_item{price={{"raw-fish", 75}}, offer={type="give-item", item="locomotive"}}
|
market.add_market_item{price={{"raw-fish", 75}}, offer={type="give-item", item="locomotive"}}
|
||||||
market.add_market_item{price={{"raw-fish", 250}}, offer={type="give-item", item="small-plane"}}
|
|
||||||
market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="cargo-wagon"}}
|
market.add_market_item{price={{"raw-fish", 30}}, offer={type="give-item", item="cargo-wagon"}}
|
||||||
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="red-wire", count=2}}
|
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="red-wire", count=2}}
|
||||||
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="green-wire", count=2}}
|
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="green-wire", count=2}}
|
||||||
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="decider-combinator"}}
|
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="decider-combinator"}}
|
||||||
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="arithmetic-combinator"}}
|
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="arithmetic-combinator"}}
|
||||||
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="constant-combinator"}}
|
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="constant-combinator"}}
|
||||||
market.add_market_item{price={{"raw-fish", 7}}, offer={type="give-item", item="programmable-speaker"}}
|
market.add_market_item{price={{"raw-fish", 7}}, offer={type="give-item", item="programmable-speaker"}}
|
||||||
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="piercing-rounds-magazine"}}
|
market.add_market_item{price={{"raw-fish", 3}}, offer={type="give-item", item="piercing-rounds-magazine"}}
|
||||||
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="grenade"}}
|
market.add_market_item{price={{"raw-fish", 2}}, offer={type="give-item", item="grenade"}}
|
||||||
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="land-mine"}}
|
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="land-mine"}}
|
||||||
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="solid-fuel"}}
|
market.add_market_item{price={{"raw-fish", 1}}, offer={type="give-item", item="solid-fuel"}}
|
||||||
market.add_market_item{price={{"raw-fish", 125}}, offer={type="give-item", item="rocket-launcher"}}
|
market.add_market_item{price={{"raw-fish", 125}}, offer={type="give-item", item="rocket-launcher"}}
|
||||||
market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="rocket"}}
|
market.add_market_item{price={{"raw-fish", 15}}, offer={type="give-item", item="rocket"}}
|
||||||
market.add_market_item{price={{"raw-fish", 20}}, offer={type="give-item", item="explosive-rocket"}}
|
market.add_market_item{price={{"raw-fish", 20}}, offer={type="give-item", item="explosive-rocket"}}
|
||||||
market.add_market_item{price={{"raw-fish", 2500}}, offer={type="give-item", item="atomic-bomb"}}
|
market.add_market_item{price={{"raw-fish", 2500}}, offer={type="give-item", item="atomic-bomb"}}
|
||||||
market.add_market_item{price={{"raw-fish", 1000}}, offer={type="give-item", item="belt-immunity-equipment"}}
|
market.add_market_item{price={{"raw-fish", 100}}, offer={type="give-item", item="loader"}}
|
||||||
|
market.add_market_item{price={{"raw-fish", 175}}, offer={type="give-item", item="fast-loader"}}
|
||||||
end
|
market.add_market_item{price={{"raw-fish", 250}}, offer={type="give-item", item="express-loader"}}
|
||||||
|
market.add_market_item{price={{"raw-fish", 1000}}, offer={type="give-item", item="belt-immunity-equipment"}}
|
||||||
|
|
||||||
local function create_market_init_button(event)
|
|
||||||
local player = game.players[1]
|
|
||||||
|
|
||||||
if player.gui.top.poll == nil then
|
|
||||||
local button = player.gui.top.add { name = "poll", type = "sprite-button", sprite = "item/programmable-speaker" }
|
|
||||||
button.style.font = "default-bold"
|
|
||||||
button.style.minimal_height = 38
|
|
||||||
button.style.minimal_width = 38
|
|
||||||
button.style.top_padding = 2
|
|
||||||
button.style.left_padding = 4
|
|
||||||
button.style.right_padding = 4
|
|
||||||
button.style.bottom_padding = 2
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local fish_market_message = {}
|
local fish_market_message = {}
|
||||||
@ -94,23 +93,23 @@ local function fish_earned(event, amount)
|
|||||||
|
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
player.insert { name = "raw-fish", count = amount }
|
player.insert { name = "raw-fish", count = amount }
|
||||||
|
|
||||||
if global.fish_market_fish_caught[event.player_index] then
|
if global.fish_market_fish_caught[event.player_index] then
|
||||||
global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + 1
|
global.fish_market_fish_caught[event.player_index] = global.fish_market_fish_caught[event.player_index] + 1
|
||||||
else
|
else
|
||||||
global.fish_market_fish_caught[event.player_index] = 1
|
global.fish_market_fish_caught[event.player_index] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if global.fish_market_fish_caught[event.player_index] <= total_fish_market_messages then
|
if global.fish_market_fish_caught[event.player_index] <= total_fish_market_messages then
|
||||||
local x = global.fish_market_fish_caught[event.player_index]
|
local x = global.fish_market_fish_caught[event.player_index]
|
||||||
player.print(fish_market_message[x])
|
player.print(fish_market_message[x])
|
||||||
end
|
end
|
||||||
|
|
||||||
local x = global.fish_market_fish_caught[event.player_index] % 7
|
local x = global.fish_market_fish_caught[event.player_index] % 7
|
||||||
if x == 0 then
|
if x == 0 then
|
||||||
local z = math.random(1,total_fish_market_bonus_messages)
|
local z = math.random(1,total_fish_market_bonus_messages)
|
||||||
player.print(fish_market_bonus_message[z])
|
player.print(fish_market_bonus_message[z])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -120,49 +119,234 @@ local function preplayer_mined_item(event)
|
|||||||
-- game.print(event.entity.type)
|
-- game.print(event.entity.type)
|
||||||
|
|
||||||
if event.entity.type == "resource" then
|
if event.entity.type == "resource" then
|
||||||
local x = math.random(1,2)
|
local x = math.random(1,2)
|
||||||
if x == 1 then
|
if x == 1 then
|
||||||
fish_earned(event, 1)
|
fish_earned(event, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.entity.name == "fish" then
|
if event.entity.name == "fish" then
|
||||||
fish_earned(event, 0)
|
fish_earned(event, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.entity.name == "stone-rock" then
|
if event.entity.name == "stone-rock" then
|
||||||
fish_earned(event, 10)
|
fish_earned(event, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.entity.name == "huge-rock" then
|
if event.entity.name == "red-desert-rock-huge-01" then
|
||||||
fish_earned(event, 25)
|
fish_earned(event, 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.entity.name == "big-rock" then
|
if event.entity.name == "red-desert-rock-big-01" then
|
||||||
fish_earned(event, 15)
|
fish_earned(event, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
if event.entity.type == "tree" then
|
if event.entity.type == "tree" then
|
||||||
local x = math.random(1,4)
|
local x = math.random(1,4)
|
||||||
if x == 1 then
|
if x == 1 then
|
||||||
fish_earned(event, 4)
|
fish_earned(event, 4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fish_drop_entity_died(event)
|
local function fish_drop_entity_died(event)
|
||||||
|
|
||||||
if event.entity.force.name == "enemy" then
|
if event.entity.force.name == "enemy" then
|
||||||
-- global.score_biter_total_kills = global.score_biter_total_kills + 1
|
-- global.score_biter_total_kills = global.score_biter_total_kills + 1
|
||||||
-- game.print(global.score_biter_total_kills)
|
-- game.print(global.score_biter_total_kills)
|
||||||
if global.score_biter_total_kills % 30 == 0 then
|
if global.score_biter_total_kills % 150 == 0 then
|
||||||
local surface = event.entity.surface
|
local surface = event.entity.surface
|
||||||
local x = math.random(1,3)
|
local x = math.random(1,2)
|
||||||
surface.spill_item_stack(event.entity.position, { name = "raw-fish", count = x }, 1)
|
surface.spill_item_stack(event.entity.position, { name = "raw-fish", count = x }, 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function pet(player, entity_name)
|
||||||
|
if not player then
|
||||||
|
player = game.connected_players[1]
|
||||||
|
else
|
||||||
|
player = game.players[player]
|
||||||
|
end
|
||||||
|
if not entity_name then
|
||||||
|
entity_name = "small-biter"
|
||||||
|
end
|
||||||
|
if not global.player_pets then global.player_pets = {} end
|
||||||
|
|
||||||
|
local surface = game.surfaces[1]
|
||||||
|
|
||||||
|
local pos = player.position
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
|
||||||
|
local x = 1
|
||||||
|
x = x + #global.player_pets
|
||||||
|
|
||||||
|
global.player_pets[x] = {}
|
||||||
|
global.player_pets[x].entity = surface.create_entity {name=entity_name, position=pos, force="player"}
|
||||||
|
global.player_pets[x].owner = player.index
|
||||||
|
global.player_pets[x].id = x
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local function reset_player_runningspeed(player)
|
||||||
|
player.character_running_speed_modifier = global.player_speed_boost_records[player.index].pre_boost_modifier
|
||||||
|
global.player_speed_boost_records[player.index] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function boost_player_runningspeed(player)
|
||||||
|
if global.player_speed_boost_records == nil then global.player_speed_boost_records = {} end
|
||||||
|
|
||||||
|
if global.player_speed_boost_records[player.index] == nil then
|
||||||
|
global.player_speed_boost_records[player.index] = {
|
||||||
|
start_tick = game.tick,
|
||||||
|
pre_boost_modifier = player.character_running_speed_modifier,
|
||||||
|
boost_lvl = 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
local boost_msg = {
|
||||||
|
[1] = "%s found the lost Dragon Scroll and got a lv.1 speed boost!",
|
||||||
|
[2] = "Guided by Master Oogway, %s got a lv.2 speed boost!",
|
||||||
|
[3] = "Kungfu Master %s defended the village and was awarded a lv.3 speed boost!",
|
||||||
|
[4] = "Travelled at the speed of light. %s saw a blackhole. Oops."
|
||||||
|
}
|
||||||
|
global.player_speed_boost_records[player.index].boost_lvl = 1 + global.player_speed_boost_records[player.index].boost_lvl
|
||||||
|
player.character_running_speed_modifier = 1 + player.character_running_speed_modifier
|
||||||
|
game.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
|
||||||
|
if global.player_speed_boost_records[player.index].boost_lvl >= 4 then
|
||||||
|
reset_player_runningspeed(player)
|
||||||
|
player.character.die()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function market_item_purchased(event)
|
||||||
|
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
|
if event.offer_index == 1 then -- exoskeleton-equipment
|
||||||
|
player.get_inventory(defines.inventory.player_main).remove({name="exoskeleton-equipment", count=event.count})
|
||||||
|
boost_player_runningspeed(player)
|
||||||
|
end
|
||||||
|
|
||||||
|
if event.offer_index == 2 then
|
||||||
|
player.get_inventory(defines.inventory.player_main).remove({name="small-plane", count=event.count})
|
||||||
|
local chance = 4
|
||||||
|
local x = math.random(1,3)
|
||||||
|
if x < 3 then
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "small-biter"
|
||||||
|
else
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "medium-biter"
|
||||||
|
else
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "big-biter"
|
||||||
|
else
|
||||||
|
rolled_pet = "behemoth-biter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "small-spitter"
|
||||||
|
else
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "medium-spitter"
|
||||||
|
else
|
||||||
|
local x = math.random(1,chance)
|
||||||
|
if x < chance then
|
||||||
|
rolled_pet = "big-spitter"
|
||||||
|
else
|
||||||
|
rolled_pet = "behemoth-spitter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local str = player.name
|
||||||
|
str = str .. " bought his very own pet "
|
||||||
|
str = str .. rolled_pet
|
||||||
|
str = str .. " at the fish market!!"
|
||||||
|
game.print(str)
|
||||||
|
pet(event.player_index, rolled_pet)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if not global.pet_command_rotation then global.pet_command_rotation = 1 end
|
||||||
|
|
||||||
|
local function on_tick(event)
|
||||||
|
|
||||||
|
if game.tick % 1000 == 0 then
|
||||||
|
if global.player_speed_boost_records then
|
||||||
|
for k,v in pairs(global.player_speed_boost_records) do
|
||||||
|
if game.tick - v.start_tick > 3000 then
|
||||||
|
reset_player_runningspeed(game.players[k])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if game.tick % 200 == 0 then
|
||||||
|
for _, pets in pairs(global.player_pets) do
|
||||||
|
local player = game.players[pets.owner]
|
||||||
|
if pcall(function () local x = pets.entity.name end) then
|
||||||
|
if global.pet_command_rotation % 15 == 0 then
|
||||||
|
local surface = game.surfaces[1]
|
||||||
|
local pet_pos = pets.entity.position
|
||||||
|
local pet_name = pets.entity.name
|
||||||
|
local pet_direction = pets.entity.direction
|
||||||
|
pets.entity.destroy()
|
||||||
|
pets.entity = surface.create_entity {name=pet_name, position=pet_pos, direction=pet_direction, force="player"}
|
||||||
|
end
|
||||||
|
if global.pet_command_rotation % 2 == 1 then
|
||||||
|
pets.entity.set_command({type=defines.command.go_to_location, destination=player.position,distraction=defines.distraction.none})
|
||||||
|
else
|
||||||
|
local fake_pos = pets.entity.position
|
||||||
|
pets.entity.set_command({type=defines.command.go_to_location, destination=fake_pos,distraction=defines.distraction.none})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
global.player_pets[pets.id] = nil
|
||||||
|
local str = player.name .. "´s pet died ;_;"
|
||||||
|
game.print(str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
global.pet_command_rotation = global.pet_command_rotation + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
function help()
|
||||||
|
local infotext = global.player_pets[1].entity.help()
|
||||||
|
player = game.players[1]
|
||||||
|
player.gui.left.direction = "horizontal"
|
||||||
|
local frame = player.gui.left.add { type = "frame", name = "info_panel"}
|
||||||
|
frame.style.top_padding = 20
|
||||||
|
frame.style.left_padding = 20
|
||||||
|
frame.style.right_padding = 20
|
||||||
|
frame.style.bottom_padding = 20
|
||||||
|
local info_table = frame.add { type = "table", colspan = 1, name = "info_table" }
|
||||||
|
local headline_label = info_table.add { type = "label", name = "headline_label", caption = "redmew fishy info" }
|
||||||
|
headline_label.style.font = "default-listbox"
|
||||||
|
headline_label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||||
|
|
||||||
|
|
||||||
|
local text_box = info_table.add { type = "text-box", text = infotext, name = "text_box" }
|
||||||
|
text_box.read_only = true
|
||||||
|
text_box.selectable = true
|
||||||
|
text_box.word_wrap = false
|
||||||
|
text_box.style.right_padding = 5
|
||||||
|
text_box.style.top_padding = 5
|
||||||
|
text_box.style.left_padding = 5
|
||||||
|
text_box.style.bottom_padding = 5
|
||||||
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item)
|
Event.register(defines.events.on_preplayer_mined_item, preplayer_mined_item)
|
||||||
Event.register(defines.events.on_entity_died, fish_drop_entity_died)
|
Event.register(defines.events.on_entity_died, fish_drop_entity_died)
|
||||||
|
Event.register(defines.events.on_market_item_purchased, market_item_purchased)
|
||||||
|
Event.register(defines.events.on_tick, on_tick)
|
||||||
|
9
info.lua
9
info.lua
@ -1,7 +1,7 @@
|
|||||||
local function create_info_button(event)
|
local function create_info_button(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
if player.gui.top.info == nil then
|
if player.gui.top.info_button == nil then
|
||||||
local button = player.gui.top.add({ type = "sprite-button", name = "info_button", sprite = "item/raw-fish" })
|
local button = player.gui.top.add({ type = "sprite-button", name = "info_button", sprite = "item/raw-fish" })
|
||||||
button.style.minimal_height = 38
|
button.style.minimal_height = 38
|
||||||
button.style.minimal_width = 38
|
button.style.minimal_width = 38
|
||||||
@ -22,12 +22,17 @@ Hi stranger, I'm a fish..
|
|||||||
And this is what you ought to know:
|
And this is what you ought to know:
|
||||||
|
|
||||||
- Please be nice and don't grief.
|
- Please be nice and don't grief.
|
||||||
|
|
||||||
- Fix personal confrontations diplomatically.
|
- Fix personal confrontations diplomatically.
|
||||||
|
|
||||||
- No political, racist, or misogynistic content.
|
- No political, racist, or misogynistic content.
|
||||||
|
|
||||||
- If you suspect you desync while connecting,
|
- If you suspect you desync while connecting,
|
||||||
close and relaunch Factorio ASAP. Very bad for us.
|
close and relaunch Factorio ASAP. Very bad for us.
|
||||||
- Join our community on discord.me/redmew
|
|
||||||
|
- Join our community on https://discord.gg/gKyDpQE
|
||||||
for questions and feedback. Also on /r/redmew (reddit)
|
for questions and feedback. Also on /r/redmew (reddit)
|
||||||
|
|
||||||
- You can contribute to server costs and upgrades
|
- You can contribute to server costs and upgrades
|
||||||
with bitcoin: 13qh5uJh3UDUiWKyQaybkpxC1gfLVDB1ww
|
with bitcoin: 13qh5uJh3UDUiWKyQaybkpxC1gfLVDB1ww
|
||||||
]===]
|
]===]
|
||||||
|
2044
map_layout.lua
2044
map_layout.lua
File diff suppressed because it is too large
Load Diff
71
perlin_noise.lua
Normal file
71
perlin_noise.lua
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
-- original code by Ken Perlin: http://mrl.nyu.edu/~perlin/noise/
|
||||||
|
|
||||||
|
perlin = {}
|
||||||
|
perlin.p = {}
|
||||||
|
perlin.permutation = { 151,160,137,91,90,15,
|
||||||
|
131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,
|
||||||
|
190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,
|
||||||
|
88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166,
|
||||||
|
77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,
|
||||||
|
102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196,
|
||||||
|
135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123,
|
||||||
|
5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,
|
||||||
|
223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9,
|
||||||
|
129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228,
|
||||||
|
251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107,
|
||||||
|
49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254,
|
||||||
|
138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180
|
||||||
|
}
|
||||||
|
perlin.size = 256
|
||||||
|
perlin.gx = {}
|
||||||
|
perlin.gy = {}
|
||||||
|
perlin.randMax = 256
|
||||||
|
|
||||||
|
function perlin:load( )
|
||||||
|
for i=1,self.size do
|
||||||
|
self.p[i] = self.permutation[i]
|
||||||
|
self.p[256+i] = self.p[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function perlin:noise( x, y, z )
|
||||||
|
local X = math.floor(x) % 256
|
||||||
|
local Y = math.floor(y) % 256
|
||||||
|
local Z = math.floor(z) % 256
|
||||||
|
x = x - math.floor(x)
|
||||||
|
y = y - math.floor(y)
|
||||||
|
z = z - math.floor(z)
|
||||||
|
local u = fade(x)
|
||||||
|
local v = fade(y)
|
||||||
|
local w = fade(z)
|
||||||
|
local A = self.p[X+1]+Y
|
||||||
|
local AA = self.p[A+1]+Z
|
||||||
|
local AB = self.p[A+2]+Z
|
||||||
|
local B = self.p[X+2]+Y
|
||||||
|
local BA = self.p[B+1]+Z
|
||||||
|
local BB = self.p[B+2]+Z
|
||||||
|
|
||||||
|
return lerp(w, lerp(v, lerp(u, grad(self.p[AA+1], x , y , z ),
|
||||||
|
grad(self.p[BA+1], x-1, y , z )),
|
||||||
|
lerp(u, grad(self.p[AB+1], x , y-1, z ),
|
||||||
|
grad(self.p[BB+1], x-1, y-1, z ))),
|
||||||
|
lerp(v, lerp(u, grad(self.p[AB+2], x , y , z-1),
|
||||||
|
grad(self.p[BA+2], x-1, y , z-1)),
|
||||||
|
lerp(u, grad(self.p[AB+2], x , y-1, z-1),
|
||||||
|
grad(self.p[BB+2], x-1, y-1, z-1))))
|
||||||
|
end
|
||||||
|
|
||||||
|
function fade( t )
|
||||||
|
return t * t * t * (t * (t * 6 - 15) + 10)
|
||||||
|
end
|
||||||
|
|
||||||
|
function lerp( t, a, b )
|
||||||
|
return a + t * (b - a)
|
||||||
|
end
|
||||||
|
|
||||||
|
function grad( hash, x, y, z )
|
||||||
|
local h = hash % 16
|
||||||
|
local u = h < 8 and x or y
|
||||||
|
local v = h < 4 and y or ((h == 12 or h == 14) and x or z)
|
||||||
|
return ((h % 2) == 0 and u or -u) + ((h % 3) == 0 and v or -v)
|
||||||
|
end
|
88
pet.lua
Normal file
88
pet.lua
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
--[[local function on_player_joined_game(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
|
||||||
|
if player.gui.top.pet_button == nil then
|
||||||
|
local button = player.gui.top.add({ type = "sprite-button", name = "pet_button", sprite = "entity/small-biter" })
|
||||||
|
button.style.minimal_height = 38
|
||||||
|
button.style.minimal_width = 38
|
||||||
|
button.style.top_padding = 0
|
||||||
|
button.style.left_padding = 0
|
||||||
|
button.style.right_padding = 0
|
||||||
|
button.style.bottom_padding = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function show_pet_panel(player)
|
||||||
|
local frame = player.gui.left.add { type = "frame", name = "pet-panel", direction = "vertical" }
|
||||||
|
|
||||||
|
pet_table = frame.add { type = "table", name = "pet_panel_table", colspan = 2 }
|
||||||
|
pet_table.add({ type = "sprite-button", name = "pet_button", sprite = "entity/small-biter" })
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
function pet(player, entity_name)
|
||||||
|
if not player then
|
||||||
|
player = game.connected_players[1]
|
||||||
|
else
|
||||||
|
player = game.players[player]
|
||||||
|
end
|
||||||
|
if not entity_name then
|
||||||
|
entity_name = "small-biter"
|
||||||
|
end
|
||||||
|
if not global.player_pets then global.player_pets = {} end
|
||||||
|
|
||||||
|
local surface = game.surfaces[1]
|
||||||
|
|
||||||
|
local pos = player.position
|
||||||
|
pos.y = pos.y - 2
|
||||||
|
|
||||||
|
local x = 1
|
||||||
|
x = x + #global.player_pets
|
||||||
|
|
||||||
|
global.player_pets[x] = {}
|
||||||
|
global.player_pets[x].entity = surface.create_entity {name=entity_name, position=pos, force="player"}
|
||||||
|
global.player_pets[x].owner = player.index
|
||||||
|
global.player_pets[x].id = x
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_tick()
|
||||||
|
if game.tick % 120 == 0 then
|
||||||
|
for _, pets in pairs(global.player_pets) do
|
||||||
|
local player = game.players[pets.owner]
|
||||||
|
if pcall(function () local x = pets.entity.name end) then
|
||||||
|
pets.entity.set_command({type=defines.command.go_to_location, destination=player.position,distraction=defines.distraction.none})
|
||||||
|
else
|
||||||
|
global.player_pets[pets.id] = nil
|
||||||
|
local str = player.name .. "´s pet died ;_;"
|
||||||
|
game.print(str)
|
||||||
|
-- game.print(pets.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
local function try()
|
||||||
|
local x = global.player_pets[1].entity.name
|
||||||
|
end
|
||||||
|
|
||||||
|
function test()
|
||||||
|
for _, pets in pairs(global.player_pets) do
|
||||||
|
local str = " ID="
|
||||||
|
str = str .. pets.id
|
||||||
|
if pcall(function () local x = global.player_pets[pets.id].entity.name end) then
|
||||||
|
str = str .. pets.entity.name
|
||||||
|
else
|
||||||
|
str = str .. "entity.. HAS.... NOOO... NAAAAAAMEEE"
|
||||||
|
end
|
||||||
|
|
||||||
|
str = str .. " ownerID="
|
||||||
|
str = str .. pets.owner
|
||||||
|
|
||||||
|
game.print(str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
]]--
|
||||||
|
|
||||||
|
Event.register(defines.events.on_gui_click, on_gui_click)
|
||||||
|
Event.register(defines.events.on_player_joined_game, on_player_joined_game)
|
||||||
|
Event.register(defines.events.on_tick, on_tick)
|
345
player_list.lua
Normal file
345
player_list.lua
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
--[[
|
||||||
|
Hello there!
|
||||||
|
|
||||||
|
This will add a player list with "ranks" to your server.
|
||||||
|
Oh.. and you can also "poke" a player.
|
||||||
|
pokemessages = 80% by redlabel
|
||||||
|
|
||||||
|
To install, add: require "player_list"
|
||||||
|
to your scenario control.lua.
|
||||||
|
|
||||||
|
---MewMew---
|
||||||
|
|
||||||
|
|
||||||
|
things to do (maybe)
|
||||||
|
make it sorted by time played
|
||||||
|
--]]
|
||||||
|
|
||||||
|
local symbol_asc = "▲"
|
||||||
|
local symbol_desc = "▼"
|
||||||
|
|
||||||
|
local pokemessages = {"a stick", "a leaf", "a moldy carrot", "a crispy slice of bacon", "a french fry", "a realistic toygun", "a broomstick", "a thirteen inch iron stick", "a mechanical keyboard", "a fly fishing cane", "a selfie stick", "an oversized fidget spinner", "a thumb extender", "a dirty straw", "a green bean", "a banana", "an umbrella", "grandpa's walking stick", "live firework", "a toilet brush", "a fake hand", "an undercooked hotdog", "a slice of yesterday's microwaved pizza", "bubblegum", "a biter leg", "grandma's toothbrush", "charred octopus", "a dollhouse bathtub", "a length of copper wire", "a decommissioned nuke", "a smelly trout", "an unopened can of deodorant", "a stone brick", "a half full barrel of lube", "a half empty barrel of lube", "an unexploded cannon shell", "a blasting programmable speaker", "a not so straight rail", "a mismatched pipe to ground", "a surplus box of landmines", "decommissioned yellow rounds", "an oily pumpjack shaft", "a melted plastic bar in the shape of the virgin mary", "a bottle of watermelon vitamin water", "a slice of watermelon", "a stegosaurus tibia", "a basking musician's clarinet", "a twig", "an undisclosed pokey item", "a childhood trophy everyone else got","a dead starfish","a titanium toothpick", "a nail file","a stamp collection","a bucket of lego","a rolled up carpet","a rolled up WELCOME doormat","Bobby's favorite bone","an empty bottle of cheap vodka","a tattooing needle","a peeled cucumber","a stack of cotton candy","a signed baseball bat","that 5 dollar bill grandma sent for christmas","a stack of overdue phone bills","the 'relax' section of the white pages","a bag of gym clothes which never made it to the washing machine","a handful of peanut butter","a pheasant's feather","a rusty pickaxe","a diamond sword","the bill of rights of a banana republic","one of those giant airport Toblerone's", "a long handed inserter", "a wiimote","an easter chocolate rabbit","a ball of yarn the cat threw up","a slightly expired but perfectly edible cheese sandwich", "conclusive proof of lizard people existence","a pen drive full of high res wallpapers","a pet hamster","an oversized goldfish","a one foot extension cord","a CD from Walmart's 1 dollar bucket","a magic wand","a list of disappointed people who believed in you","murder exhibit no. 3","a paperback copy of 'Great Expectations'", "a baby biter", "a little biter fang", "the latest diet fad","a belt that no longer fits you","an abandoned pet rock","a lava lamp", "some spirit herbs","a box of fish sticks found at the back of the freezer","a bowl of tofu rice", "a bowl of ramen noodles", "a live lobster!", "a miniature golf cart","dunce cap","a fully furnished x-mas tree", "an orphaned power pole", "an horphaned power pole","an box of overpriced girl scout cookies","the cheapest item from the yard sale","a Sharpie","a glowstick","a thick unibrow hair","a very detailed map of Kazakhstan","the official Factorio installation DVD","a Liberal Arts degree","a pitcher of Kool-Aid","a 1/4 pound vegan burrito","a bottle of expensive wine","a hamster sized gravestone","a counterfeit Cuban cigar","an old Nokia phone","a huge inferiority complex","a dead real state agent","a deck of tarot cards","unreleased Wikileaks documents","a mean-looking garden dwarf","the actual mythological OBESE cat","a telescope used to spy on the MILF next door","a fancy candelabra","the comic version of the Kama Sutra","an inflatable 'Netflix & chill' doll","whatever it is redlabel gets high on","Obama's birth certificate","a deck of Cards Against Humanity","a copy of META MEME HUMOR for Dummies","an abandoned, not-so-young-anymore puppy","one of those useless items advertised on TV","a genetic blueprint of a Japanese teen idol" }
|
||||||
|
|
||||||
|
local function on_player_joined_game(event)
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
if not global.poke_spam_protection then global.poke_spam_protection = {} end
|
||||||
|
global.poke_spam_protection[event.player_index] = game.tick
|
||||||
|
if not global.player_list_pokes_counter then global.player_list_pokes_counter = {} end
|
||||||
|
|
||||||
|
if player.gui.top.player_list_button == nil then
|
||||||
|
local button = player.gui.top.add({ type = "sprite-button", name = "player_list_button", sprite = "item/heavy-armor" })
|
||||||
|
button.style.minimal_height = 38
|
||||||
|
button.style.minimal_width = 38
|
||||||
|
button.style.top_padding = 2
|
||||||
|
button.style.left_padding = 4
|
||||||
|
button.style.right_padding = 4
|
||||||
|
button.style.bottom_padding = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_formatted_playtime(x)
|
||||||
|
local y = x / 216000
|
||||||
|
y = tostring(y)
|
||||||
|
local h = ""
|
||||||
|
for i=1,10,1 do
|
||||||
|
local z = string.sub(y, i, i)
|
||||||
|
|
||||||
|
if z == "." then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
h = h .. z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local m = x % 216000
|
||||||
|
m = m / 3600
|
||||||
|
m = math.floor(m)
|
||||||
|
m = tostring(m)
|
||||||
|
|
||||||
|
if h == "0" then
|
||||||
|
local str = m .. " minutes"
|
||||||
|
return str
|
||||||
|
else
|
||||||
|
local str = h .. " hours "
|
||||||
|
str = str .. m
|
||||||
|
str = str .. " minutes"
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_rank(player)
|
||||||
|
local m = player.online_time / 3600
|
||||||
|
|
||||||
|
local ranks = {
|
||||||
|
"item/iron-axe","item/burner-mining-drill","item/burner-inserter","item/stone-furnace","item/light-armor","item/steam-engine",
|
||||||
|
"item/inserter", "item/transport-belt", "item/underground-belt", "item/splitter","item/assembling-machine-1","item/long-handed-inserter","item/electronic-circuit","item/electric-mining-drill",
|
||||||
|
"item/heavy-armor","item/steel-furnace","item/steel-axe","item/gun-turret","item/fast-transport-belt", "item/fast-underground-belt", "item/fast-splitter","item/assembling-machine-2","item/fast-inserter","item/radar","item/filter-inserter",
|
||||||
|
"item/defender-capsule","item/pumpjack","item/chemical-plant","item/solar-panel","item/advanced-circuit","item/modular-armor","item/accumulator", "item/construction-robot",
|
||||||
|
"item/distractor-capsule","item/stack-inserter","item/electric-furnace","item/express-transport-belt","item/express-underground-belt", "item/express-splitter","item/assembling-machine-3","item/processing-unit","item/power-armor","item/logistic-robot","item/laser-turret",
|
||||||
|
"item/stack-filter-inserter","item/destroyer-capsule","item/power-armor-mk2","item/flamethrower-turret","item/beacon",
|
||||||
|
"item/steam-turbine","item/centrifuge","item/nuclear-reactor"
|
||||||
|
}
|
||||||
|
|
||||||
|
--52 ranks
|
||||||
|
|
||||||
|
local time_needed = 15 -- in minutes between rank upgrades
|
||||||
|
m = m / time_needed
|
||||||
|
m = math.floor(m)
|
||||||
|
m = m + 1
|
||||||
|
|
||||||
|
if m > #ranks then m = #ranks end
|
||||||
|
|
||||||
|
return ranks[m]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_sorted_list(sort_by)
|
||||||
|
local player_list = {}
|
||||||
|
for i, player in pairs(game.connected_players) do
|
||||||
|
player_list[i] = {}
|
||||||
|
player_list[i].rank = get_rank(player)
|
||||||
|
player_list[i].name = player.name
|
||||||
|
player_list[i].played_time = get_formatted_playtime(player.online_time)
|
||||||
|
player_list[i].played_ticks = player.online_time
|
||||||
|
if not global.player_list_pokes_counter[player.index] then global.player_list_pokes_counter[player.index] = 0 end
|
||||||
|
player_list[i].pokes = global.player_list_pokes_counter[player.index]
|
||||||
|
player_list[i].player_index = player.index
|
||||||
|
end
|
||||||
|
--[[
|
||||||
|
for i = 1, 4, 1 do
|
||||||
|
player_list[i] = {}
|
||||||
|
player_list[i].pokes = math.random(1,100)
|
||||||
|
player_list[i].name = "mewmew " .. i
|
||||||
|
player_list[i].played_ticks = math.random(1,115222000)
|
||||||
|
player_list[i].played_time = get_formatted_playtime(player_list[i].played_ticks)
|
||||||
|
player_list[i].rank = "item/heavy-armor"
|
||||||
|
player_list[i].player_index = 1
|
||||||
|
end--]]
|
||||||
|
|
||||||
|
for i = #player_list, 1, -1 do
|
||||||
|
for i2 = #player_list, 1, -1 do
|
||||||
|
if sort_by == "pokes_asc" then
|
||||||
|
if player_list[i].pokes > player_list[i2].pokes then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sort_by == "pokes_desc" then
|
||||||
|
if player_list[i].pokes < player_list[i2].pokes then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sort_by == "time_played_asc" then
|
||||||
|
if player_list[i].played_ticks > player_list[i2].played_ticks then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sort_by == "time_played_desc" then
|
||||||
|
if player_list[i].played_ticks < player_list[i2].played_ticks then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sort_by == "name_asc" then
|
||||||
|
if player_list[i].name > player_list[i2].name then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if sort_by == "name_desc" then
|
||||||
|
if player_list[i].name < player_list[i2].name then
|
||||||
|
local a = player_list[i]
|
||||||
|
local b = player_list[i2]
|
||||||
|
player_list[i] = b
|
||||||
|
player_list[i2] = a
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return player_list
|
||||||
|
end
|
||||||
|
|
||||||
|
local function player_list_show(player, sort_by)
|
||||||
|
|
||||||
|
local frame = player.gui.left["player-list-panel"]
|
||||||
|
if frame then frame.destroy() end
|
||||||
|
|
||||||
|
player.gui.left.direction = "horizontal"
|
||||||
|
local frame = player.gui.left.add { type = "frame", name = "player-list-panel", direction = "vertical" }
|
||||||
|
frame.style.minimal_width = 408
|
||||||
|
frame.style.top_padding = 8
|
||||||
|
frame.style.left_padding = 8
|
||||||
|
frame.style.right_padding = 8
|
||||||
|
frame.style.bottom_padding = 8
|
||||||
|
|
||||||
|
|
||||||
|
local player_list_panel_header_table = frame.add { type = "table", name = "player_list_panel_header_table", colspan = 4 }
|
||||||
|
|
||||||
|
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_1", caption = " " .. #game.connected_players }
|
||||||
|
label.style.font = "default-game"
|
||||||
|
label.style.font_color = { r=0.00, g=0.00, b=0.00}
|
||||||
|
label.style.minimal_width = 35
|
||||||
|
|
||||||
|
local str = ""
|
||||||
|
if sort_by == "name_asc" then str = symbol_asc .. " " end
|
||||||
|
if sort_by == "name_desc" then str = symbol_desc .. " " end
|
||||||
|
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_2", caption = str .. "Players online" }
|
||||||
|
label.style.font = "default-listbox"
|
||||||
|
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||||
|
label.style.minimal_width = 160
|
||||||
|
label.style.maximal_width = 160
|
||||||
|
|
||||||
|
str = ""
|
||||||
|
if sort_by == "time_played_asc" then str = symbol_asc .. " " end
|
||||||
|
if sort_by == "time_played_desc" then str = symbol_desc .. " " end
|
||||||
|
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_3", caption = str .. "Time played" }
|
||||||
|
label.style.font = "default-listbox"
|
||||||
|
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||||
|
label.style.minimal_width = 130
|
||||||
|
label.style.maximal_width = 130
|
||||||
|
|
||||||
|
str = ""
|
||||||
|
if sort_by == "pokes_asc" then str = symbol_asc .. " " end
|
||||||
|
if sort_by == "pokes_desc" then str = symbol_desc .. " " end
|
||||||
|
local label = player_list_panel_header_table.add { type = "label", name = "player_list_panel_header_4", caption = str .. "Poke" }
|
||||||
|
label.style.font = "default-listbox"
|
||||||
|
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||||
|
label.style.minimal_width = 35
|
||||||
|
|
||||||
|
local player_list_panel_table = frame.add { type = "scroll-pane", name = "scroll_pane", direction = "vertical", horizontal_scroll_policy = "never", vertical_scroll_policy = "auto"}
|
||||||
|
player_list_panel_table.style.maximal_height = 530
|
||||||
|
|
||||||
|
|
||||||
|
player_list_panel_table = player_list_panel_table.add { type = "table", name = "player_list_panel_table", colspan = 4 }
|
||||||
|
|
||||||
|
local player_list = get_sorted_list(sort_by)
|
||||||
|
|
||||||
|
for i = 1, #player_list, 1 do
|
||||||
|
|
||||||
|
local sprite = player_list_panel_table.add { type = "sprite", name = "player_rank_sprite_" .. i, sprite = player_list[i].rank }
|
||||||
|
sprite.style.minimal_width = 35
|
||||||
|
|
||||||
|
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_names_" .. i, caption = player_list[i].name }
|
||||||
|
label.style.font = "default"
|
||||||
|
label.style.font_color = {
|
||||||
|
r = .4 + game.players[player_list[i].player_index].color.r * 0.6,
|
||||||
|
g = .4 + game.players[player_list[i].player_index].color.g * 0.6,
|
||||||
|
b = .4 + game.players[player_list[i].player_index].color.b * 0.6,
|
||||||
|
}
|
||||||
|
label.style.minimal_width = 160
|
||||||
|
label.style.maximal_width = 160
|
||||||
|
|
||||||
|
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_time_played_" .. i, caption = player_list[i].played_time }
|
||||||
|
label.style.minimal_width = 130
|
||||||
|
label.style.maximal_width = 130
|
||||||
|
|
||||||
|
local flow = player_list_panel_table.add { type = "flow", name = "button_flow_" .. i, direction = "horizontal" }
|
||||||
|
flow.add { type = "label", name = "button_spacer_" .. i, caption = "" }
|
||||||
|
local button = flow.add { type = "button", name = "poke_player_" .. player_list[i].name, caption = player_list[i].pokes }
|
||||||
|
button.style.font = "default"
|
||||||
|
label.style.font_color = { r=0.83, g=0.83, b=0.83}
|
||||||
|
button.style.minimal_height = 30
|
||||||
|
button.style.minimal_width = 30
|
||||||
|
button.style.maximal_height = 30
|
||||||
|
button.style.maximal_width = 30
|
||||||
|
button.style.top_padding = 0
|
||||||
|
button.style.left_padding = 0
|
||||||
|
button.style.right_padding = 0
|
||||||
|
button.style.bottom_padding = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_gui_click(event)
|
||||||
|
if not (event and event.element and event.element.valid) then return end
|
||||||
|
local player = game.players[event.element.player_index]
|
||||||
|
local name = event.element.name
|
||||||
|
|
||||||
|
if (name == "player_list_button") then
|
||||||
|
if player.gui.left["player-list-panel"] then
|
||||||
|
player.gui.left["player-list-panel"].destroy()
|
||||||
|
else
|
||||||
|
player_list_show(player,"time_played_desc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (name == "player_list_panel_header_2") then
|
||||||
|
if string.find(event.element.caption, symbol_desc) then
|
||||||
|
player_list_show(player,"name_asc")
|
||||||
|
else
|
||||||
|
player_list_show(player,"name_desc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (name == "player_list_panel_header_3") then
|
||||||
|
if string.find(event.element.caption, symbol_desc) then
|
||||||
|
player_list_show(player,"time_played_asc")
|
||||||
|
else
|
||||||
|
player_list_show(player,"time_played_desc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (name == "player_list_panel_header_4") then
|
||||||
|
if string.find(event.element.caption, symbol_desc) then
|
||||||
|
player_list_show(player,"pokes_asc")
|
||||||
|
else
|
||||||
|
player_list_show(player,"pokes_desc")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--Poke other players
|
||||||
|
if event.element.type == "button" then
|
||||||
|
local x = string.find(name, "poke_player_")
|
||||||
|
if x ~= nil then
|
||||||
|
local y = string.len(event.element.name)
|
||||||
|
local poked_player = string.sub(event.element.name, 13, y)
|
||||||
|
if player.name ~= poked_player then
|
||||||
|
local x = global.poke_spam_protection[event.element.player_index] + 420
|
||||||
|
if x < game.tick then
|
||||||
|
local str = ">> "
|
||||||
|
str = str .. player.name
|
||||||
|
str = str .. " has poked "
|
||||||
|
str = str .. poked_player
|
||||||
|
str = str .. " with "
|
||||||
|
local z = math.random(1,#pokemessages)
|
||||||
|
str = str .. pokemessages[z]
|
||||||
|
str = str .. " <<"
|
||||||
|
game.print(str)
|
||||||
|
global.poke_spam_protection[event.element.player_index] = game.tick
|
||||||
|
local p = game.players[poked_player]
|
||||||
|
global.player_list_pokes_counter[p.index] = global.player_list_pokes_counter[p.index] + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_tick()
|
||||||
|
if game.tick % 1200 == 0 then
|
||||||
|
for _,player in pairs(game.connected_players) do
|
||||||
|
if player.gui.left["player-list-panel"] then
|
||||||
|
local sort_method
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_desc) then sort_method = "name_desc" end
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_2.caption, symbol_asc) then sort_method = "name_asc" end
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_desc) then sort_method = "time_played_desc" end
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_3.caption, symbol_asc) then sort_method = "time_played_asc" end
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_desc) then sort_method = "pokes_desc" end
|
||||||
|
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_4.caption, symbol_asc) then sort_method = "pokes_asc" end
|
||||||
|
player.gui.left["player-list-panel"].destroy()
|
||||||
|
player_list_show(player,sort_method)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Event.register(defines.events.on_tick, on_tick)
|
||||||
|
Event.register(defines.events.on_player_joined_game, on_player_joined_game)
|
||||||
|
Event.register(defines.events.on_gui_click, on_gui_click)
|
13
poll.lua
13
poll.lua
@ -296,18 +296,16 @@ local function on_gui_click(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function poll_timeout()
|
local function on_tick()
|
||||||
if game.tick % 60 == 0 then
|
if game.tick % 60 == 0 then
|
||||||
local x = 1
|
for _, player in pairs(game.connected_players) do
|
||||||
while game.players[x] ~= nil do
|
|
||||||
local player = game.players[x]
|
|
||||||
if global.poll_panel_creation_time[player.index] then
|
if global.poll_panel_creation_time[player.index] then
|
||||||
local frame = player.gui.left["poll-panel"]
|
local frame = player.gui.left["poll-panel"]
|
||||||
if frame then
|
if frame then
|
||||||
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
|
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
|
||||||
local y = global.poll_duration_in_seconds - y
|
local y = global.poll_duration_in_seconds - y
|
||||||
y = round(y, 0)
|
y = round(y, 0)
|
||||||
if y == 0 then
|
if y <= 0 then
|
||||||
frame.destroy()
|
frame.destroy()
|
||||||
global.poll_panel_creation_time[player.index] = nil
|
global.poll_panel_creation_time[player.index] = nil
|
||||||
else
|
else
|
||||||
@ -317,12 +315,11 @@ local function poll_timeout()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
x = x + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Event.register(defines.events.on_tick, poll_timeout)
|
Event.register(defines.events.on_tick, on_tick)
|
||||||
Event.register(defines.events.on_gui_click, on_gui_click)
|
Event.register(defines.events.on_gui_click, on_gui_click)
|
||||||
Event.register(defines.events.on_player_joined_game, create_poll_gui)
|
Event.register(defines.events.on_player_joined_game, create_poll_gui)
|
||||||
Event.register(defines.events.on_player_joined_game, poll_sync_for_new_joining_player)
|
Event.register(defines.events.on_player_joined_game, poll_sync_for_new_joining_player)
|
136
rail_grid.lua
Normal file
136
rail_grid.lua
Normal file
File diff suppressed because one or more lines are too long
44
shapes.lua
Normal file
44
shapes.lua
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
--Author Valansch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Compass = {
|
||||||
|
east={x=1,y=0,next="north"},
|
||||||
|
north={x=0,y=-1,next="west"},
|
||||||
|
west={x=-1,y=0,next="south"},
|
||||||
|
south={x=0,y=1,next="east"},
|
||||||
|
direction="west"}
|
||||||
|
function Compass.turn()
|
||||||
|
Compass.direction=Compass[Compass.direction].next
|
||||||
|
end
|
||||||
|
function Compass.getdirection()
|
||||||
|
return Compass[Compass.direction]
|
||||||
|
end
|
||||||
|
|
||||||
|
--spiral
|
||||||
|
Spiral = {Pixels={}, width = 4, size = 10}
|
||||||
|
function Spiral.onshape(p)
|
||||||
|
x = math.floor(p[1]/32/Spiral.width)
|
||||||
|
y = math.floor(p[2]/32/Spiral.width)
|
||||||
|
return Spiral.Pixels[x .. "," .. y] ~= nil
|
||||||
|
end
|
||||||
|
function Spiral.add(p)
|
||||||
|
Spiral.Pixels[p[1].. "," .. p[2]] = true
|
||||||
|
end
|
||||||
|
function Spiral.takesteps(p, n)
|
||||||
|
direction = Compass.getdirection()
|
||||||
|
for i = 1, n do
|
||||||
|
p[1] = p[1] + direction["x"]
|
||||||
|
p[2] = p[2] + direction["y"]
|
||||||
|
Spiral.add(p)
|
||||||
|
end
|
||||||
|
return p
|
||||||
|
end
|
||||||
|
function Spiral.build()
|
||||||
|
p = {-1,-1}
|
||||||
|
Spiral.add(p)
|
||||||
|
for i = 1, 100 do
|
||||||
|
p = Spiral.takesteps(p, i)
|
||||||
|
Compass.turn()
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user