mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
updates
This commit is contained in:
parent
4ba537962c
commit
e24dfa5c50
117
band.lua
117
band.lua
@ -3,16 +3,61 @@ local Gui = require 'utils.gui'
|
||||
local Token = require 'utils.global_token'
|
||||
|
||||
local band_roles = require 'resources.band_roles'
|
||||
local band_roles_token = Token.register_global(band_roles)
|
||||
|
||||
local player_tags = {}
|
||||
local player_tags_token = Token.register_global(player_tags)
|
||||
|
||||
Event.on_load(
|
||||
function()
|
||||
band_roles = Token.get_global(band_roles_token)
|
||||
player_tags = Token.get_global(player_tags_token)
|
||||
end
|
||||
)
|
||||
|
||||
local function change_player_tag(player, band_name)
|
||||
local tag_name = '[' .. band_name .. ']'
|
||||
|
||||
local old_tag = player.tag
|
||||
if old_tag == tag_name then
|
||||
return false
|
||||
end
|
||||
|
||||
if old_tag ~= '' then
|
||||
local players = player_tags[old_tag]
|
||||
if players then
|
||||
players[player.index] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if band_name == '' then
|
||||
player.tag = ''
|
||||
return true
|
||||
end
|
||||
|
||||
local players = player_tags[tag_name]
|
||||
if not players then
|
||||
players = {}
|
||||
player_tags[tag_name] = players
|
||||
end
|
||||
|
||||
players[player.index] = true
|
||||
|
||||
player.tag = tag_name
|
||||
|
||||
local verbs = band_roles[band_name].verbs
|
||||
local verb
|
||||
if verbs then
|
||||
verb = verbs[math.random(#verbs)]
|
||||
else
|
||||
verb = 'expanded'
|
||||
end
|
||||
|
||||
game.print(tag_name .. ' squad has `' .. verb .. '` with ' .. player.name)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local main_button_name = Gui.uid_name()
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local band_button_name = Gui.uid_name()
|
||||
@ -31,8 +76,8 @@ local function player_joined(event)
|
||||
player.gui.top.add {name = main_button_name, type = 'button', caption = 'tag'}
|
||||
end
|
||||
|
||||
local function draw_main_frame(event)
|
||||
local left = event.player.gui.left
|
||||
local function draw_main_frame(player)
|
||||
local left = player.gui.left
|
||||
local main_frame =
|
||||
left.add {type = 'frame', name = main_frame_name, caption = 'Choose your tag', direction = 'vertical'}
|
||||
|
||||
@ -42,18 +87,41 @@ local function draw_main_frame(event)
|
||||
|
||||
scroll_pane.style.right_padding = 0
|
||||
|
||||
for band_name, band_data in pairs(band_roles.roles) do
|
||||
for band_name, band_data in pairs(band_roles) do
|
||||
local tag_name = '[' .. band_name .. ']'
|
||||
local players = player_tags[tag_name]
|
||||
|
||||
local size = players and table.size(players) or 0
|
||||
if size == 0 then
|
||||
size = ''
|
||||
else
|
||||
size = ' (' .. size .. ')'
|
||||
end
|
||||
|
||||
local row = scroll_pane.add {type = 'flow', direction = 'horizontal'}
|
||||
|
||||
local button = row.add {type = 'sprite-button', name = band_button_name, sprite = band_data.path}
|
||||
|
||||
Gui.set_data(button, band_name)
|
||||
|
||||
local role_label = row.add {type = 'label', caption = band_name}
|
||||
role_label.style.vertical_align = 'center'
|
||||
local role_label = row.add {type = 'label', caption = band_name .. size}
|
||||
role_label.style.top_padding = 8
|
||||
role_label.style.minimal_width = 120
|
||||
|
||||
local list = row.add {type = 'label'}
|
||||
local list = row.add {type = 'flow', direction = 'horizontal'}
|
||||
|
||||
if players then
|
||||
for k, _ in pairs(players) do
|
||||
local p = game.players[k]
|
||||
if p and p.valid and p.connected then
|
||||
local color = {r = 0.4 + 0.6 * p.color.r, g = 0.4 + 0.6 * p.color.g, b = 0.4 + 0.6 * p.color.b}
|
||||
|
||||
local label = list.add {type = 'label', caption = game.players[k].name}
|
||||
label.style.top_padding = 8
|
||||
label.style.font_color = color
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
list.style.minimal_width = 100
|
||||
end
|
||||
@ -63,6 +131,18 @@ local function draw_main_frame(event)
|
||||
flow.add {type = 'button', name = clear_button_name, caption = 'clear tag'}
|
||||
end
|
||||
|
||||
local function redraw_main_frame()
|
||||
for _, p in ipairs(game.connected_players) do
|
||||
local main_frame = p.gui.left[main_frame_name]
|
||||
if main_frame then
|
||||
Gui.remove_data_recursivly(main_frame)
|
||||
main_frame.destroy()
|
||||
|
||||
draw_main_frame(p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function toggle(event)
|
||||
local left = event.player.gui.left
|
||||
local main_frame = left[main_frame_name]
|
||||
@ -71,7 +151,7 @@ local function toggle(event)
|
||||
Gui.remove_data_recursivly(main_frame)
|
||||
main_frame.destroy()
|
||||
else
|
||||
draw_main_frame(event)
|
||||
draw_main_frame(event.player)
|
||||
end
|
||||
end
|
||||
|
||||
@ -80,9 +160,28 @@ Gui.on_click(main_button_name, toggle)
|
||||
Gui.on_click(
|
||||
band_button_name,
|
||||
function(event)
|
||||
event.player.print(Gui.get_data(event.element))
|
||||
event.player.tag = '['..Gui.get_data(event.element)..']'
|
||||
local tag = Gui.get_data(event.element)
|
||||
|
||||
if change_player_tag(event.player, tag) then
|
||||
redraw_main_frame()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
clear_button_name,
|
||||
function(event)
|
||||
if change_player_tag(event.player, '') then
|
||||
redraw_main_frame()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, player_joined)
|
||||
|
||||
--[[ local function tag_command(cmd)
|
||||
change_player_tag(game.players[cmd.player_index], 'Oil')
|
||||
redraw_main_frame()
|
||||
end
|
||||
|
||||
commands.add_command('tag', '<player> <tag> Sets a players tag. (Admins only)', tag_command) ]]
|
||||
|
@ -247,7 +247,7 @@ local function toggle(event)
|
||||
|
||||
local filter_frame = scroll_pane.add {type = 'frame', caption = 'Entity Converter', direction = 'vertical'}
|
||||
|
||||
filter_frame.add {type = 'label', caption = 'Set filters then with blueprint in cursor click convert'}
|
||||
filter_frame.add {type = 'label', caption = 'Set filters then with blueprint in cursor click convert.'}
|
||||
|
||||
local filter_table = filter_frame.add {type = 'table', column_count = 13}
|
||||
|
||||
|
@ -2,212 +2,205 @@
|
||||
-- Feel free to edit.
|
||||
|
||||
return {
|
||||
['to_print'] = {
|
||||
-- "%name now in the [%band] group.",
|
||||
'%name has joined the [%band] party.',
|
||||
'%name is now supporting the [%band] party.'
|
||||
['Trooper'] = {
|
||||
path = 'item/tank',
|
||||
tooltip = {
|
||||
'Incoming!!!',
|
||||
"If the facts don't fit the theory, change the facts.",
|
||||
'I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.',
|
||||
"There's a fine line between genius and insanity. I have erased this line."
|
||||
},
|
||||
verbs = {
|
||||
'strengthened'
|
||||
}
|
||||
},
|
||||
['roles'] = {
|
||||
['Trooper'] = {
|
||||
path = 'item/tank',
|
||||
tooltip = {
|
||||
'Incoming!!!',
|
||||
"If the facts don't fit the theory, change the facts.",
|
||||
'I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.',
|
||||
"There's a fine line between genius and insanity. I have erased this line."
|
||||
},
|
||||
verbs = {
|
||||
'strengthened'
|
||||
}
|
||||
['Mining'] = {
|
||||
--"item/steel-axe",
|
||||
path = 'item/iron-axe',
|
||||
-- "item/iron-ore",
|
||||
-- "item/copper-ore",
|
||||
tooltip = {
|
||||
'Mine or not to mine',
|
||||
'The nation behaves well if it treats the natural resources as assets which\n it must turn over to the next generation increased, and not impaired, in value.'
|
||||
},
|
||||
['Mining'] = {
|
||||
--"item/steel-axe",
|
||||
path ='item/iron-axe',
|
||||
-- "item/iron-ore",
|
||||
-- "item/copper-ore",
|
||||
tooltip = {
|
||||
'Mine or not to mine',
|
||||
'The nation behaves well if it treats the natural resources as assets which\n it must turn over to the next generation increased, and not impaired, in value.'
|
||||
},
|
||||
verbs = {
|
||||
'enriched'
|
||||
-- "smelted"
|
||||
}
|
||||
verbs = {
|
||||
'enriched'
|
||||
-- "smelted"
|
||||
}
|
||||
},
|
||||
['Smelting'] = {
|
||||
--"item/assembling-machine-1",
|
||||
path = 'item/steel-furnace',
|
||||
--"item/assembling-machine-3",
|
||||
--"item/inserter",
|
||||
--"item/stack-inserter",
|
||||
tooltip = {
|
||||
'Mirrors are ice which do not melt: what melts are those who admire themselves in them.',
|
||||
"It's as certain that as long as fossil fuels are the cheapest energy, we will just keep burning them."
|
||||
},
|
||||
['Smelting'] = {
|
||||
--"item/assembling-machine-1",
|
||||
path ='item/steel-furnace',
|
||||
--"item/assembling-machine-3",
|
||||
--"item/inserter",
|
||||
--"item/stack-inserter",
|
||||
tooltip = {
|
||||
'Mirrors are ice which do not melt: what melts are those who admire themselves in them.',
|
||||
"It's as certain that as long as fossil fuels are the cheapest energy, we will just keep burning them."
|
||||
},
|
||||
verbs = {
|
||||
'fused'
|
||||
}
|
||||
verbs = {
|
||||
'fused'
|
||||
}
|
||||
},
|
||||
['Production'] = {
|
||||
--'item/assembling-machine-1',
|
||||
path = 'item/assembling-machine-2',
|
||||
--'item/assembling-machine-3',
|
||||
--"item/inserter",
|
||||
--"item/stack-inserter",
|
||||
tooltip = {
|
||||
"When every physical and mental resources is focused, one's power to solve a problem multiplies tremendously.",
|
||||
'The production of too many useful things results in too many useless people. ',
|
||||
'Everything must be made as simple as possible. But not simpler.'
|
||||
},
|
||||
['Production'] = {
|
||||
--'item/assembling-machine-1',
|
||||
path ='item/assembling-machine-2',
|
||||
--'item/assembling-machine-3',
|
||||
--"item/inserter",
|
||||
--"item/stack-inserter",
|
||||
tooltip = {
|
||||
"When every physical and mental resources is focused, one's power to solve a problem multiplies tremendously.",
|
||||
'The production of too many useful things results in too many useless people. ',
|
||||
'Everything must be made as simple as possible. But not simpler.'
|
||||
},
|
||||
verbs = {
|
||||
'enhanced'
|
||||
}
|
||||
verbs = {
|
||||
'enhanced'
|
||||
}
|
||||
},
|
||||
['Science'] = {
|
||||
path = 'item/science-pack-1',
|
||||
--'item/science-pack-2',
|
||||
--'item/science-pack-3',
|
||||
--'item/military-science-pack',
|
||||
--'item/production-science-pack',
|
||||
--'item/high-tech-science-pack',
|
||||
--'item/space-science-pack',
|
||||
tooltip = {
|
||||
'Science without religion is lame, religion without science is blind',
|
||||
'If we knew what it was we were doing, it would not be called research, would it?',
|
||||
'Somewhere, something incredible is waiting to be known.',
|
||||
"I'm sure the universe is full of intelligent life. It's just been too intelligent to come here."
|
||||
},
|
||||
['Science'] = {
|
||||
path ='item/science-pack-1',
|
||||
--'item/science-pack-2',
|
||||
--'item/science-pack-3',
|
||||
--'item/military-science-pack',
|
||||
--'item/production-science-pack',
|
||||
--'item/high-tech-science-pack',
|
||||
--'item/space-science-pack',
|
||||
tooltip = {
|
||||
'Science without religion is lame, religion without science is blind',
|
||||
'If we knew what it was we were doing, it would not be called research, would it?',
|
||||
'Somewhere, something incredible is waiting to be known.',
|
||||
"I'm sure the universe is full of intelligent life. It's just been too intelligent to come here."
|
||||
},
|
||||
verbs = {
|
||||
'advanced'
|
||||
}
|
||||
verbs = {
|
||||
'advanced'
|
||||
}
|
||||
},
|
||||
['Wizard'] = {
|
||||
--'item/green-wire',
|
||||
--'item/red-wire',
|
||||
path = 'item/arithmetic-combinator',
|
||||
--'item/decider-combinator',
|
||||
tooltip = {
|
||||
"Without mathematics, there's nothing you can do. Everything around you is mathematics. Everything around you is numbers.",
|
||||
'Pure mathematics is, in its way, the poetry of logical ideas.',
|
||||
'God used beautiful mathematics in creating the world.',
|
||||
'The numbers may be said to rule the whole world of quantity, and the four rules of arithmetic may be regarded as the complete equipment of the mathematician.',
|
||||
'But if the technological Singularity can happen, it will.'
|
||||
--"One day it will have a mind of it´s own!."
|
||||
},
|
||||
['Wizard'] = {
|
||||
--'item/green-wire',
|
||||
--'item/red-wire',
|
||||
path ='item/arithmetic-combinator',
|
||||
--'item/decider-combinator',
|
||||
tooltip = {
|
||||
"Without mathematics, there's nothing you can do. Everything around you is mathematics. Everything around you is numbers.",
|
||||
'Pure mathematics is, in its way, the poetry of logical ideas.',
|
||||
'God used beautiful mathematics in creating the world.',
|
||||
'The numbers may be said to rule the whole world of quantity, and the four rules of arithmetic may be regarded as the complete equipment of the mathematician.',
|
||||
'But if the technological Singularity can happen, it will.'
|
||||
--"One day it will have a mind of it´s own!."
|
||||
},
|
||||
verbs = {
|
||||
'combinated',
|
||||
'equaled'
|
||||
}
|
||||
verbs = {
|
||||
'combinated',
|
||||
'equaled'
|
||||
}
|
||||
},
|
||||
['Trains'] = {
|
||||
--"entity/curved-rail",
|
||||
--"item/cargo-wagon",
|
||||
--"item/fluid-wagon",
|
||||
path = 'item/locomotive',
|
||||
--"item/rail-signal",
|
||||
--"item/rail",
|
||||
tooltip = {
|
||||
'Ch, ch, choooo!',
|
||||
'The only way of catching a train I have ever discovered is to miss the train before. ',
|
||||
"If a trainstation is where the train stops, what's a workstation...?"
|
||||
},
|
||||
['Trains'] = {
|
||||
--"entity/curved-rail",
|
||||
--"item/cargo-wagon",
|
||||
--"item/fluid-wagon",
|
||||
path ='item/locomotive',
|
||||
--"item/rail-signal",
|
||||
--"item/rail",
|
||||
tooltip = {
|
||||
'Ch, ch, choooo!',
|
||||
'The only way of catching a train I have ever discovered is to miss the train before. ',
|
||||
"If a trainstation is where the train stops, what's a workstation...?"
|
||||
},
|
||||
verbs = {
|
||||
'expanded',
|
||||
'derailed'
|
||||
}
|
||||
verbs = {
|
||||
'expanded',
|
||||
'derailed'
|
||||
}
|
||||
},
|
||||
['Oil'] = {
|
||||
--"item/storage-tank",
|
||||
--"item/pipe-to-ground",
|
||||
--"item/oil-refinery",
|
||||
--"item/chemical-plant",
|
||||
path = 'item/pumpjack',
|
||||
--'fluid/crude-oil',
|
||||
--"fluid/heavy-oil",
|
||||
--"fluid/light-oil",
|
||||
--"fluid/petroleum-gas",
|
||||
--"fluid/lubricant",
|
||||
--"fluid/sulfuric-acid",
|
||||
tooltip = {
|
||||
"We're running out of oil!",
|
||||
'Black gold',
|
||||
"Naturally occurring, yellow-to-black liquid found in geological formations beneath the Earth's surface, which is commonly refined into various types of fuels.",
|
||||
'Components of petroleum are separated using a technique called fractional distillation.',
|
||||
'The petroleum industry generally classifies crude oil by the geographic location it is produced in (e.g. West Texas Intermediate, Brent, or Oman), its API gravity (an oil industry measure of density), and its sulfur content.'
|
||||
},
|
||||
['Oil'] = {
|
||||
--"item/storage-tank",
|
||||
--"item/pipe-to-ground",
|
||||
--"item/oil-refinery",
|
||||
--"item/chemical-plant",
|
||||
path ='item/pumpjack',
|
||||
--'fluid/crude-oil',
|
||||
--"fluid/heavy-oil",
|
||||
--"fluid/light-oil",
|
||||
--"fluid/petroleum-gas",
|
||||
--"fluid/lubricant",
|
||||
--"fluid/sulfuric-acid",
|
||||
tooltip = {
|
||||
"We're running out of oil!",
|
||||
'Black gold',
|
||||
"Naturally occurring, yellow-to-black liquid found in geological formations beneath the Earth's surface, which is commonly refined into various types of fuels.",
|
||||
'Components of petroleum are separated using a technique called fractional distillation.',
|
||||
'The petroleum industry generally classifies crude oil by the geographic location it is produced in (e.g. West Texas Intermediate, Brent, or Oman), its API gravity (an oil industry measure of density), and its sulfur content.'
|
||||
},
|
||||
verbs = {
|
||||
'lubricated',
|
||||
'sulfured'
|
||||
}
|
||||
verbs = {
|
||||
'lubricated',
|
||||
'sulfured'
|
||||
}
|
||||
},
|
||||
['Powah!'] = {
|
||||
--'item/steam-turbine',
|
||||
--"item/nuclear-reactor",
|
||||
--"item/heat-exchanger",
|
||||
path = 'item/steam-engine',
|
||||
--'item/solar-panel',
|
||||
--'item/accumulator',
|
||||
--"item/boiler",
|
||||
--"fluid/steam",
|
||||
tooltip = {
|
||||
'I ve Got The power!',
|
||||
'Power Overwhelming!!!111',
|
||||
'Its Over 9000!!!',
|
||||
'If you want to find the secrets of the universe, think in terms of energy, frequency and vibration.'
|
||||
},
|
||||
['Powah!'] = {
|
||||
--'item/steam-turbine',
|
||||
--"item/nuclear-reactor",
|
||||
--"item/heat-exchanger",
|
||||
path = 'item/steam-engine',
|
||||
--'item/solar-panel',
|
||||
--'item/accumulator',
|
||||
--"item/boiler",
|
||||
--"fluid/steam",
|
||||
tooltip = {
|
||||
'I ve Got The power!',
|
||||
'Power Overwhelming!!!111',
|
||||
'Its Over 9000!!!',
|
||||
'If you want to find the secrets of the universe, think in terms of energy, frequency and vibration.'
|
||||
},
|
||||
verbs = {
|
||||
'amplified',
|
||||
'teslaed',
|
||||
'electrified'
|
||||
}
|
||||
verbs = {
|
||||
'amplified',
|
||||
'teslaed',
|
||||
'electrified'
|
||||
}
|
||||
},
|
||||
['Spaceman'] = {
|
||||
path = 'item/rocket-silo',
|
||||
--'item/rocket-control-unit',
|
||||
--'item/satellite',
|
||||
--'item/rocket-fuel',
|
||||
tooltip = {
|
||||
"That's one small step for a man, one giant leap for mankind.",
|
||||
"The sky is the limit only for those who aren't afraid to fly!",
|
||||
'Apocalyptic explosions, dead reactors, terrorists, mass murder, death-slugs, and now a blindness plague. This is a terrible planet. We should not have come here.',
|
||||
'A still more glorious dawn awaits. Not a sunrise, but a galaxy rise. A morning filled with 400 billion suns. The rising of the milky way',
|
||||
'The Universe is under no obligation to make sense to you.'
|
||||
},
|
||||
['Spaceman'] = {
|
||||
path ='item/rocket-silo',
|
||||
--'item/rocket-control-unit',
|
||||
--'item/satellite',
|
||||
--'item/rocket-fuel',
|
||||
tooltip = {
|
||||
"That's one small step for a man, one giant leap for mankind.",
|
||||
"The sky is the limit only for those who aren't afraid to fly!",
|
||||
'Apocalyptic explosions, dead reactors, terrorists, mass murder, death-slugs, and now a blindness plague. This is a terrible planet. We should not have come here.',
|
||||
'A still more glorious dawn awaits. Not a sunrise, but a galaxy rise. A morning filled with 400 billion suns. The rising of the milky way',
|
||||
'The Universe is under no obligation to make sense to you.'
|
||||
},
|
||||
verbs = {
|
||||
'warped'
|
||||
}
|
||||
verbs = {
|
||||
'warped'
|
||||
}
|
||||
},
|
||||
['Cat'] = {
|
||||
path = 'item/raw-fish',
|
||||
tooltip = {
|
||||
'=^.^=',
|
||||
'Meow',
|
||||
"In a cat's eye, all things belong to cats.",
|
||||
"Cats don't like change without their consent.",
|
||||
'Heard melodies are sweet, but those unheard, are sweeter'
|
||||
},
|
||||
['Cat'] = {
|
||||
path ='item/raw-fish',
|
||||
tooltip = {
|
||||
'=^.^=',
|
||||
'Meow',
|
||||
"In a cat's eye, all things belong to cats.",
|
||||
"Cats don't like change without their consent.",
|
||||
'Heard melodies are sweet, but those unheard, are sweeter'
|
||||
},
|
||||
verbs = {
|
||||
'mewed',
|
||||
'purred',
|
||||
'miaowed'
|
||||
}
|
||||
verbs = {
|
||||
'mewed',
|
||||
'purred',
|
||||
'miaowed'
|
||||
}
|
||||
},
|
||||
['Dog'] = {
|
||||
path = 'entity/small-biter',
|
||||
--'entity/medium-biter',
|
||||
--'entity/big-biter',
|
||||
--'entity/behemoth-biter',
|
||||
tooltip = {
|
||||
'Not a cat',
|
||||
'Friend',
|
||||
"It's not the size of the dog in the fight, it's the size of the fight in the dog.",
|
||||
'When what you want is a relationship, and not a person, get a dog',
|
||||
'A dog has one aim in life... to bestow his heart.'
|
||||
},
|
||||
['Dog'] = {
|
||||
path ='entity/small-biter',
|
||||
--'entity/medium-biter',
|
||||
--'entity/big-biter',
|
||||
--'entity/behemoth-biter',
|
||||
tooltip = {
|
||||
'Not a cat',
|
||||
'Friend',
|
||||
"It's not the size of the dog in the fight, it's the size of the fight in the dog.",
|
||||
'When what you want is a relationship, and not a person, get a dog',
|
||||
'A dog has one aim in life... to bestow his heart.'
|
||||
},
|
||||
verbs = {
|
||||
'woofed',
|
||||
'howled'
|
||||
}
|
||||
verbs = {
|
||||
'woofed',
|
||||
'howled'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user