Differences From
Artifact [6f8619640d]:
- File
astrolabe.lua
— part of check-in
[3f6a913e4e]
at
2020-09-29 12:40:28
on branch trunk
— * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior
* initial documentation commit
* initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes
(user:
lexi,
size: 626)
[annotate]
[blame]
[check-ins using]
- File
astrolabe.lua
— part of check-in
[ea6e475e44]
at
2020-10-19 09:52:11
on branch trunk
— continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes
(user:
lexi,
size: 3919)
[annotate]
[blame]
[check-ins using]
1 +local calendar_style_list = function()
2 + local k = sorcery.lib.tbl.keys(sorcery.data.calendar.styles)
3 + table.sort(k)
4 + local r = {}
5 + for i,v in ipairs(k) do
6 + r[i] = {
7 + id = k[i];
8 + name = sorcery.data.calendar.styles[v].name;
9 + }
10 + end
11 + print(dump(r))
12 + return r
13 +end
14 +local astrolabe_formspec = function(pos)
15 + local m = minetest.get_meta(pos)
16 + local i = m:get_inventory()
17 + local datestamp = minetest.get_day_count()
18 + local date = sorcery.calendar.date(datestamp)
19 + local strd = sorcery.calendar.stars(datestamp)
20 + local style = m:get_string('datestyle')
21 + if style == '' then style = sorcery.data.calendar.default end
22 + local fdate = string.format('<global halign=center valign=middle size=20><b>%s</b>\n%s',
23 + sorcery.calendar.shortdate(datestamp,style),
24 + sorcery.calendar.longdate(datestamp,style))
25 + sstr=string.format('<global halign=center valign=middle><style size=20>Sign of the %s</style>\n<i>Stellar cycle %u</i>',strd.sign.patron,strd.cycle)
26 + local lphase = sorcery.calendar.contmatch(sorcery.calendar.moon_phases,date.lunar_phase)
27 + local menu
28 + local mi = calendar_style_list()
29 + local activestyle = 1
30 + local getphaseimg = function(body,fac)
31 + if fac >= 1 then fac = 0 end
32 + return 'sorcery_'..body..'_phases.png^[verticalframe:19:' .. tostring(math.floor(fac * 20))
33 + end
34 + local planetphase = getphaseimg('planet',minetest.get_timeofday())
35 + local ltime = '<global halign=center size=15>' .. sorcery.calendar.contmatch(sorcery.calendar.timesofday,minetest.get_timeofday()+0.1)
36 + local moonphase = getphaseimg('moon',date.lunar_phase)
37 + local moonlabel = string.format('<global halign=center size=15>%s Moon', lphase)
38 + for i,s in ipairs(mi) do
39 + if s.id == style then activestyle = i end
40 + local esc = minetest.formspec_escape(s.name)
41 + if menu
42 + then menu = menu .. ',' .. esc
43 + else menu = esc
44 + end
45 + end
46 + m:set_string('formspec', string.format([[
47 + formspec_version[3] size[14,4.25]
48 + box[0.25,0.25;3.75,3.75;#000000FF]
49 + hypertext[0.25,2.75;3.75,1;;%s]
50 + dropdown[4.1,0.25;5.1;style;%s;%u]
51 +
52 + box[4.1,1.5;2.50,2.50;#000000FF]
53 + image[4.1,1.5;2.50,2.50;%s]
54 + hypertext[4.1,3.50;2.50,1;;%s]
55 +
56 + box[6.7,1.5;2.50,2.50;#000000FF]
57 + image[6.7,1.5;2.50,2.50;%s]
58 + hypertext[6.7,3.50;2.50,1;;%s]
59 +
60 + hypertext[9.60,1.5;4.15,2.5;;%s]
61 +
62 + ]],
63 + minetest.formspec_escape(sstr),
64 + menu, activestyle,
65 + moonphase, minetest.formspec_escape(moonlabel),
66 + planetphase, minetest.formspec_escape(ltime),
67 + minetest.formspec_escape(fdate)))
68 +end
1 69 local albox = {
2 70 type = 'fixed';
3 71 fixed = {
4 72 -0.43,-0.5,-0.43;
5 - 0.43, 0.3, 0.43;
73 + 0.43, 0.35, 0.43;
6 74 };
7 75 }
8 76 minetest.register_node('sorcery:astrolabe',{
9 77 description = 'Astrolabe';
10 78 drawtype = 'mesh';
11 79 mesh = 'sorcery-astrolabe.obj';
12 80 groups = {
................................................................................
18 86 after_dig_node = sorcery.lib.node.purge_containers;
19 87 tiles = {
20 88 'default_steel_block.png';
21 89 'default_bronze_block.png';
22 90 'default_copper_block.png';
23 91 'default_aspen_wood.png';
24 92 };
93 + on_construct = function(pos)
94 + local m = minetest.get_meta(pos)
95 + local i = m:get_inventory()
96 + m:set_string('infotext','Astrolabe')
97 + astrolabe_formspec(pos)
98 + end;
99 + on_rightclick = function(pos)
100 + astrolabe_formspec(pos)
101 + end;
102 + on_receive_fields = function(pos,name,fields)
103 + local m = minetest.get_meta(pos)
104 + local i = m:get_inventory()
105 +
106 + local csl = calendar_style_list()
107 + if fields.style then
108 + for _,s in pairs(csl) do
109 + if s.name == fields.style then
110 + m:set_string('datestyle',s.id)
111 + astrolabe_formspec(pos)
112 + break
113 + end
114 + end
115 + end
116 + end;
25 117 _sorcery = {
26 118 recipe = {
27 119 note = 'Unravel the secrets of the stars';
28 120 };
29 121 };
30 122 })
123 +
124 +minetest.register_craft {
125 + output = 'sorcery:astrolabe';
126 + recipe = {
127 + {'sorcery:steel_screw','default:steel_ingot','sorcery:steel_screw'};
128 + {'default:copper_ingot',sorcery.data.metals.brass.parts.block,'default:copper_ingot'};
129 + {'default:stick','sorcery:screw_steel','default:stick'};
130 + };
131 +};