sorcery  Check-in [efb9d9d1b9]

Overview
Comment:bug fixes, add disc textures, get lathe fully operational finally
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: efb9d9d1b9b3db57153e03dc9b01ef33d4400bc1fb738467ea99d84a61890d31
User & Date: lexi on 2021-07-08 17:06:16
Other Links: manifest | tags
Context
2021-07-08
21:52
add tree lathe recipes check-in: 56a2b90c1b user: lexi tags: trunk
17:06
bug fixes, add disc textures, get lathe fully operational finally check-in: efb9d9d1b9 user: lexi tags: trunk
14:32
bug fixes, improve disc texture, improve recipes, you can now pour blood directly into a trough when you draw it with a consecrated dagger check-in: a66c0f02c7 user: lexi tags: trunk
Changes

Modified lathe.lua from [f27b9cba36] to [75f9e0d88f].

31
32
33
34
35
36
37
38
39
40

41












42
43
44
45
46
47
48
49
50
51
52
53
54
..
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
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
local R = sorcery.lathe.recipes
sorcery.lathe.get = function(pos,idx,howmany)
	local inv = minetest.get_meta(pos):get_inventory()
	local tool = inv:get_stack('tool',1)
	local tech = sorcery.lathe.tooltech(tool)
	if not tech then return nil end
	local wkpc = inv:get_stack('workpiece',1)
	howmany = howmany or wkpc:get_count()
	local rec = R[wkpc:get_name()][tech][idx]
	local outn = ItemStack(rec.output):get_count()

	local ntimes = math.floor(howmany / (rec.mass or 1))












	return {
		tool = tool, wkpc = wkpc;
		cost = rec.cost * ntimes;
		ntimes = ntimes;
		tqty = math.floor(howmany / outn) * (rec.mass or 1), outn = outn;
		gqty = ntimes * outn;
		tech = tech;
		rec = rec;
		inv = inv;
	}
end

sorcery.lathe.update = function(pos)
................................................................................
	local rec = R[wkpc:get_name()][tech]
	tech = sorcery.lathe.techs[tech]

	-- fill in the preview slots
	local j = 1
	for i=1, inv:get_size 'preview'  do
		local stk = ItemStack()

		if rec[i] and minetest.registered_items[ItemStack(rec[i].output):get_name()] and (rec[i].mass == nil or rec[i].mass <= wkpc:get_count()) then
			local l = sorcery.lathe.get(pos, i, wkpc:get_count())

			local max = l.ntimes --math.floor(wkpc:get_count() / (rec[i].mass or 1))
			if tech.dmg then
				-- TODO count remaining tool uses






			elseif tech.consume then
				max = math.min(max, tool:get_count())
			end
			if max > 0 then
				stk = ItemStack(rec[i].output)


				stk:set_count(stk:get_count() * max)
			end
		end
		inv:set_stack('preview',i,stk)
		j = j + 1
	end

	-- make sure remaining slots are clear
................................................................................
		local m = minetest.get_meta(pos)
		local i = m:get_inventory()
		i:set_size('workpiece', 1);
		i:set_size('tool', 1);
		i:set_size('preview', 8);
		m:set_string('formspec', [[
			formspec_version[3] size[10.25,8]
			list[context;tool;1.50,1;1,1]
			list[context;workpiece;3,1;1,1]
			list[context;preview;5.25,0.25;4,2]
			list[current_player;main;0.25,3;8,4]

			listring[current_player;main] listring[context;workpiece]
			listring[current_player;main] listring[context;tool]
			listring[current_player;main] listring[context;preview]
			listring[current_player;main]
................................................................................
	on_metadata_inventory_put = sorcery.lathe.update;
	on_metadata_inventory_take = function(pos, list, idx, stack, user)
		if list == 'preview' then
			local l = sorcery.lathe.get(pos,idx,stack:get_count())
			if sorcery.lathe.techs[l.tech].consume then
				l.tool:take_item(l.cost)
			elseif sorcery.lathe.techs[l.tech].dmg then
				local mat = sorcery.itemclass.get(l.tool,'material')
				local mmat = sorcery.itemclass.get(l.wkpc,'metal')
				local dur = 100
				local lfac = 1
				if mat then
					local dur = mat.data.durability or dur
					lfac = (mmat and mmat.data.level or 1) /
						(mat.data.maxlevel or mat.data.level or 1)
				end
				local ch = 65535 / dur
				l.tool:add_wear(ch * l.cost * lfac)
			end
			l.wkpc:take_item(l.tqty)
			l.inv:set_stack('tool', 1, l.tool)
			l.inv:set_stack('workpiece', 1, l.wkpc)
			if l.rec.leftover then
				sorcery.lib.node.insert(ItemStack(l.rec.leftover), 'workpiece', pos, user, l.inv)
			end







<


>
|
>
>
>
>
>
>
>
>
>
>
>
>



|
|
|







 







>
|
|
>
|

<
>
>
>
>
>
>





>
>
|







 







|
|







 







<
<
<
<
<
<
<
<
<
<
|







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
..
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
...
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
...
199
200
201
202
203
204
205










206
207
208
209
210
211
212
213
local R = sorcery.lathe.recipes
sorcery.lathe.get = function(pos,idx,howmany)
	local inv = minetest.get_meta(pos):get_inventory()
	local tool = inv:get_stack('tool',1)
	local tech = sorcery.lathe.tooltech(tool)
	if not tech then return nil end
	local wkpc = inv:get_stack('workpiece',1)

	local rec = R[wkpc:get_name()][tech][idx]
	local outn = ItemStack(rec.output):get_count()
	howmany = howmany or math.floor(wkpc:get_count()/(rec.mass or 1))*outn
	local ntimes = math.floor(howmany / outn)

	local tmat = sorcery.itemclass.get(tool,'material')
	local wmat = sorcery.itemclass.get(wkpc,'material')
	local dur = 100
	local lfac = 1
	if tmat then
		local dur = tmat.data.durability or dur
		lfac = (wmat and wmat.data.level or 1) /
			(tmat.data.maxlevel or tmat.data.level or 1)
	end
	local ch = 65535 / dur
	local wear = 2 * (ch * rec.cost * ntimes * lfac);
	return {
		tool = tool, wkpc = wkpc;
		cost = rec.cost * ntimes;
		wear = wear;
		ntimes = ntimes;
		tqty = ntimes * (rec.mass or 1), outn = outn;
		tech = tech;
		rec = rec;
		inv = inv;
	}
end

sorcery.lathe.update = function(pos)
................................................................................
	local rec = R[wkpc:get_name()][tech]
	tech = sorcery.lathe.techs[tech]

	-- fill in the preview slots
	local j = 1
	for i=1, inv:get_size 'preview'  do
		local stk = ItemStack()
		local os = rec[i] and ItemStack(rec[i].output)
		if rec[i] and minetest.registered_items[os:get_name()] and (rec[i].mass == nil or rec[i].mass <= wkpc:get_count()) then
			local l = sorcery.lathe.get(pos, i)
			local max = l.ntimes
			--math.floor(wkpc:get_count() / (rec[i].mass or 1))
			if tech.dmg then

				local lw = l.wear
				while lw + tool:get_wear() > 65535 do
					max = max - 1
					if max == 0 then break end
					lw = sorcery.lathe.get(pos, i, max).wear
				end
			elseif tech.consume then
				max = math.min(max, tool:get_count())
			end
			if max > 0 then
				stk = ItemStack(rec[i].output)
				local ct = math.min(stk:get_count() * max, stk:get_stack_max())
				ct = ct - (ct % os:get_count())
				stk:set_count(ct)
			end
		end
		inv:set_stack('preview',i,stk)
		j = j + 1
	end

	-- make sure remaining slots are clear
................................................................................
		local m = minetest.get_meta(pos)
		local i = m:get_inventory()
		i:set_size('workpiece', 1);
		i:set_size('tool', 1);
		i:set_size('preview', 8);
		m:set_string('formspec', [[
			formspec_version[3] size[10.25,8]
			list[context;tool;1.25,1;1,1]
			list[context;workpiece;2.75,1;1,1]
			list[context;preview;5.25,0.25;4,2]
			list[current_player;main;0.25,3;8,4]

			listring[current_player;main] listring[context;workpiece]
			listring[current_player;main] listring[context;tool]
			listring[current_player;main] listring[context;preview]
			listring[current_player;main]
................................................................................
	on_metadata_inventory_put = sorcery.lathe.update;
	on_metadata_inventory_take = function(pos, list, idx, stack, user)
		if list == 'preview' then
			local l = sorcery.lathe.get(pos,idx,stack:get_count())
			if sorcery.lathe.techs[l.tech].consume then
				l.tool:take_item(l.cost)
			elseif sorcery.lathe.techs[l.tech].dmg then










				l.tool:add_wear(l.wear)
			end
			l.wkpc:take_item(l.tqty)
			l.inv:set_stack('tool', 1, l.tool)
			l.inv:set_stack('workpiece', 1, l.wkpc)
			if l.rec.leftover then
				sorcery.lib.node.insert(ItemStack(l.rec.leftover), 'workpiece', pos, user, l.inv)
			end

Modified metal.lua from [43593523a3] to [69d743e332].

35
36
37
38
39
40
41

42
43
44
45
46
47
48
..
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
		value = fragments_per_ingot;
	};
	['morelights_vintage:brass_block'] = {
		id = 'brass'; data = sorcery.data.metals.brass;
		value = fragments_per_ingot * 9;
	};
}


local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors
-- for name, metal in pairs(sorcery.data.metals) do
sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal)
	local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot'
	local block = metal.block or 'sorcery:' .. name .. 'block'
	local screw = 'sorcery:screw_' .. name
................................................................................
				grindcost = 2, grindvalue = 1;
				value = 0.5;
			};
		};
	})
	minetest.register_craftitem(disc, {
		description = sorcery.lib.str.capitalize(name) .. ' Disc';
		inventory_image = sorcery.lib.image('sorcery_disc.png'):multiply(sorcery.lib.color(metal.tone)):render();
		groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; };
		_sorcery = {
			material = {
				id = name, data = metal;
				powder = powder;
				grindvalue = (3*4) / 2;
				value = 4 * (2/3);







>







 







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
		value = fragments_per_ingot;
	};
	['morelights_vintage:brass_block'] = {
		id = 'brass'; data = sorcery.data.metals.brass;
		value = fragments_per_ingot * 9;
	};
}
local fmt = string.format

local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors
-- for name, metal in pairs(sorcery.data.metals) do
sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal)
	local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot'
	local block = metal.block or 'sorcery:' .. name .. 'block'
	local screw = 'sorcery:screw_' .. name
................................................................................
				grindcost = 2, grindvalue = 1;
				value = 0.5;
			};
		};
	})
	minetest.register_craftitem(disc, {
		description = sorcery.lib.str.capitalize(name) .. ' Disc';
		inventory_image = fmt('sorcery_disc_%s.png', name);
		groups = { metal = 1; sorcery_disc = 1; sorcery_tech_component = 1; };
		_sorcery = {
			material = {
				id = name, data = metal;
				powder = powder;
				grindvalue = (3*4) / 2;
				value = 4 * (2/3);

Modified recipes.lua from [3da7013b08] to [f4ffdfcd69].

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	recipe = {
		{'','sorcery:gem_emerald',''};
		{'',mtlp('silver','disc'),''};
		{'sorcery:inverter_coil','sorcery:warding_plate','sorcery:inverter_coil'};
	};
}

print(dump{
	output = 'sorcery:tuning_disc';
	recipe = {
		{'','sorcery_gem:emerald',''};
		{'',mtlp('silver','disc'),''};
		{'sorcery:inverter_coil','sorcery:warding_plate','sorcery:inverter_coil'};
	};
})

minetest.register_craft {
	output = 'sorcery:farcaster';
	recipe = {
		{ingot('gold'),ingot('iridium'),ingot('gold')};
		{'sorcery:core_mandatic','default:diamondblock','sorcery:tuning_disc'};
		{ingot('gold'),ingot('iridium'),ingot('gold')};
	};







<
<
<
<
<
<
<
<
<







165
166
167
168
169
170
171









172
173
174
175
176
177
178
	recipe = {
		{'','sorcery:gem_emerald',''};
		{'',mtlp('silver','disc'),''};
		{'sorcery:inverter_coil','sorcery:warding_plate','sorcery:inverter_coil'};
	};
}










minetest.register_craft {
	output = 'sorcery:farcaster';
	recipe = {
		{ingot('gold'),ingot('iridium'),ingot('gold')};
		{'sorcery:core_mandatic','default:diamondblock','sorcery:tuning_disc'};
		{ingot('gold'),ingot('iridium'),ingot('gold')};
	};

Added textures/sorcery_disc_aluminum.png version [256f4dd766].

cannot compute difference between binary files

Added textures/sorcery_disc_brass.png version [103517ac67].

cannot compute difference between binary files

Added textures/sorcery_disc_bronze.png version [ac125cbc55].

cannot compute difference between binary files

Added textures/sorcery_disc_cobalt.png version [f7bc51f3c8].

cannot compute difference between binary files

Added textures/sorcery_disc_copper.png version [bd262561de].

cannot compute difference between binary files

Added textures/sorcery_disc_draconium.png version [44d851abb6].

cannot compute difference between binary files

Added textures/sorcery_disc_duridium.png version [ebf16dfeb1].

cannot compute difference between binary files

Added textures/sorcery_disc_electrum.png version [837e29a879].

cannot compute difference between binary files

Added textures/sorcery_disc_eternium.png version [e3780ee115].

cannot compute difference between binary files

Added textures/sorcery_disc_gold.png version [a10cbf9395].

cannot compute difference between binary files

Added textures/sorcery_disc_impervium.png version [0d454327bd].

cannot compute difference between binary files

Added textures/sorcery_disc_iridium.png version [9a3e75045c].

cannot compute difference between binary files

Added textures/sorcery_disc_levitanium.png version [4130ad9b4d].

cannot compute difference between binary files

Added textures/sorcery_disc_lithium.png version [bc972a091c].

cannot compute difference between binary files

Added textures/sorcery_disc_platinum.png version [2263fac066].

cannot compute difference between binary files

Added textures/sorcery_disc_silver.png version [24263ad780].

cannot compute difference between binary files

Added textures/sorcery_disc_steel.png version [c212e5c1db].

cannot compute difference between binary files

Added textures/sorcery_disc_tin.png version [8bb0dbd577].

cannot compute difference between binary files

Added textures/sorcery_disc_tungsten.png version [bd340f51d3].

cannot compute difference between binary files

Added textures/sorcery_disc_tyrannium.png version [0c7ec910aa].

cannot compute difference between binary files

Added textures/sorcery_disc_unobtanium.png version [908a2781fc].

cannot compute difference between binary files

Added textures/sorcery_disc_vidrium.png version [61f07965e9].

cannot compute difference between binary files