mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-02-11 13:39:17 +02:00
added poor lost files
This commit is contained in:
parent
3f9e95b88e
commit
577b433baf
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)
|
257
player_list.lua
Normal file
257
player_list.lua
Normal file
@ -0,0 +1,257 @@
|
||||
--[[
|
||||
Hello there!
|
||||
|
||||
This will add a player list with "ranks" to your server.
|
||||
Oh.. and you can also "poke" a player.
|
||||
|
||||
To install, add: require "player_list"
|
||||
to your scenario control.lua.
|
||||
|
||||
---MewMew---
|
||||
|
||||
pokemessage = 80% by redlabel
|
||||
|
||||
|
||||
things to do (maybe)
|
||||
make it sorted by time played
|
||||
make poke buttons count pokes
|
||||
make division instead of for loop
|
||||
--]]
|
||||
|
||||
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"}
|
||||
|
||||
local function create_player_list_button(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
|
||||
|
||||
local time_counter = time_needed
|
||||
for i=1,#ranks,1 do
|
||||
if m < time_counter then return ranks[i] end
|
||||
time_counter = time_counter + time_needed
|
||||
end
|
||||
|
||||
return ranks[#ranks]
|
||||
end
|
||||
|
||||
local function player_list_show(player)
|
||||
|
||||
player.gui.left.direction = "horizontal"
|
||||
local frame = player.gui.left.add { type = "frame", name = "player-list-panel", direction = "vertical" }
|
||||
frame.style.top_padding = 8
|
||||
frame.style.left_padding = 8
|
||||
frame.style.right_padding = 8
|
||||
frame.style.bottom_padding = 8
|
||||
|
||||
local player_list_panel_table = frame.add { type = "table", name = "player_list_panel_table", colspan = 4 }
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_header_1", caption = "" }
|
||||
label.style.font = "default-game"
|
||||
label.style.font_color = { r=0.00, g=0.00, b=0.00}
|
||||
label.style.minimal_width = 35
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_header_2", caption = "Players online" }
|
||||
label.style.font = "default-listbox"
|
||||
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
label.style.minimal_width = 140
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_header_3", caption = "Time played" }
|
||||
label.style.font = "default-listbox"
|
||||
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
label.style.minimal_width = 140
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_header_4", caption = "Poke" }
|
||||
label.style.font = "default-bold"
|
||||
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
--label.style.minimal_width = 35
|
||||
|
||||
|
||||
local x = 1
|
||||
local online_players_amount = 0
|
||||
--local connected_player_table = {}
|
||||
|
||||
while (game.players[x] ~= nil) do
|
||||
|
||||
local player = game.players[x]
|
||||
if player.connected then
|
||||
|
||||
online_players_amount = online_players_amount + 1
|
||||
--connected_player_table[online_players_amount] = {t_player_index = x, t_player_playtime = player.online_time}
|
||||
local str = get_rank(player)
|
||||
|
||||
player_list_panel_table.add { type = "sprite", name = "player_rank_sprite_" .. x, sprite = str }
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_names_" .. x, caption = player.name }
|
||||
label.style.font = "default"
|
||||
label.style.font_color = {
|
||||
r = .4 + player.color.r * 0.6,
|
||||
g = .4 + player.color.g * 0.6,
|
||||
b = .4 + player.color.b * 0.6,
|
||||
}
|
||||
--label.style.minimal_width = 140
|
||||
|
||||
local time_played = get_formatted_playtime(player.online_time)
|
||||
|
||||
local label = player_list_panel_table.add { type = "label", name = "player_list_panel_player_time_played_" .. x, caption = time_played }
|
||||
|
||||
if not global.player_list_pokes_counter[player.index] then global.player_list_pokes_counter[player.index] = 0 end
|
||||
|
||||
local button = player_list_panel_table.add { type = "button", name = "poke_player_" .. player.name, caption = global.player_list_pokes_counter[player.index] }
|
||||
button.style.font = "default"
|
||||
label.style.font_color = { r=0.83, g=0.83, b=0.83}
|
||||
button.style.minimal_height = 28
|
||||
button.style.minimal_width = 28
|
||||
button.style.maximal_height = 28
|
||||
button.style.maximal_width = 28
|
||||
button.style.top_padding = 0
|
||||
button.style.left_padding = 0
|
||||
button.style.right_padding = 0
|
||||
button.style.bottom_padding = 0
|
||||
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
x = x - 1
|
||||
player_list_panel_table.player_list_panel_header_1.caption = " " .. online_players_amount
|
||||
|
||||
--[[
|
||||
connected_player_table[2] = {t_player_index = 27, t_player_playtime = 235355}
|
||||
connected_player_table[3] = {t_player_index = 7, t_player_playtime = 11532563}
|
||||
connected_player_table[4] = {t_player_index = 9, t_player_playtime = 2355}
|
||||
connected_player_table[5] = {t_player_index = 15, t_player_playtime = 43545}
|
||||
|
||||
--table.sort(connected_player_table, function(a, b) return a[2] > b[2] end)
|
||||
|
||||
for x=1,#connected_player_table,1 do
|
||||
local z = connected_player_table[x]
|
||||
local a = "t_player_index=" .. z.t_player_index
|
||||
a = a.. " t_player_playtime="
|
||||
a = a .. z.t_player_playtime
|
||||
game.print(a)
|
||||
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
|
||||
local frame = player.gui.left["player-list-panel"]
|
||||
if (frame) then
|
||||
frame.destroy()
|
||||
else
|
||||
player_list_show(player)
|
||||
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 player_list_refresh()
|
||||
if game.tick % 1800 == 0 then
|
||||
local x = 1
|
||||
while game.players[x] ~= nil do
|
||||
local player = game.players[x]
|
||||
if player.connected then
|
||||
local frame = player.gui.left["player-list-panel"]
|
||||
if frame then
|
||||
frame.destroy()
|
||||
player_list_show(player)
|
||||
end
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Event.register(defines.events.on_tick, player_list_refresh)
|
||||
Event.register(defines.events.on_player_joined_game, create_player_list_button)
|
||||
Event.register(defines.events.on_player_left_game, player_log_out)
|
||||
Event.register(defines.events.on_gui_click, on_gui_click)
|
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