-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.lua
87 lines (74 loc) · 2.95 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
-------------------------------------------------------
--[[
Some helper functions for the frequency, size, richness tables
]]
local function PCR(f,z,r) return {frequency=f or 1,size=z or f or 1,richness=r or f or 1} end
local function PCRMul(a,b) if(type(b)=="table")then
return {frequency=(a.frequency or 1)*(b.frequency or 1),size=(a.size or 1)*(b.size or 1),richness=(a.richness or 1)*(b.richness or 1)} else
return {frequency=(a.frequency or 1)*(b or 1),size=(a.size or 1)*(b or 1),richness=(a.richness or 1)*(b or 1)}
end end
-------------------------------------------------------
--[[
Here is the actual planet table
Many of the tile lines are commented due to debugging and testing tile autoplacement, and is not yet finished.
]]
local swamp={
key="swamp",name="A Swamp Planet",zone=22,rng=settings.startup["warptorio_planetpack_swamp"].value,
desc="The platform lands with an unusual squish, and in the distance only for a moment, you could have sworn you just saw a disgruntled ogre.",
modifiers={
{"nauvis",{tiles={"grass","dirt","water"}}},
--{"tile_nauvis",{"dirt",true}},
--{"tile_nauvis",{"grass",true}},
--{"tile_nauvis",{"water",true}},
{"tile_nauvis",{"dry%-dirt",false}},
{"tile_mod",{"water%-green",true}},
{"tile_mod_expr",{"water%-green","probability",nil}},
{"moisture",0.125},
{"aux",0.25},
--{"tile_mod_expr",{"water%-green","probability",1}},
--{"tile_mod_expr",{"water%-green","coverage",-2}},
--{"tile_mod_expr",{"water%-green","sharpness",-1}},
--{"tile_mod_expr",{"water%-green","max_probability",0.8}},
--{"tile_nauvis_expr",{"grass","probability",0.45}},
--{"tile_nauvis_expr",{"dirt","probability",0.45}},
{"water",1},
{"starting_area",0.5},
{"resource_set",{["crude-oil"]=PCR(3,2,1),["coal"]=PCR(3,2,1),}},
{"biters",2},
},
required_controls={"coal","crude-oil"},
fgen_call={"warptorio_planet_pack","fgenSwamp"},
spawn_call={"warptorio_planet_pack","spawnSwamp"},
}
-------------------------------------------------------
--[[
Surface Map Generation calls
Some dynamic changes to the planet generation table, or scripted changes, or both?
]]
function fgenSwamp(g)
for _,ore in pairs(remote.call("warptorio","getresources"))do
if(ore~="crude-oil" and ore~="coal")then
g.autoplace_controls[ore]=PCRMul(g.autoplace_controls[ore] or PCR(1),math.random(30,75)/100)
end
end
return g
end
function spawnSwamp(f,g,chart)
f.daytime=0.25
f.freeze_daytime=1
end
remote.add_interface("warptorio_planet_pack",{
["fgenSwamp"]=fgenSwamp,
["spawnSwamp"]=spawnSwamp,
})
-------------------------------------------------------
--[[
Register the planet with warptorio
]]
local function RegisterPlanets()
remote.call("warptorio","registerplanet",swamp)
remote.call("warptorio","tiledefault","deepwater-green",false)
remote.call("warptorio","tiledefault","water-green",false)
end
script.on_init(RegisterPlanets)
script.on_load(RegisterPlanets)