1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-30 04:30:58 +02:00

Merge branch 'master' into develop

# Conflicts:
#	fish_market.lua
This commit is contained in:
Valansch 2017-07-21 23:59:03 +02:00
commit d6082e5c8e
10 changed files with 276 additions and 325 deletions

View File

@ -20,6 +20,7 @@ do
end
end
local custom_roles = {}
local expand_band_gui
@ -140,14 +141,26 @@ expand_band_gui = function(player, dev_icons, dev_addfakes, right_click)
end
local player_role = player.tag:sub(2,-2)
-- Will be filled: { roleN = {{name,color},...} , ...}
local players_by_role = {}
for role in pairs(roles) do
players_by_role[role] = {}
end
for _,role in pairs(custom_roles) do
roles[role] = nil
end
for _,cplayer in pairs(game.players) do
local role = cplayer.tag:sub(2,-2)
if role ~= "" and roles[role] == nil then
players_by_role[role] = {}
table.insert(custom_roles, role)
roles[role] = {"item/iron-stick",tooltip = {"I'm sure he does something"},verbs = {"enlarged"}}
end
end
if right_click then
for _, oplayer in pairs(game.players) do
local prole = oplayer.tag:sub(2,-2)
@ -168,7 +181,6 @@ expand_band_gui = function(player, dev_icons, dev_addfakes, right_click)
end
end
if dev_addfakes then
test_fake_players(players_by_role)
end
@ -311,43 +323,6 @@ local function update_player_role(player, role)
global.update_player_name.tag = ""
end
-- update other player gui (counter & label)
--[[
for _,cplayer in pairs( game.connected_players ) do
if cplayer.gui.left.band_panel then
local troles = cplayer.gui.left.band_panel.scroll.table_roles
if local_role then
local player_label = troles.children[roles[local_role].index*2]["list_players_" .. cplayer.name]
if player_label then
player_label.destroy()
end
end
if global.update_player_role_name then
subgui_add_player_label( troles.children[roles[global.update_player_role_name].index*2], cplayer.name, cplayer.color)
subgui_update_role_counter( troles.children[roles[global.update_player_role_name].index*2 - 1].role_cap_line, 1)
end
if local_role then
subgui_update_role_counter( troles.children[roles[local_role].index*2 - 1].role_cap_line, -1)
end
end
end
-- update local player gui (role label color)
local troles_local = player.gui.left.band_panel.scroll.table_roles
if local_role then
troles_local.children[roles[local_role].index*2 - 1].children[2].children[1].style.font_color = {r=1,g=1,b=1}
end
if global.update_player_role_name then
troles_local.children[roles[global.update_player_role_name].index*2 - 1].children[2].children[1].style.font_color = {r=.7,g=1,b=.7}
end
--]]
print_role_change(global.update_player_name.name, global.update_player_role_name)
expand_band_gui(player)
expand_band_gui(player)
@ -380,7 +355,6 @@ local function on_gui_click(event)
player.gui.top.band_toggle_btn.caption = "Tag"
player.gui.top.band_toggle_btn.tooltip = ""
player.gui.top.band_toggle_btn.sprite = ""
-- expand_band_gui(player)
return
end

View File

@ -12,6 +12,10 @@ Event.register(-1, function()
}
global.scenario.variables.regulars = {
helpower2 = "",
rorror = "",
Medival3 = "",
dpoba = "",
settdigger = ""
}
global.scenario.variables.player_positions = {}
global.scenario.variables.player_walk_distances = {}

View File

@ -16,6 +16,7 @@ require "map_layout"
require "custom_commands"
require "nuke_control"
require "walk_distance"
require "on_tick"

View File

@ -242,6 +242,26 @@ local function afk()
end
end
local function tag(cmd)
if not game.player.admin then
cant_run(cmd.name)
return
end
local params = {}
for param in string.gmatch(cmd.parameter, "%w+") do table.insert(params, param) end
if #params ~= 2 then
game.player.print("Two arguments expect failed. Usage: <player> <tag> Sets a players tag.")
elseif game.players[params[1]] == nil then
game.player.print("Player does not exist.")
else
game.players[params[1]].tag = "[" .. params[2] .. "]"
game.print(params[1] .. " joined [" .. params[2] .. "].")
end
end
commands.add_command("kill", "Will kill you.", kill)
commands.add_command("detrain", "<player> - Kicks the player off a train. (Admins and moderators)", detrain)
commands.add_command("tpplayer", "<player> - Teleports you to the player. (Admins and moderators)", teleport_player)
@ -256,3 +276,4 @@ commands.add_command("regular", '<promote, demote>, <player> Change regular stat
commands.add_command("mods", 'Prints a list of game mods.', print_mods)
commands.add_command("mod", '<promote, demote>, <player> Changes moderator status of a player. (Admins only)', mod)
commands.add_command("afktime", 'Shows how long players have been afk.', afk)
commands.add_command("tag", '<player> <tag> Sets a players tag. (Admins only)', tag)

View File

@ -285,77 +285,50 @@ end
if not global.pet_command_rotation then global.pet_command_rotation = 1 end
local function on_tick(event)
function fish_market_on_180_ticks()
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 % 180 == 0 then
if game.tick % 200 == 0 then
if global.player_pets == nil then
return
if game.tick % 900 == 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 global.player_pets 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
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_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)

16
on_tick.lua Normal file
View File

@ -0,0 +1,16 @@
local function on_tick()
if game.tick % 60 == 0 then
poll_on_second()
walk_distance_on_second()
if game.tick % 120 == 0 then
pet_on_120_ticks()
if game.tick % 1200 == 0 then
player_list_on_12_seconds()
end
elseif game.tick % 180 == 0 then
fish_market_on_180_ticks()
end
end
end
Event.register(defines.events.on_tick, on_tick)

40
pet.lua
View File

@ -45,44 +45,18 @@ function pet(player, entity_name)
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()
function pet_on_120_ticks()
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
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
str = str .. "entity.. HAS.... NOOO... NAAAAAAMEEE"
global.player_pets[pets.id] = nil
local str = player.name .. "´s pet died ;_;"
game.print(str)
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)

View File

@ -351,26 +351,22 @@ local function on_gui_click(event)
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 = "distance_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 = "distance_asc" end
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.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_5.caption, symbol_asc) then sort_method = "pokes_asc" end
player.gui.left["player-list-panel"].destroy()
player_list_show(player,sort_method)
end
function player_list_on_12_seconds()
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 = "distance_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 = "distance_asc" end
if string.find(player.gui.left["player-list-panel"].player_list_panel_header_table.player_list_panel_header_5.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_5.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
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)

View File

@ -296,30 +296,27 @@ local function on_gui_click(event)
end
end
local function on_tick()
if game.tick % 60 == 0 then
for _, player in pairs(game.connected_players) do
if global.poll_panel_creation_time[player.index] then
local frame = player.gui.left["poll-panel"]
if frame then
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
local y = global.poll_duration_in_seconds - y
y = round(y, 0)
if y <= 0 then
frame.destroy()
global.poll_panel_creation_time[player.index] = nil
else
y = "Hide (" .. y
y = y .. ")"
frame.poll_panel_button_table.poll_hide_button.caption = y
end
function poll_on_second()
for _, player in pairs(game.connected_players) do
if global.poll_panel_creation_time[player.index] then
local frame = player.gui.left["poll-panel"]
if frame then
local y = (game.tick - global.poll_panel_creation_time[player.index]) / 60
local y = global.poll_duration_in_seconds - y
y = round(y, 0)
if y <= 0 then
frame.destroy()
global.poll_panel_creation_time[player.index] = nil
else
y = "Hide (" .. y
y = y .. ")"
frame.poll_panel_button_table.poll_hide_button.caption = y
end
end
end
end
end
Event.register(defines.events.on_tick, on_tick)
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, poll_sync_for_new_joining_player)

View File

@ -1,10 +1,4 @@
local function on_tick()
if game.tick % 60 == 0 then
on_second()
end
end
function on_second()
function walk_distance_on_second()
local last_positions = global.scenario.variables.player_positions
local d_x = 0
local d_y = 0
@ -29,8 +23,9 @@ end
local function init_player_position(event)
local player = game.players[event.player_index]
global.scenario.variables.player_positions[player.name] = player.position
global.scenario.variables.player_walk_distances[player.name] = 0
if not global.scenario.variables.player_walk_distances[player.name] then
global.scenario.variables.player_walk_distances[player.name] = 0
end
end
Event.register(defines.events.on_tick, on_tick)
Event.register(defines.events.on_player_joined_game, init_player_position)