forked from DustyDave961/rainbow_source
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
170 lines (161 loc) · 5.2 KB
/
Copy pathinit.lua
File metadata and controls
170 lines (161 loc) · 5.2 KB
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
--table in case setting names break something
rainbow_source = {}
--Water definitions
local source_list = {
{"black", "Darkened", "292421", 40, 36, 33},
{"blue", "Blue", "0000FF", 0, 0, 255},
{"cyan", "Cyan", "00FFFF", 0, 255, 255},
{"green", "Green", "00FF00", 0, 255, 0},
{"magenta", "Magenta", "FF00FF", 255, 0, 255},
{"orange", "Orange", "FF6103", 255, 97, 3},
{"purple", "Purple", "800080", 128, 0, 128, "violet"},
{"red", "Red", "FF0000", 255, 0, 0},
{"yellow", "Yellow", "FFFF00", 255, 255, 0},
{"frosted", "Frosted", "FFFFFF", 255, 255, 255, "white"}
}
--renewable liquid setting value for Your Land thanks to tour_ist
local liquid_renewable = core.settings:get_bool("rainbow_source.liquid_renewable", false)
-- Enable buckets
-- Set this to true if you want to enable buckets, set this to false to disable them
-- Optional, default true
local enable_buckets = core.settings:get_bool(rainbow_source.enable_buckets, true)
for i in ipairs(source_list) do
local name = source_list[i][1]
local description = source_list[i][2]
local colour = source_list[i][3]
local red = source_list[i][4]
local green = source_list[i][5]
local blue = source_list[i][6]
local dye = source_list[i][7] or name
--Register water source nodes. New textures thanks to tour_ist
core.register_node("rainbow_source:"..name.."_water_source", {
description = description.." Water Source",
drawtype = "liquid",
tiles = {
{
name = "default_water_source_animated.png^[hsl:0:-100:0^[colorize:#"..colour..":70",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
},
special_tiles = {
{
name = "default_water_source_animated.png^[hsl:0:-100:0^[colorize:#"..colour..":70",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
backface_culling = false,
},
},
use_texture_alpha = "blend",
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "source",
liquid_alternative_flowing = "rainbow_source:"..name.."_water_flowing",
liquid_alternative_source = "rainbow_source:"..name.."_water_source",
liquid_viscosity = 1,
liquid_renewable = liquid_renewable,
post_effect_color = {a = 50, r = red, g = green, b = blue},
groups = {water = 3, liquid = 3, puts_out_fire = 1,
cools_lava = 1},
sounds = default.node_sound_water_defaults(),
})
--Register flowing water nodes
core.register_node("rainbow_source:"..name.."_water_flowing", {
description = description.." Flowing Water",
drawtype = "flowingliquid",
tiles = {"default_water.png^[hsl:0:-100:0^[colorize:#"..colour..":70"},
special_tiles = {
{
name = "default_water_flowing_animated.png^[hsl:0:-100:0^[colorize:#"..colour..":70",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
{
name = "default_water_flowing_animated.png^[hsl:0:-100:0^[colorize:#"..colour..":70",
backface_culling = true,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 0.8,
},
},
},
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
drop = "",
drowning = 1,
liquidtype = "flowing",
liquid_alternative_flowing = "rainbow_source:"..name.."_water_flowing",
liquid_alternative_source = "rainbow_source:"..name.."_water_source",
liquid_viscosity = 1,
liquid_renewable = liquid_renewable,
post_effect_color = {a = 50, r = red, g = green, b = blue},
groups = {water = 3, liquid = 3, puts_out_fire = 1,
not_in_creative_inventory = 1, cools_lava = 1},
sounds = default.node_sound_water_defaults(),
})
--[[-------------------------------------
--Buckets (new feature by DustyDave961)--
---------------------------------------]]
if enable_buckets == true then
--Register buckets with fluid_lib function
if core.get_modpath("bucket_compat") then
fluid_lib.register_liquid(
"rainbow_source:"..name.."_water_source",
"rainbow_source:"..name.."_water_flowing",
"rainbow_source:bucket_"..name.."_water",
"#"..colour,
description.." Water Bucket",
{tool = 1, water_bucket = 1}
)
--Add buckets even without bucket_compat
elseif core.get_modpath("bucket") then
bucket.register_liquid(
"rainbow_source:"..name.."_water_source",
"rainbow_source:"..name.."_water_flowing",
"rainbow_source:bucket_"..name.."_water",
"rs_bucket.png^(bucket_mask.png^[colorize:#"..colour..":70)",
description.." Water Bucket",
{tool = 1, water_bucket = 1}
)
end
--Register crafting recipes if dye is present and crafting setting is enabled
if core.get_modpath("dye") and core.settings:get_bool("rainbow_source.bucket_crafts") then
if core.get_modpath("bucket") or core.get_modpath("bucket_compat") then
core.register_craft({
output = "rainbow_source:bucket_"..name.."_water",
recipe = {
{"dye:"..dye},
{"group:water_bucket"}
}
})
end
end
end
end