starlit  Diff

Differences From Artifact [cc61bb3736]:

To Artifact [33f1e7300a]:


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
--[[ {
	part = {
		['starlit_building:pipe'] = 'myMod:stage3';
	};
	tool = {
		['starlit:screwdriver'] = 'myMod:otherThing_stage1';
		['starlit:saw'] = function(node, tool)
			minetest.replace_node(node, {name='myMod:stage1'})
			minetest.drop_item(node, 'starlit_building:pipe')
		end;
		['myMod:laserWrench'] = {
			allow = function(node, tool) ... end;
			handle = function(node, tool) ... end;
		};
	};
} ]]
................................................................................
	if e.fab then
		scmID = string.format('%s_schematic', id)
		rev = {
			sw = scmID;
			complexity = e.complexity or 1;
		}
	end
	minetest.register_craftitem(id, {
		short_description = e.name;
		description = starlit.ui.tooltip {
			title = e.name;
			desc = e.desc;
			props = props;
		};
		stack_max = e.max or (e.mass and math.min(math.max(math.floor(500 / e.mass), 1), 500)) or 10;
		inventory_image = e.img;
		on_place = function(stack, luser, point)
			local node = minetest.get_node(point.under)
			local function tryBuild()
				local p = B.path[node.name]
				if not p then return nil end
				if (not p.part) or (not p.part[id]) then return nil end
				local n = p.part[id]
				local obj
				if type(n) == 'function' then
................................................................................
				else
					obj = ItemStack(n)
					stack:take_item(1)
				end
				local pname = obj:get_name()
				local stg = B.stage.db[pname]
				node.name = pname
				minetest.swap_node(point.under, node)
				-- TODO make a noise
				if stg.onBuild then
					stg.onBuild(point.under, luser, stack)
				end
				return stack
			end

................................................................................
				if not p then return nil end
				if type(p) == 'function' then
					p = p(stack, node, point)
					if p == nil then return nil end
				else
					stack:take_item(1)
				end
				minetest.rotate_and_place(ItemStack(p), luser, point, true)
				-- TODO make a noise
				return stack
			end

			return tryBuild() or tryBegin() or stack
		end;
		_starlit = {
................................................................................
	local grp = e.groups and table.copy(e.groups) or {}
	grp.stage = 1
	local meta = {
		stage = id;
		recover = e.recover;
	}
	for k,v in pairs(e.meta or {}) do meta[k] = v end
	minetest.register_node(id, {
		description = 'Construction';
		drawtype = (e.box  and 'nodebox')
		        or (e.mesh and 'mesh')
		        or 'regular';
		paramtype  = e.paramtype or (e.box or e.mesh or e.light) and 'light' or nil;
		paramtype2 = e.paramtype2 or 'none';
		tiles = e.tex;







|
|







 







|









|







 







|







 







|







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
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
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
--[[ {
	part = {
		['starlit_building:pipe'] = 'myMod:stage3';
	};
	tool = {
		['starlit:screwdriver'] = 'myMod:otherThing_stage1';
		['starlit:saw'] = function(node, tool)
			core.replace_node(node, {name='myMod:stage1'})
			core.drop_item(node, 'starlit_building:pipe')
		end;
		['myMod:laserWrench'] = {
			allow = function(node, tool) ... end;
			handle = function(node, tool) ... end;
		};
	};
} ]]
................................................................................
	if e.fab then
		scmID = string.format('%s_schematic', id)
		rev = {
			sw = scmID;
			complexity = e.complexity or 1;
		}
	end
	core.register_craftitem(id, {
		short_description = e.name;
		description = starlit.ui.tooltip {
			title = e.name;
			desc = e.desc;
			props = props;
		};
		stack_max = e.max or (e.mass and math.min(math.max(math.floor(500 / e.mass), 1), 500)) or 10;
		inventory_image = e.img;
		on_place = function(stack, luser, point)
			local node = core.get_node(point.under)
			local function tryBuild()
				local p = B.path[node.name]
				if not p then return nil end
				if (not p.part) or (not p.part[id]) then return nil end
				local n = p.part[id]
				local obj
				if type(n) == 'function' then
................................................................................
				else
					obj = ItemStack(n)
					stack:take_item(1)
				end
				local pname = obj:get_name()
				local stg = B.stage.db[pname]
				node.name = pname
				core.swap_node(point.under, node)
				-- TODO make a noise
				if stg.onBuild then
					stg.onBuild(point.under, luser, stack)
				end
				return stack
			end

................................................................................
				if not p then return nil end
				if type(p) == 'function' then
					p = p(stack, node, point)
					if p == nil then return nil end
				else
					stack:take_item(1)
				end
				core.rotate_and_place(ItemStack(p), luser, point, true)
				-- TODO make a noise
				return stack
			end

			return tryBuild() or tryBegin() or stack
		end;
		_starlit = {
................................................................................
	local grp = e.groups and table.copy(e.groups) or {}
	grp.stage = 1
	local meta = {
		stage = id;
		recover = e.recover;
	}
	for k,v in pairs(e.meta or {}) do meta[k] = v end
	core.register_node(id, {
		description = 'Construction';
		drawtype = (e.box  and 'nodebox')
		        or (e.mesh and 'mesh')
		        or 'regular';
		paramtype  = e.paramtype or (e.box or e.mesh or e.light) and 'light' or nil;
		paramtype2 = e.paramtype2 or 'none';
		tiles = e.tex;