-
Notifications
You must be signed in to change notification settings - Fork 10
/
control.lua
215 lines (182 loc) · 7.6 KB
/
control.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
if not script.active_mods['pylandblock'] then
script.on_init(function(event)
if remote.interfaces['freeplay'] then
local created_items = remote.call('freeplay', 'get_created_items')
created_items['landfill'] = 1000
created_items['stone'] = 400
created_items['log'] = 500
created_items["iron-plate"] = 1000
created_items["copper-plate"] = 1000
created_items['py-tank-1000'] = 1
created_items['py-tank-3000'] = 1
created_items['py-tank-5000'] = 1
created_items['py-tank-8000'] = 1
created_items["stone-furnace"] = 1
created_items["py-sinkhole"] = 2
created_items["py-gas-vent"] = 2
remote.call('freeplay', 'set_created_items', created_items)
--local debris_items = remote.call("freeplay", "get_debris_items")
--debris_items["stone-furnace"] = 1
--debris_items["py-sinkhole"] = 2
--debris_items["py-gas-vent"] = 2
--debris_items["scrap-iron"] = 400
--remote.call("freeplay", "set_debris_items", debris_items)
end
end)
--[[
local Rocks = {
'iron-rock', 'copper-rock', 'uranium-rock', 'zinc-rock', 'aluminium-rock', 'chromium-rock', 'coal-rock',
'lead-rock', 'nexelit-rock', 'nickel-rock', 'phosphate-rock-02', 'quartz-rock', 'salt-rock', 'tin-rock',
'titanium-rock', 'volcanic-pipe', 'regolites', 'rare-earth-bolide', 'phosphate-rock', 'sulfur-patch',
'bitumen-seep'
}
-- local firstrock = true
local loot_table_fuelrod = {'fuelrod-mk01', 'fuelrod-mk02', 'fuelrod-mk03', 'fuelrod-mk04', 'fuelrod-mk05'}
local loot_table_plates = {
'iron-plate', 'copper-plate', 'duralumin', 'steel-plate', 'pb-wrought-iron-plate', 'chromium', 'super-steel',
'landfill'
}
local loot_table_basic_mats = {
'stone', 'wood', 'stone-brick', 'iron-ore', 'ore-aluminium', 'ore-nickel', 'ore-quartz', 'ore-zinc',
'ore-titanium', 'ore-chromium', 'raw-coal'
}
]]--
--[[
script.on_event(defines.events.on_chunk_generated, function(event)
-- getting chunk bounds
local tx = event.area.left_top.x
local ty = event.area.left_top.y
local bx = event.area.right_bottom.x
local by = event.area.right_bottom.y
-- log(serpent.block(event.area))
-- do first delete everything in the chunk + set it to water only
if tx == -32 and ty == -32 then
-- log("was start chunk")
-- log(serpent.block(event.area))
elseif tx == -32 and ty == 0 then
-- log("was start chunk")
-- log(serpent.block(event.area))
elseif tx == 0 and ty == -32 then
-- log("was start chunk")
-- log(serpent.block(event.area))
elseif tx == 0 and ty == 0 then
-- log("was start chunk")
-- log(serpent.block(event.area))
else
local crap = game.surfaces['nauvis'].find_entities({{tx, ty}, {bx, by}})
for _, c in pairs(crap) do
-- log(serpent.block(c))
-- log(serpent.block(c.name))
-- log(serpent.block(c.position))
if c.valid == true and c.name ~= 'iron-rock' and c.name ~= 'seaweed' and c.name ~= 'fish' then
-- log('destroying')
c.destroy()
end
end
local oldtiles = {}
local waters = {
'water', 'deepwater'
-- "deepwater-green",
-- "water-green",
-- "water-shallow",
-- "water-mud",
}
local fx = tx
local fy = ty
for i = 0, 1024 do
-- check for landfill from another chunk and dont replace
if game.surfaces['nauvis'].get_tile(fx, fy).name == 'landfill' then
else
-- local ent = game.surfaces["nauvis"].find_entities({{fx,fy},{fx,fy}})
-- for _, e in pairs(ent) do
-- log(e.name)
-- if e.name == "iron-rock" then
-- else
table.insert(oldtiles, {name = waters[math.random(1, 2)], position = {fx, fy}})
-- end
-- end
end
fx = fx + 1
if fx == tx + 32 then
fx = tx
fy = fy + 1
end
end
game.surfaces['nauvis'].set_tiles(oldtiles)
local crap = game.surfaces['nauvis'].find_entities({{tx, ty}, {bx, by}})
for _, c in pairs(crap) do
-- log(serpent.block(c.name))
if c.name ~= 'fish' and c.name ~= 'seaweed' then c.destroy() end
end
-- end
end
-- setting stuff in chunk
local SelectedRock = math.random(1, 21)
local Randx = math.random(tx + 7, bx - 7)
local Randy = math.random(ty + 7, by - 7)
local tiles = {}
local x = Randx - 7
local y = Randy - 7
local a = 0
local b = 0
local RandChance
if global.firstrock == true then
SelectedRock = 1
RandChance = math.random(0, 30)
elseif global.secondrock == true and global.firstrock == false then
SelectedRock = 2
RandChance = math.random(0, 30)
else
RandChance = math.random(0, 240)
end
if RandChance == 5 then
for i = 0, 169 do
table.insert(tiles, {name = 'landfill', position = {x, y}})
x = x + 1
a = a + 1
if a == 13 then
x = x - 13
y = y + 1
b = b + 1
a = 0
if b == 13 then
y = y - 13
b = 0
end
end
end
game.surfaces['nauvis'].set_tiles(tiles)
local rock = Rocks[SelectedRock]
if rock == 'bitumen-seep' then
amount = math.random(1000, 2500)
else
amount = math.random(250000, 1000000)
end
game.surfaces['nauvis'].create_entity{name = rock, position = {Randx, Randy}, amount = amount}
if global.firstrock == true then
global.firstrock = false
elseif global.firstrock == false and global.secondrock == true then
global.secondrock = false
end
end
if RandChance == 6 then
local ship = game.surfaces['nauvis'].create_entity{
name = crashedshipparts[math.random(1, 3)],
position = {math.random(tx + 3, bx - 3), math.random(ty + 3, by - 3)},
force = game.forces.player
}
local loot_rand_pick = math.random(1, 25)
if loot_rand_pick > 20 and loot_rand_pick <= 25 then
local rand = math.random(1, 5)
ship.insert({name = loot_table_fuelrod[rand], count = math.random(1, 6)})
elseif loot_rand_pick > 10 and loot_rand_pick < 20 then
local rand = math.random(1, 8)
ship.insert({name = loot_table_plates[rand], count = math.random(25, 100)})
elseif loot_rand_pick > 0 and loot_rand_pick < 10 then
local rand = math.random(1, 11)
ship.insert({name = loot_table_basic_mats[rand], count = math.random(100, 500)})
end
end
end)
]]--
end