Spell Check and Lua Check

This commit is contained in:
Cooldude2606
2019-01-11 22:32:30 +00:00
parent 7110b76444
commit 082d9e5439
65 changed files with 760 additions and 724 deletions

View File

@@ -1,19 +1,19 @@
--- Makes paths which wear down and paths where entites are placed.
--- Makes paths which wear down and paths where entities are placed.
-- @module WornPaths@^4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
-- @alais ThisModule
-- @alias ThisModule
-- Module Require
local Game = require('FactorioStdLib.Game')
-- Local Varibles
local entites = require(module_path..'/src/entites')
-- Local Variables
local entities = require(module_path..'/src/entites')
local paths = require(module_path..'/src/paths')
for tile,value in pairs(paths) do value[1]=-1/value[1] end
for _,value in pairs(paths) do value[1]=-1/value[1] end
local placed_paths = require(module_path..'/src/placed')
local adjacency_boost = 2 -- makes paths more lickly to be next to each other; must be greater than 0
local adjacency_boost = 2 -- makes paths more likely to be next to each other; must be greater than 0
adjacency_boost = 10/adjacency_boost -- dont change this line
-- Module Define
@@ -28,7 +28,7 @@ local function global_key(surface,pos)
return 'S'..surface.name..'X'..math.floor(pos.x)..'Y'..math.floor(pos.y)
end
--- Downgrads a tile in this position
--- Downgrades a tile in this position
-- @usage ThisModule.down_grade(surface,{x=10,y=10})
-- @tparam surface surface the surface the tile is on
-- @tparam table pos the position of the tile to change
@@ -36,7 +36,7 @@ function ThisModule.down_grade(surface,pos)
local tile = surface.get_tile(pos).name
local new_tile = paths[tile][2]
if new_tile == 'world-gen' then
new_tile = global[global_key(surface,pos)] or 'grass-1'
new_tile = global[global_key(surface,pos)] or 'grass-1'
end
surface.set_tiles{{name=new_tile,position=pos}}
end
@@ -46,15 +46,15 @@ script.on_event({defines.events.on_player_built_tile,defines.events.on_robot_bui
local surface = event.surface_index and game.surfaces[event.surface_index] or event.robot and event.robot.surface
local old_tiles = event.tiles
for _,old_tile in pairs(old_tiles) do
if placed_paths[old_tile.old_tile.name] or old_tile.old_tile.name == 'water' or old_tile.old_tile.name == 'deepwater' then else
global[global_key(surface,old_tile.position)]=old_tile.old_tile.name -- not a mistake, this makes it have dimising returns
if not placed_paths[old_tile.old_tile.name] and old_tile.old_tile.name ~= 'water' and old_tile.old_tile.name ~= 'deepwater' then
global[global_key(surface,old_tile.position)]=old_tile.old_tile.name -- not a mistake, this makes it have demising returns
end
end
end)
script.on_event(defines.events.on_player_changed_position, function(event)
local player = Game.get_player(event)
if player and player.valid and game.tick > 10 then else return end
if not player or not player.valid or game.tick < 10 then return end
if player.afk_time > 300 then return end
local surface = player.surface
local pos = player.position
@@ -76,7 +76,7 @@ end)
script.on_event({defines.events.on_built_entity,on_robot_built_entity}, function(event)
local entity = event.created_entity
local surface = entity.surface
if entites[entity.name] then
if entities[entity.name] then
local box = entity.prototype.collision_box
for x = box.left_top.x,box.right_bottom.x do for y = box.left_top.y,box.right_bottom.y do
local pos = {x=entity.position.x+x,y=entity.position.y+y}
@@ -87,17 +87,17 @@ script.on_event({defines.events.on_built_entity,on_robot_built_entity}, function
end)
-- Module Return
-- when called it will downgrade a tile
return setmetatable(ThisModule,{__call=function(self,...) self.down_grade(...) end})
return setmetatable(ThisModule,{__call=function(self,...) self.down_grade(...) end})
--[[
/interface
local tile_name = surface.get_tile(position).name
/interface
local tile_name = surface.get_tile(position).name
if not paths[tile_name] then return end
local count = -9 -- this value is important
for x = -1,1 do for y = -1,1 do
local _pos = {position.x+x,position.y+y}
if placed_paths[tile_name] and not placed_paths[surface.get_tile(_pos).name]
or surface.get_tile(_pos).name == paths[tile_name][2]
if placed_paths[tile_name] and not placed_paths[surface.get_tile(_pos).name]
or surface.get_tile(_pos).name == paths[tile_name][2]
then count=count+1 end
end end
return paths[tile_name][1]/(count-adjacency_boost)