forked from stujones11/hovercraft
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.lua
103 lines (88 loc) · 2.17 KB
/
init.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
hover = {}
hover.modname = core.get_current_modname()
hover.modpath = core.get_modpath(hover.modname)
dofile(hover.modpath .. "/settings.lua")
dofile(hover.modpath .. "/hover.lua")
local S = core.get_translator("hovercraft")
local hover_colors = {
red = {
max_speed = 10,
jump_vel = 4.0,
fall_vel = 1.0,
bounce = 0.5,
},
blue = {
max_speed = 12,
decel = 0.1,
jump_vel = 4.0,
fall_vel = 1.0,
bounce = 0.8,
},
green = {
decel = 0.15,
jump_vel = 5.5,
fall_vel = 1.5,
bounce = 0.5,
},
yellow = {},
}
if core.settings:get_bool("hovercraft.extended_colors", true) then
for _, color in ipairs({"white", "black", "grey", "dark_grey", "cyan",
"orange", "brown", "pink", "magenta", "violet", "dark_green"}) do
hover_colors[color] = {
max_speed = 12,
accel = 0.25,
decel = 0.05,
jump_vel = 3.0,
fall_vel = 0.5,
bounce = 0.25,
}
end
end
for color, c_def in pairs(hover_colors) do
local title = ""
local whitespace = true
for idx=1, #color do
local c = color:sub(idx, idx)
if whitespace then
c = c:upper()
whitespace = false
end
if c == "_" then
c = " "
whitespace = true
end
title = title .. c
end
hover:register_hovercraft(":hovercraft:hover_" .. color, {
description = S(title .. " Hovercraft"),
textures = {"hovercraft_" .. color .. ".png"},
inventory_image = "hovercraft_" .. color .. "_inv.png",
max_speed = c_def.max_speed or 8,
acceleration = c_def.accel or 0.25,
deceleration = c_def.decel or 0.05,
jump_velocity = c_def.jump_vel or 3.0,
fall_velocity = c_def.fall_vel or 0.5,
bounce = c_def.bounce or 0.25,
})
end
local ing = {
motor = core.registered_items["basic_materials:motor"]
and "basic_materials:motor" or "",
block = "default:steelblock",
wool_base = "wool:black",
}
if core.registered_items[ing.block] and core.registered_items[ing.wool_base] then
for color in pairs(hover_colors) do
if core.registered_items["wool:" .. color] then
core.register_craft({
output = "hovercraft:hover_" .. color,
recipe = {
{"", ing.motor, ing.block},
{"wool:" .. color, "wool:" .. color, "wool:" .. color},
{ing.wool_base, ing.wool_base, ing.wool_base},
},
})
end
end
end