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
|
local lib = starlit.mod.lib
do -- chemlamp
local burnTime = 60*60
local maxBright = 12
local stages = maxBright
local stageTimeout = burnTime / stages
local function chemLampID(n)
if n == stages then return 'starlit_tech:chem_lamp' end
return string.format('starlit_tech:chem_lamp_%s',n)
end
local fab = starlit.type.fab {
element = { carbon = 4, magnesium = 1 };
cost = { power = 100 };
flag = { print = true };
time = { print = 5 };
};
for i = stages, 0, -1 do
minetest.register_node(chemLampID(i), {
short_description = 'Chem Lamp';
description = starlit.ui.tooltip {
title = 'Chem Lamp';
desc = "A simple carbon-frame chemical light source powered by ambient oxygen. Cheap, quick to print, and biodedragable, without any need for an electric grid or complex power storage mechanism. However, the light only lasts a few days, after which the lamp must be recycled or discarded.";
color = lib.color(1,.4,.1);
props = {
{title = 'Burn Remaining', desc=lib.math.timespec(stageTimeout * i), affinity=i > 4 and 'good' or 'bad'};
{title = 'Mass', desc='10g', affinity='info'};
};
};
drawtype = 'nodebox';
groups = {
object = 1;
attached_node = 1;
};
node_box = {
type = 'fixed';
fixed = {
-.4, -.5, -.20;
.4, -.3, .20;
};
};
tiles = {
lib.image 'starlit-tech-lamp-glow.png'
:fade(1 - i/stages)
:blit(lib.image 'starlit-tech-lamp.png')
:render();
};
paramtype = 'light';
paramtype2 = 'wallmounted';
wallmounted_rotate_vertical = true;
light_source = math.floor(lib.math.lerp(i/stages, 0, maxBright));
on_construct = i ~= 0 and function(pos)
local t = minetest.get_node_timer(pos)
t:start(stageTimeout)
end or nil;
on_timer = i ~= 0 and function(pos)
local me = minetest.get_node(pos)
minetest.swap_node(pos, {name=chemLampID(i-1), param2=me.param2})
return i > 1
end or nil;
_starlit = {
mass = 10;
reverseEngineer = {
complexity = 1;
sw = 'starlit_tech:schematic_chem_lamp';
};
recover = starlit.type.fab {
element = {
carbon = 8;
magnesium = math.floor(lib.math.lerp(i/stages, 0, 2));
};
time = {
shred = .5;
shredPower = 2;
};
};
};
})
end
starlit.item.sw.link('starlit_tech:schematic_chem_lamp', {
name = 'Chem Lamp Schematic';
kind = 'schematic';
input = fab;
output = chemLampID(stages);
size = 32e6;
cost = {
cycles = 8e9;
ram = 16e6;
};
rarity = 1;
})
end
minetest.register_node('starlit_tech:crate', {
short_description = 'Crate';
description = starlit.ui.tooltip {
title = 'Crate';
desc = 'A sturdy but lightweight storage crate woven from graphene.';
props = { {title='Mass', affinity='info', desc='100g'} };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
<
<
<
|
|
|
<
<
<
<
<
|
>
>
>
>
|
|
>
|
|
|
<
>
|
>
>
|
<
<
<
<
|
|
|
|
|
|
<
>
>
>
|
|
<
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
local lib = starlit.mod.lib
local function mkBurnDown(def) -- chemlamp
local burnTime = def.time
local stages = def.stages or 10
local stageTimeout = burnTime / stages
local function stID(n)
if n == stages then return def.id end
return string.format('%s_%s',def.id,n)
end
local fab = def.fab
for i = stages, 0, -1 do
local grp = {
object = 1;
attached_node = 1;
}
if def.group then
for k,v in pairs(def.group((i/stages))) do grp[k]=v end
end
minetest.register_node(stID(i), {
short_description = def.name;
description = starlit.ui.tooltip {
title = def.name;
desc = def.desc;
color = def.color;
props = {
{title = 'Burn Remaining', desc=lib.math.timespec(stageTimeout * i), affinity=i > (stages/2) and 'good' or 'bad'};
{title = 'Mass', desc=lib.math.siUI('g', def.mass), affinity='info'};
};
};
drawtype = 'nodebox';
groups = grp;
node_box = {
type = 'fixed';
fixed = {
-(7/16), -.5, -(4/16);
(7/16), -.5 + (2/16), (4/16);
};
};
tiles = def.tile((i/stages));
paramtype = 'light';
paramtype2 = 'wallmounted';
wallmounted_rotate_vertical = true;
light_source = math.floor(lib.math.lerp(i/stages, 0, def.glow));
on_construct = i ~= 0 and function(pos)
local t = minetest.get_node_timer(pos)
t:start(stageTimeout)
if def.ctor then def.ctor(pos, (i/stages)) end
end or nil;
on_destruct = def.dtor and function(pos)
def.dtor(pos, (i/stages))
end or nil;
on_timer = i ~= 0 and function(pos)
local me = minetest.get_node(pos)
minetest.swap_node(pos, {name=stID(i-1), param2=me.param2})
return i > 1
end or nil;
_starlit = (function()
local meta = {
mass = def.mass;
reverseEngineer = {
complexity = 1;
sw = def.id .. '_schematic';
};
recover = def.mat
+ (def.fuel / (i/stages))
+ starlit.type.fab {
time = {
shred = .5;
shredPower = 2;
};
};
}
for k,v in pairs(def.meta and def.meta((i/stages)) or {}) do meta[k]=v end
return meta
end)();
})
end
starlit.item.sw.link(def.id .. '_schematic', {
name = def.name .. ' Schematic';
kind = 'schematic';
input = def.fab + def.mat + def.fuel;
output = stID(stages);
size = 32e6;
cost = {
cycles = 8e9;
ram = 16e6;
};
rarity = 1;
})
end
mkBurnDown {
id = 'starlit_tech:chem_lamp';
name = 'Chem Lamp';
desc = "A simple carbon-frame chemical light source powered by ambient oxygen. Cheap, quick to print, and biodedragable, without any need for an electric grid or complex power storage mechanism. However, the light only lasts a few days, after which the lamp must be recycled or discarded.";
stages = 12;
glow = 12;
time = 60*60;
mass = 10;
color = lib.color(1,.4,.1);
tile = function(f) return {
lib.image 'starlit-tech-lamp-glow.png'
:fade(f)
:blit(lib.image 'starlit-tech-lamp.png')
:render();
} end;
fab = starlit.type.fab {
cost = { power = 100 };
flag = { print = true };
time = { print = 5 };
};
mat = starlit.type.fab { element = { carbon = 4 }; };
fuel = starlit.type.fab { element = { magnesium = 1 }; };
}
mkBurnDown {
id = 'starlit_tech:chem_radiator';
name = 'Chem Radiator';
desc = "A simple carbon-frame chemical heat source powered by ambient oxygen. Cheap, quick to print, and biodedragable, without any need for an electric grid or complex power storage mechanism. However, the heat only lasts a few hours, after which the lamp must be recycled or discarded.";
stages = 12;
glow = 7;
time = 15*60;
mass = 10;
color = lib.color(1,.4,.1);
tile = function(f) return {
lib.image 'starlit-tech-lamp-glow.png'
:fade(f)
:blit(lib.image 'starlit-tech-lamp.png')
:tint{hue=0,sat=1,lum=.5}:render();
} end;
fab = starlit.type.fab {
cost = { power = 150 };
flag = { print = true };
time = { print = 10 };
};
mat = starlit.type.fab { element = { carbon = 4 }; };
fuel = starlit.type.fab { element = { magnesium = 2, iron = 2 }; };
group = function(f)
if f > 0
then return {radiator=1}
else return {}
end
end;
ctor = function(pos, f) starlit.region.radiator.scan(pos) end;
dtor = function(pos, f) starlit.region.radiator.unload(pos) end;
meta = function(f) return {
radiator = {
radius = function(pos)
return 2;
end;
radiate = function(rp, pos)
return 15 * f
end;
};
} end;
}
minetest.register_node('starlit_tech:crate', {
short_description = 'Crate';
description = starlit.ui.tooltip {
title = 'Crate';
desc = 'A sturdy but lightweight storage crate woven from graphene.';
props = { {title='Mass', affinity='info', desc='100g'} };
|