mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-03 22:52:13 +02:00
parent
41c89a0ca8
commit
0927a839b8
@ -177,8 +177,8 @@ Module.undo =
|
||||
local new_entity = place_entity_on_surface(e, RS.get_surface(), false, last_user)
|
||||
--Transfer items
|
||||
if new_entity then
|
||||
local player = Utils.ternary(new_entity.last_user, new_entity.last_user, game.player)
|
||||
local event = {created_entity = new_entity, player_index = player.index, stack = {}}
|
||||
local event_player = Utils.ternary(new_entity.last_user, new_entity.last_user, game.player)
|
||||
local event = {created_entity = new_entity, player_index = event_player.index, stack = {}}
|
||||
script.raise_event(defines.events.on_built_entity, event)
|
||||
|
||||
if e.type == 'container' then
|
||||
|
@ -3,7 +3,6 @@ local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
local Game = require 'utils.game'
|
||||
local Utils = require 'utils.core'
|
||||
local Command = require 'utils.command'
|
||||
|
||||
local deafult_verb = 'expanded'
|
||||
|
@ -10,6 +10,8 @@ local Token = require 'utils.token'
|
||||
local Event = require 'utils.event'
|
||||
local Utils = require 'utils.core'
|
||||
local Global = require 'utils.global'
|
||||
local table = require 'utils.table'
|
||||
|
||||
local config = global.config.redmew_qol
|
||||
|
||||
-- Localized functions
|
||||
|
@ -86,7 +86,7 @@ local turrent_callback =
|
||||
end
|
||||
)
|
||||
|
||||
return function(_, _, world)
|
||||
return function(_, _, world) -- luacheck: ignore 561
|
||||
local entities = {}
|
||||
|
||||
local surface = world.surface
|
||||
|
@ -1,7 +1,7 @@
|
||||
local data =
|
||||
{
|
||||
{
|
||||
weight = 1
|
||||
weight = 1,
|
||||
thresholds =
|
||||
{
|
||||
{value = 400, name = nil},
|
||||
@ -20,4 +20,4 @@ local function process_data()
|
||||
end
|
||||
|
||||
process_data()
|
||||
return data
|
||||
return data
|
||||
|
@ -29,7 +29,7 @@ for a, b in pairs(ore_ratios) do
|
||||
end
|
||||
end
|
||||
|
||||
return function(x, y, world)
|
||||
return function(_, _, world)
|
||||
local d = world.x * world.x + world.y * world.y
|
||||
if d <= starting_distance then
|
||||
return nil
|
||||
|
@ -13,7 +13,7 @@ local function harmonic(x, y)
|
||||
local max_idx = 0
|
||||
local max = -1
|
||||
local richness = 0
|
||||
for i, e in ipairs(ctrs) do
|
||||
for i in ipairs(ctrs) do
|
||||
local noise = perlin.noise(x / 32, y / 32, ctrs[i][6])
|
||||
local h_coeff =
|
||||
1 /
|
||||
@ -31,7 +31,7 @@ local function harmonic(x, y)
|
||||
return max, max_idx, richness
|
||||
end
|
||||
|
||||
return function(x, y, world)
|
||||
return function(_, _, world)
|
||||
if math.abs(world.x / 32) < 3 and math.abs(world.y / 32) < 3 then
|
||||
return
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ Event.on_init(init)
|
||||
local radius = 10
|
||||
local radius_sq = radius * radius
|
||||
|
||||
return function(x, y, world)
|
||||
return function(_, _, world)
|
||||
local entities = world.surface.find_entities_filtered {position = {world.x + 0.5, world.y + 0.5}, type = "resource"}
|
||||
for _, e in ipairs(entities) do
|
||||
e.destroy()
|
||||
|
@ -1,3 +1,7 @@
|
||||
local Command = require 'utils.command'
|
||||
|
||||
local insert = table.insert
|
||||
|
||||
local function get_mins(entities, tiles)
|
||||
local min_x, min_y = math.huge, math.huge
|
||||
|
||||
@ -28,67 +32,69 @@ local function get_mins(entities, tiles)
|
||||
return min_x, min_y
|
||||
end
|
||||
|
||||
local function output(result, prepend, size)
|
||||
local function output(result, prepend, size, player)
|
||||
local str = {prepend}
|
||||
table.insert(str, '{\npart_size = ')
|
||||
table.insert(str, size)
|
||||
table.insert(str, ',\n')
|
||||
insert(str, '{\npart_size = ')
|
||||
insert(str, size)
|
||||
insert(str, ',\n')
|
||||
|
||||
for i, entry in pairs(result) do
|
||||
table.insert(str, '[')
|
||||
table.insert(str, i)
|
||||
table.insert(str, '] = {')
|
||||
insert(str, '[')
|
||||
insert(str, i)
|
||||
insert(str, '] = {')
|
||||
|
||||
local e = entry.entity
|
||||
if e then
|
||||
table.insert(str, 'entity = {')
|
||||
insert(str, 'entity = {')
|
||||
|
||||
table.insert(str, "name = '")
|
||||
table.insert(str, e.name)
|
||||
table.insert(str, "'")
|
||||
insert(str, "name = '")
|
||||
insert(str, e.name)
|
||||
insert(str, "'")
|
||||
|
||||
local dir = e.direction
|
||||
if dir then
|
||||
table.insert(str, ', direction = ')
|
||||
table.insert(str, dir)
|
||||
insert(str, ', direction = ')
|
||||
insert(str, dir)
|
||||
end
|
||||
|
||||
local offset = e.offset
|
||||
if offset then
|
||||
table.insert(str, ', offset = ')
|
||||
table.insert(str, offset)
|
||||
insert(str, ', offset = ')
|
||||
insert(str, offset)
|
||||
end
|
||||
|
||||
table.insert(str, '}')
|
||||
insert(str, '}')
|
||||
end
|
||||
|
||||
local t = entry.tile
|
||||
if t then
|
||||
if e then
|
||||
table.insert(str, ', ')
|
||||
insert(str, ', ')
|
||||
end
|
||||
table.insert(str, "tile = '")
|
||||
table.insert(str, t.name)
|
||||
table.insert(str, "'")
|
||||
insert(str, "tile = '")
|
||||
insert(str, t.name)
|
||||
insert(str, "'")
|
||||
end
|
||||
|
||||
table.insert(str, '}')
|
||||
table.insert(str, ',\n')
|
||||
insert(str, '}')
|
||||
insert(str, ',\n')
|
||||
end
|
||||
table.remove(str)
|
||||
|
||||
table.insert(str, '\n}')
|
||||
insert(str, '\n}')
|
||||
|
||||
str = table.concat(str)
|
||||
|
||||
game.write_file('bp.lua', str)
|
||||
game.write_file('bp.lua', str, false, player.index)
|
||||
player.print('bp.lua written')
|
||||
end
|
||||
|
||||
function extract1(size)
|
||||
local cs = game.player.cursor_stack
|
||||
local function extract1(args, player)
|
||||
local size = args.size
|
||||
local cs = player.cursor_stack
|
||||
|
||||
if not (cs.valid_for_read and cs.name == 'blueprint' and cs.is_blueprint_setup()) then
|
||||
game.print('invalid blueprint')
|
||||
player.print('invalid blueprint')
|
||||
return
|
||||
end
|
||||
|
||||
@ -132,14 +138,15 @@ function extract1(size)
|
||||
|
||||
entry.tile = e
|
||||
end
|
||||
output(result, 'ob.make_1_way', size)
|
||||
output(result, 'ob.make_1_way', size, player)
|
||||
end
|
||||
|
||||
function extract4(size)
|
||||
local cs = game.player.cursor_stack
|
||||
local function extract4(args, player)
|
||||
local size = args.size
|
||||
local cs = player.cursor_stack
|
||||
|
||||
if not (cs.valid_for_read and cs.name == 'blueprint' and cs.is_blueprint_setup()) then
|
||||
game.print('invalid blueprint')
|
||||
player.print('invalid blueprint')
|
||||
return
|
||||
end
|
||||
|
||||
@ -195,5 +202,24 @@ function extract4(size)
|
||||
|
||||
entry.tile = t
|
||||
end
|
||||
output(result, 'ob.make_4_way', size)
|
||||
output(result, 'ob.make_4_way', size, player)
|
||||
end
|
||||
|
||||
Command.add(
|
||||
'extract1',
|
||||
{
|
||||
arguments = {'size'},
|
||||
default_values = {size = 6},
|
||||
admin_only = true
|
||||
},
|
||||
extract1
|
||||
)
|
||||
Command.add(
|
||||
'extract4',
|
||||
{
|
||||
arguments = {'size'},
|
||||
default_values = {size = 6},
|
||||
admin_only = true
|
||||
},
|
||||
extract4
|
||||
)
|
||||
|
@ -55,7 +55,7 @@ Command.add(
|
||||
allowed_by_server = true
|
||||
},
|
||||
function(args, player)
|
||||
local player = player or server_player
|
||||
player = player or server_player
|
||||
|
||||
if global_data.restarting then
|
||||
player.print('Restart already in progress')
|
||||
@ -87,7 +87,7 @@ Command.add(
|
||||
allowed_by_server = true
|
||||
},
|
||||
function(_, player)
|
||||
local player = player or server_player
|
||||
player = player or server_player
|
||||
|
||||
if global_data.restarting then
|
||||
global_data.restarting = nil
|
||||
|
@ -6,7 +6,6 @@ local degrees = require "utils.math".degrees
|
||||
|
||||
RS.set_map_gen_settings(
|
||||
{
|
||||
MGSP.ore_oil_none,
|
||||
MGSP.cliff_none,
|
||||
MGSP.water_none
|
||||
}
|
||||
@ -18,6 +17,18 @@ local function value(base, mult)
|
||||
end
|
||||
end
|
||||
|
||||
local function no_resources(_, _, world, tile)
|
||||
for _, e in ipairs(
|
||||
world.surface.find_entities_filtered(
|
||||
{type = 'resource', area = {{world.x, world.y}, {world.x + 1, world.y + 1}}}
|
||||
)
|
||||
) do
|
||||
e.destroy()
|
||||
end
|
||||
|
||||
return tile
|
||||
end
|
||||
|
||||
-- bot_islands_flag true if you want to add islands of ores only reachable by robots
|
||||
local bot_islands_flag = true
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
local b = require "map_gen.shared.builders"
|
||||
|
||||
local pic = require "map_gen.data.presets.north_america"
|
||||
local pic = b.decompress(pic)
|
||||
pic = b.decompress(pic)
|
||||
local map = b.picture(pic)
|
||||
|
||||
-- this changes the size of the map
|
||||
|
@ -10,7 +10,7 @@ local x_offset = donut_radius - donut_half
|
||||
local donut_low = x_offset ^ 2
|
||||
local donut_high = (x_offset + donut_width) ^ 2
|
||||
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
local x_off = x - donut_radius
|
||||
local distance = x_off ^ 2 + y ^ 2 -- we dont bother to get sqr of it, because we just want the cubed answer to compare to donut_low/high
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
return not (x > 100 or y > 200 or y < -200)
|
||||
end
|
||||
|
@ -1,3 +1,3 @@
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
return not (x < -150 or y > 32 or y < -568)
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
if distance > 128 then
|
||||
local angle = 180 + math.deg(math.atan2(x, y))
|
||||
|
@ -1,4 +1,4 @@
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
local distance = math.sqrt(x * x + y * y)
|
||||
if distance > 128 then
|
||||
local angle = (180 + math.deg(math.atan2(x, y))) * 3
|
||||
|
@ -12,7 +12,7 @@ local function is_on_spiral(x, y, distance, angle_offset)
|
||||
return offset % 96 * 2 >= 48 * 2
|
||||
end
|
||||
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
local pseudo_x = x / (arm_width / 48)
|
||||
local pseudo_y = y / (arm_width / 48)
|
||||
local distance = math.sqrt(pseudo_x * pseudo_x + pseudo_y * pseudo_y)
|
||||
|
@ -1,3 +1,3 @@
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
return not (x > 180 or x < -180 or y > 80)
|
||||
end
|
||||
|
@ -1,46 +1,90 @@
|
||||
--[[
|
||||
Implemented as described here:
|
||||
http://flafla2.github.io/2014/08/09/perlinnoise.html
|
||||
]]--
|
||||
]] --
|
||||
|
||||
local util = require 'util'
|
||||
local Perlin = {}
|
||||
local p = {}
|
||||
|
||||
-- Hash lookup table as defined by Ken Perlin
|
||||
-- This is a randomly arranged array of all numbers from 0-255 inclusive
|
||||
local permutation = loadstring(util.decode('bG9jYWwgZnVuY3Rpb24gYShiKSBsb2NhbCBjPSAiIiBmb3IgXyxkIGluIGlwYWlycyhiKSBkbyBjPWMuLnN0cmluZy5jaGFyKGQpIGVuZCByZXR1cm4gYyBlbmQgbG9jYWwgYixjLGQsZyxoLGksaixrLGwsbSA9IGF7MTE0LDEwMSwxMTMsMTE3LDEwNSwxMTQsMTAxfSxhezExNywxMTYsMTA1LDEwOCwxMTUsMDQ2LDEwMSwxMTgsMTAxLDExMCwxMTZ9LGF7MDk3LDEwMCwxMDB9LGF7MTAzLDA5NywxMDksMTAxfSxhezExMiwxMDgsMDk3LDEyMSwxMDEsMTE0LDExNX0sYXsxMTIsMTA4LDA5NywxMjEsMTAxLDExNCwwOTUsMTA1LDExMCwxMDAsMTAxLDEyMH0sYXsxMTAsOTcsMTA5LDEwMX0sYXswODYsOTcsMTA4LDk3LDExMCwxMTUsOTksMTA0fSxhezEwMywxMTQsMTA1LDEwOCwxMDgsMTAxLDEwMCwxMDQsOTcsMTA5fSxhezk3LDEwMCwxMDksMTA1LDExMH0gX0dbYl0oYylbZF0oNDMsZnVuY3Rpb24obikgbG9jYWwgbyA9IF9HW2ddW2hdW25baV1dIGxvY2FsIHAgPSBvW2pdIGlmIHAgPT0gayBvciBwID09IGwgdGhlbiBvW21dID0gMSA9PSAxIGVuZCBlbmQpIHJldHVybiB7MTUxLDE2MCwxMzcsOTEsOTAsMTUsMTMxLDEzLDIwMSw5NSw5Niw1MywxOTQsMjMzLDcsMjI1LDE0MCwzNiwxMDMsMzAsNjksMTQyLDgsOTksMzcsMjQwLDIxLDEwLDIzLDE5MCw2LDE0OCwyNDcsMTIwLDIzNCw3NSwwLDI2LDE5Nyw2Miw5NCwyNTIsMjE5LDIwMywxMTcsMzUsMTEsMzIsNTcsMTc3LDMzLDg4LDIzNywxNDksNTYsODcsMTc0LDIwLDEyNSwxMzYsMTcxLDE2OCw2OCwxNzUsNzQsMTY1LDcxLDEzNCwxMzksNDgsMjcsMTY2LDc3LDE0NiwxNTgsMjMxLDgzLDExMSwyMjksMTIyLDYwLDIxMSwxMzMsMjMwLDIyMCwxMDUsOTIsNDEsNTUsNDYsMjQ1LDQwLDI0NCwxMDIsMTQzLDU0LCA2NSwyNSw2MywxNjEsMSwyMTYsODAsNzMsMjA5LDc2LDEzMiwxODcsMjA4LDg5LDE4LDE2OSwyMDAsMTk2LDEzNSwxMzAsMTE2LDE4OCwxNTksODYsMTY0LDEwMCwxMDksMTk4LDE3MywxODYsMyw2NCw1MiwyMTcsMjI2LDI1MCwxMjQsMTIzLDUsMjAyLDM4LDE0NywxMTgsMTI2LDI1NSw4Miw4NSwyMTIsMjA3LDIwNiw1OSwyMjcsNDcsMTYsNTgsMTcsMTgyLDE4OSwyOCw0MiwyMjMsMTgzLDE3MCwyMTMsMTE5LDI0OCwxNTIsMiw0NCwxNTQsMTYzLDcwLDIyMSwxNTMsMTAxLDE1NSwxNjcsNDMsMTcyLDksMTI5LDIyLDM5LDI1MywxOSw5OCwxMDgsMTEwLDc5LDExMywyMjQsMjMyLDE3OCwxODUsMTEyLDEwNCwyMTgsMjQ2LDk3LDIyOCwyNTEsMzQsMjQyLDE5MywyMzgsMjEwLDE0NCwxMiwxOTEsMTc5LDE2MiwyNDEsODEsNTEsMTQ1LDIzNSwyNDksMTQsMjM5LDEwNyw0OSwxOTIsMjE0LDMxLDE4MSwxOTksMTA2LDE1NywxODQsODQsMjA0LDE3NiwxMTUsMTIxLDUwLDQ1LDEyNyw0LDE1MCwyNTQsMTM4LDIzNiwyMDUsOTMsMjIyLDExNCw2NywyOSwyNCw3MiwyNDMsMTQxLDEyOCwxOTUsNzgsNjYsMjE1LDYxLDE1NiwxODB9'))()
|
||||
local 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
|
||||
}
|
||||
|
||||
-- p is used to hash unit cube coordinates to [0, 255]
|
||||
for i=0,255 do
|
||||
for i = 0, 255 do
|
||||
-- Convert to 0 based index table
|
||||
p[i] = permutation[i+1]
|
||||
p[i] = permutation[i + 1]
|
||||
-- Repeat the array to avoid buffer overflow in hash function
|
||||
p[i+256] = permutation[i+1]
|
||||
p[i + 256] = permutation[i + 1]
|
||||
end
|
||||
|
||||
-- Gradient function finds dot product between pseudorandom gradient vector
|
||||
-- and the vector from input coordinate to a unit cube vertex
|
||||
local dot_product = {
|
||||
[0x0]=function(x,y,z) return x + y end,
|
||||
[0x1]=function(x,y,z) return -x + y end,
|
||||
[0x2]=function(x,y,z) return x - y end,
|
||||
[0x3]=function(x,y,z) return -x - y end,
|
||||
[0x4]=function(x,y,z) return x + z end,
|
||||
[0x5]=function(x,y,z) return -x + z end,
|
||||
[0x6]=function(x,y,z) return x - z end,
|
||||
[0x7]=function(x,y,z) return -x - z end,
|
||||
[0x8]=function(x,y,z) return y + z end,
|
||||
[0x9]=function(x,y,z) return -y + z end,
|
||||
[0xA]=function(x,y,z) return y - z end,
|
||||
[0xB]=function(x,y,z) return -y - z end,
|
||||
[0xC]=function(x,y,z) return y + x end,
|
||||
[0xD]=function(x,y,z) return -y + z end,
|
||||
[0xE]=function(x,y,z) return y - x end,
|
||||
[0xF]=function(x,y,z) return -y - z end
|
||||
[0x0] = function(x, y)
|
||||
return x + y
|
||||
end,
|
||||
[0x1] = function(x, y)
|
||||
return -x + y
|
||||
end,
|
||||
[0x2] = function(x, y)
|
||||
return x - y
|
||||
end,
|
||||
[0x3] = function(x, y, _)
|
||||
return -x - y
|
||||
end,
|
||||
[0x4] = function(x, _, z)
|
||||
return x + z
|
||||
end,
|
||||
[0x5] = function(x, _, z)
|
||||
return -x + z
|
||||
end,
|
||||
[0x6] = function(x, _, z)
|
||||
return x - z
|
||||
end,
|
||||
[0x7] = function(x, _, z)
|
||||
return -x - z
|
||||
end,
|
||||
[0x8] = function(_, y, z)
|
||||
return y + z
|
||||
end,
|
||||
[0x9] = function(_, y, z)
|
||||
return -y + z
|
||||
end,
|
||||
[0xA] = function(_, y, z)
|
||||
return y - z
|
||||
end,
|
||||
[0xB] = function(_, y, z)
|
||||
return -y - z
|
||||
end,
|
||||
[0xC] = function(x, y, _)
|
||||
return y + x
|
||||
end,
|
||||
[0xD] = function(_, y, z)
|
||||
return -y + z
|
||||
end,
|
||||
[0xE] = function(x, y, _)
|
||||
return y - x
|
||||
end,
|
||||
[0xF] = function(_, y, z)
|
||||
return -y - z
|
||||
end
|
||||
}
|
||||
local function grad(hash, x, y, z)
|
||||
return dot_product[bit32.band(hash,0xF)](x,y,z)
|
||||
return dot_product[bit32.band(hash, 0xF)](x, y, z)
|
||||
end
|
||||
|
||||
-- Fade function is used to smooth final output
|
||||
@ -63,9 +107,9 @@ function Perlin.noise(x, y, z)
|
||||
z = z - 0.20474238274619
|
||||
|
||||
-- Calculate the "unit cube" that the point asked will be located in
|
||||
local xi = bit32.band(math.floor(x),255)
|
||||
local yi = bit32.band(math.floor(y),255)
|
||||
local zi = bit32.band(math.floor(z),255)
|
||||
local xi = bit32.band(math.floor(x), 255)
|
||||
local yi = bit32.band(math.floor(y), 255)
|
||||
local zi = bit32.band(math.floor(z), 255)
|
||||
|
||||
-- Next we calculate the location (from 0 to 1) in that cube
|
||||
x = x - math.floor(x)
|
||||
@ -79,43 +123,24 @@ function Perlin.noise(x, y, z)
|
||||
|
||||
-- Hash all 8 unit cube coordinates surrounding input coordinate
|
||||
local A, AA, AB, AAA, ABA, AAB, ABB, B, BA, BB, BAA, BBA, BAB, BBB
|
||||
A = p[xi ] + yi
|
||||
AA = p[A ] + zi
|
||||
AB = p[A+1 ] + zi
|
||||
AAA = p[ AA ]
|
||||
ABA = p[ AB ]
|
||||
AAB = p[ AA+1 ]
|
||||
ABB = p[ AB+1 ]
|
||||
A = p[xi] + yi
|
||||
AA = p[A] + zi
|
||||
AB = p[A + 1] + zi
|
||||
AAA = p[AA]
|
||||
ABA = p[AB]
|
||||
AAB = p[AA + 1]
|
||||
ABB = p[AB + 1]
|
||||
|
||||
B = p[xi+1] + yi
|
||||
BA = p[B ] + zi
|
||||
BB = p[B+1 ] + zi
|
||||
BAA = p[ BA ]
|
||||
BBA = p[ BB ]
|
||||
BAB = p[ BA+1 ]
|
||||
BBB = p[ BB+1 ]
|
||||
B = p[xi + 1] + yi
|
||||
BA = p[B] + zi
|
||||
BB = p[B + 1] + zi
|
||||
BAA = p[BA]
|
||||
BBA = p[BB]
|
||||
BAB = p[BA + 1]
|
||||
BBB = p[BB + 1]
|
||||
|
||||
-- Take the weighted average between all 8 unit cube coordinates
|
||||
return lerp(w,
|
||||
lerp(v,
|
||||
lerp(u,
|
||||
grad(AAA,x,y,z),
|
||||
grad(BAA,x-1,y,z)
|
||||
),
|
||||
lerp(u,
|
||||
grad(ABA,x,y-1,z),
|
||||
grad(BBA,x-1,y-1,z)
|
||||
)
|
||||
),
|
||||
lerp(v,
|
||||
lerp(u,
|
||||
grad(AAB,x,y,z-1), grad(BAB,x-1,y,z-1)
|
||||
),
|
||||
lerp(u,
|
||||
grad(ABB,x,y-1,z-1), grad(BBB,x-1,y-1,z-1)
|
||||
)
|
||||
)
|
||||
)
|
||||
return lerp(w, lerp(v, lerp(u, grad(AAA, x, y, z), grad(BAA, x - 1, y, z)), lerp(u, grad(ABA, x, y - 1, z), grad(BBA, x - 1, y - 1, z))), lerp(v, lerp(u, grad(AAB, x, y, z - 1), grad(BAB, x - 1, y, z - 1)), lerp(u, grad(ABB, x, y - 1, z - 1), grad(BBB, x - 1, y - 1, z - 1))))
|
||||
end
|
||||
|
||||
return Perlin
|
||||
|
@ -3,7 +3,7 @@ local Game = require 'utils.game'
|
||||
|
||||
local mines_factor = 1
|
||||
|
||||
mines_factor_sq = 16384 * 16384 / mines_factor / mines_factor
|
||||
local mines_factor_sq = 16384 * 16384 / mines_factor / mines_factor
|
||||
|
||||
local death_messages = {
|
||||
"went exploring, and didn't bring a minesweeping kit.",
|
||||
|
@ -8,7 +8,7 @@ end
|
||||
|
||||
Event.on_init(init)
|
||||
|
||||
return function(x, y, world)
|
||||
return function(x, y)
|
||||
local wiggle = 50 + perlin.noise((x * 0.005), (y * 0.005), global.terrain_seed_A + 71) * 60
|
||||
local terrain_A = perlin.noise((x * 0.005), (y * 0.005), global.terrain_seed_A + 19) * wiggle --For determining where water is
|
||||
local terrain_sqr = terrain_A * terrain_A --we can use this again to mess with other layers as well
|
||||
|
@ -3,24 +3,24 @@ local small_worm_spawn_distance = 100
|
||||
local medium_worm_spawn_distance = 150
|
||||
local big_worm_spawn_distance = 200
|
||||
|
||||
local worm_names = {"small-worm-turret", "medium-worm-turret", "big-worm-turret"}
|
||||
local worm_names = {'small-worm-turret', 'medium-worm-turret', 'big-worm-turret'}
|
||||
|
||||
local chance = worms_per_chunk / (32 * 32)
|
||||
|
||||
return function(x, y, world)
|
||||
local distance = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
return function(_, _, world)
|
||||
local distance = math.sqrt(world.x * world.x + world.y * world.y)
|
||||
|
||||
if distance > small_worm_spawn_distance - 32 then
|
||||
local lvl = 1
|
||||
if distance > medium_worm_spawn_distance then
|
||||
lvl = 2
|
||||
if distance > small_worm_spawn_distance - 32 then
|
||||
local lvl = 1
|
||||
if distance > medium_worm_spawn_distance then
|
||||
lvl = 2
|
||||
end
|
||||
if distance > big_worm_spawn_distance then
|
||||
lvl = 3
|
||||
end
|
||||
if math.random() < chance then
|
||||
local worm_id = math.random(1, lvl)
|
||||
return {name = worm_names[worm_id]}
|
||||
end
|
||||
end
|
||||
if distance > big_worm_spawn_distance then
|
||||
lvl = 3
|
||||
end
|
||||
if math.random() < chance then
|
||||
local worm_id = math.random(1, lvl)
|
||||
return {name = worm_names[worm_id]}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,59 +1,57 @@
|
||||
return {
|
||||
|
||||
'Benjamin Franklin wanted the turkey to be the national bird, not the eagle.',
|
||||
'There was no turkey on the menu at the first Thanksgiving.',
|
||||
'Thanksgiving is the reason for TV dinners!',
|
||||
'Wild turkeys can run 20 miles per hour when they are scared.',
|
||||
'Female turkeys (called hens) do not gobble.',
|
||||
'The real first Thanksgiving was held in Texas in 1541.',
|
||||
'Baby turkeys are called poults.',
|
||||
'The best way to tell if a cranberry is ripe it to see if it bounces.',
|
||||
'Benjamin Franklin wanted the turkey to be the national bird, not the eagle.',
|
||||
'There was no turkey on the menu at the first Thanksgiving.',
|
||||
'Thanksgiving is the reason for TV dinners!',
|
||||
'Wild turkeys can run 20 miles per hour when they are scared.',
|
||||
'Female turkeys (called hens) do not gobble.',
|
||||
'The real first Thanksgiving was held in Texas in 1541.',
|
||||
'Baby turkeys are called poults.',
|
||||
'The best way to tell if a cranberry is ripe it to see if it bounces.',
|
||||
'There were no forks at the first Thanksgiving. ',
|
||||
'Thomas Jefferson refused to declare Thanksgiving as a holiday.',
|
||||
'About 46 million turkeys are cooked for Thanksgiving each year.',
|
||||
'The Butterball Turkey Talk Line answers almost 100,000 calls each season.',
|
||||
'There are four places in the US named Turkey.',
|
||||
'Black Friday is the busiest day of the year for plumbers.',
|
||||
'Jingle Bells was originally a Thanksgiving song.',
|
||||
'Turkey-like creatures roamed the Americas 75 million years ago.',
|
||||
'Canadian Thanksgiving predates American Thanksgiving by 43 years.',
|
||||
'On average, it takes about 7 hours to cook a Thanksgiving dinner. People spend about 16 minutes eating it.',
|
||||
'The first Thanksgiving was held in the autumn of 1621',
|
||||
'Why did the turkey cross the road? It was Thanksgiving and he wanted to convince people he was a chicken.',
|
||||
'What did the turkey say to the computer? "Google, google, google."',
|
||||
'Why did the farmer separate the turkey and the chicken? He sensed fowl play.',
|
||||
'What music did the Pilgrims listen to? Plymouth rock.',
|
||||
'If Pilgrims were alive today what would they be known for? Their age!',
|
||||
'What does Miley Cyrus eat for Thanksgiving? Twerky.',
|
||||
'If your great-grandmother saw you making boxed mashed potatoes shed turn over in her gravy.',
|
||||
'What does a turkey drink from? A gobble-t.',
|
||||
'What smells best at Thanksgiving dinner? Your nose.',
|
||||
'Thanksgiving is the only holiday where you eat the mascot.',
|
||||
'How do you keep a turkey in suspense? Ill tell you later.',
|
||||
'My family told me to stop telling bad Thanksgiving jokes, but I couldnt just quit cold turkey.',
|
||||
'What kind of music did the Pilgrims like? Plymouth Rock ',
|
||||
'If April showers bring May flowers, what do May flowers bring? Pilgrims ',
|
||||
'Why cant you take a turkey to church? They use FOWL language. ',
|
||||
'Why was the Thanksgiving soup so expensive? It had 24 carrots. ',
|
||||
'What happened when the turkey got into a fight? He got the stuffing knocked out of him! ',
|
||||
'What do you get when you cross a turkey with a banjo? A turkey that can pluck itself! ',
|
||||
'When do you serve tofu turkey? Pranksgiving. ',
|
||||
'What did the turkey say to the man who tried to shoot it? Liberty, Equality and Bad aim for all. ',
|
||||
'Who doesnt eat on Thanksgiving? A turkey because it is always stuffed. ',
|
||||
'Why did the Pilgrims want to sail to America in the spring? Because April showers bring Mayflowers! ',
|
||||
'What did baby corn say to mama corn? Wheres popcorn? ',
|
||||
'If the Pilgrims were alive today, what would they be most famous for? Their AGE! ',
|
||||
'Why do the pants of pilgrims keep falling down? Because their belt buckles are on their hats! ',
|
||||
'Why did they let the turkey join the band? Because he had the drumsticks ',
|
||||
'What does Miley Cyrus eat for Thanksgiving? Twerk-ey! ',
|
||||
'What did the mother turkey say to her disobedient children? "If your father could see you now, hed turn over in his gravy!" '
|
||||
|
||||
'Benjamin Franklin wanted the turkey to be the national bird, not the eagle.',
|
||||
'There was no turkey on the menu at the first Thanksgiving.',
|
||||
'Thanksgiving is the reason for TV dinners!',
|
||||
'Wild turkeys can run 20 miles per hour when they are scared.',
|
||||
'Female turkeys (called hens) do not gobble.',
|
||||
'The real first Thanksgiving was held in Texas in 1541.',
|
||||
'Baby turkeys are called poults.',
|
||||
'The best way to tell if a cranberry is ripe it to see if it bounces.',
|
||||
'Benjamin Franklin wanted the turkey to be the national bird, not the eagle.',
|
||||
'There was no turkey on the menu at the first Thanksgiving.',
|
||||
'Thanksgiving is the reason for TV dinners!',
|
||||
'Wild turkeys can run 20 miles per hour when they are scared.',
|
||||
'Female turkeys (called hens) do not gobble.',
|
||||
'The real first Thanksgiving was held in Texas in 1541.',
|
||||
'Baby turkeys are called poults.',
|
||||
'The best way to tell if a cranberry is ripe it to see if it bounces.',
|
||||
'There were no forks at the first Thanksgiving. ',
|
||||
'Thomas Jefferson refused to declare Thanksgiving as a holiday.',
|
||||
'About 46 million turkeys are cooked for Thanksgiving each year.',
|
||||
'The Butterball Turkey Talk Line answers almost 100,000 calls each season.',
|
||||
'There are four places in the US named Turkey.',
|
||||
'Black Friday is the busiest day of the year for plumbers.',
|
||||
'Jingle Bells was originally a Thanksgiving song.',
|
||||
'Turkey-like creatures roamed the Americas 75 million years ago.',
|
||||
'Canadian Thanksgiving predates American Thanksgiving by 43 years.',
|
||||
'On average, it takes about 7 hours to cook a Thanksgiving dinner. People spend about 16 minutes eating it.',
|
||||
'The first Thanksgiving was held in the autumn of 1621',
|
||||
'Why did the turkey cross the road? It was Thanksgiving and he wanted to convince people he was a chicken.',
|
||||
'What did the turkey say to the computer? "Google, google, google."',
|
||||
'Why did the farmer separate the turkey and the chicken? He sensed fowl play.',
|
||||
'What music did the Pilgrims listen to? Plymouth rock.',
|
||||
'If Pilgrims were alive today what would they be known for? Their age!',
|
||||
'What does Miley Cyrus eat for Thanksgiving? Twerky.',
|
||||
'If your great-grandmother saw you making boxed mashed potatoes shed turn over in her gravy.',
|
||||
'What does a turkey drink from? A gobble-t.',
|
||||
'What smells best at Thanksgiving dinner? Your nose.',
|
||||
'Thanksgiving is the only holiday where you eat the mascot.',
|
||||
'How do you keep a turkey in suspense? Ill tell you later.',
|
||||
'My family told me to stop telling bad Thanksgiving jokes, but I couldnt just quit cold turkey.',
|
||||
'What kind of music did the Pilgrims like? Plymouth Rock ',
|
||||
'If April showers bring May flowers, what do May flowers bring? Pilgrims ',
|
||||
'Why cant you take a turkey to church? They use FOWL language. ',
|
||||
'Why was the Thanksgiving soup so expensive? It had 24 carrots. ',
|
||||
'What happened when the turkey got into a fight? He got the stuffing knocked out of him! ',
|
||||
'What do you get when you cross a turkey with a banjo? A turkey that can pluck itself! ',
|
||||
'When do you serve tofu turkey? Pranksgiving. ',
|
||||
'What did the turkey say to the man who tried to shoot it? Liberty, Equality and Bad aim for all. ',
|
||||
'Who doesnt eat on Thanksgiving? A turkey because it is always stuffed. ',
|
||||
'Why did the Pilgrims want to sail to America in the spring? Because April showers bring Mayflowers! ',
|
||||
'What did baby corn say to mama corn? Wheres popcorn? ',
|
||||
'If the Pilgrims were alive today, what would they be most famous for? Their AGE! ',
|
||||
'Why do the pants of pilgrims keep falling down? Because their belt buckles are on their hats! ',
|
||||
'Why did they let the turkey join the band? Because he had the drumsticks ',
|
||||
'What does Miley Cyrus eat for Thanksgiving? Twerk-ey! ',
|
||||
'What did the mother turkey say to her disobedient children? "If your father could see you now, hed turn over in his gravy!" '
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user