starlit  Check-in [5267c0742d]

Overview
Comment:add basic electrical parts, fix scrollbars to the greatest extent possible, fix error in marshal error msg, tweak inane compute stats
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5267c0742dc28ca6c50bf7ce78bcfa3dec0dc793cd8dd0543b9c0fce5e47f56e
User & Date: lexi on 2024-05-07 00:27:19
Other Links: manifest | tags
Context
2024-05-07
03:45
compiler now draws power, better compile job progress bars, stats screen refreshes check-in: 52a4f364ac user: lexi tags: trunk
00:27
add basic electrical parts, fix scrollbars to the greatest extent possible, fix error in marshal error msg, tweak inane compute stats check-in: 5267c0742d user: lexi tags: trunk
2024-05-06
21:29
fix image regression check-in: 108df84ed3 user: lexi tags: trunk
Changes

Modified mods/starlit-building/init.lua from [7b434e8bee] to [35031ce713].

     5      5   B.path = {}
     6      6   -- this maps stage IDs to tables of the following form
     7      7   --[[ {
     8      8   	part = {
     9      9   		['starlit_building:pipe'] = 'myMod:stage3';
    10     10   	};
    11     11   	tool = {
    12         -		['starlit:scredriver'] = 'myMod:otherThing_stage1';
           12  +		['starlit:screwdriver'] = 'myMod:otherThing_stage1';
    13     13   		['starlit:saw'] = function(node, tool)
    14     14   			minetest.replace_node(node, {name='myMod:stage1'})
    15     15   			minetest.drop_item(node, 'starlit_building:pipe')
    16     16   		end;
    17     17   		['myMod:laserWrench'] = {
    18     18   			allow = function(node, tool) ... end;
    19     19   			handle = function(node, tool) ... end;
................................................................................
    59     59   			fixed = { ... };
    60     60   		};
    61     61   	})
    62     62   ]]
    63     63   
    64     64   B.part = lib.registry.mk 'starlit_building:part'
    65     65   -- a part is implemented as a special craftitem with the proper callbacks
    66         --- to index the registries and place/replace noes by reference to the
           66  +-- to index the registries and place/replace nodes by reference to the
    67     67   -- build tree.
    68     68   --[[
    69     69   	starlit.mod.building.part.link(id, {
    70     70   		name = ''; -- display name
    71     71   		desc = ''; -- display desc
    72     72   		img = ''; -- display image
           73  +		mass = 0;
           74  +		fab = {}; -- (optional) auto-gen schematic
           75  +		rarity = 0;
    73     76   	})
    74     77   ]]
           78  +B.part.foreach('starlit:partGen', {}, function(id, e)
           79  +	local props = {}
           80  +	if e.mass then
           81  +		table.insert(props, {title='Mass', desc=lib.math.siUI('g',e.mass), affinity='info'})
           82  +	end
           83  +	local rev, scmID
           84  +	if e.fab then
           85  +		scmID = string.format('%s_schematic', id)
           86  +		rev = {
           87  +			sw = scmID;
           88  +			complexity = e.complexity or 1;
           89  +		}
           90  +	end
           91  +	minetest.register_craftitem(id, {
           92  +		short_description = e.name;
           93  +		description = starlit.ui.tooltip {
           94  +			title = e.name;
           95  +			desc = e.desc;
           96  +			props = props;
           97  +		};
           98  +		inventory_image = e.img;
           99  +		_starlit = {
          100  +			mass = e.mass;
          101  +			reverseEngineer = rev;
          102  +			recover = e.recover or e.fab;
          103  +		};
          104  +	})
          105  +	if e.fab then
          106  +		starlit.item.sw.link(scmID, {
          107  +			kind = 'schematic';
          108  +			name = string.format('%s Schematic', e.name);
          109  +			size = e.size or 32e6;
          110  +			input = e.fab;
          111  +			output = id;
          112  +			cost = e.cost or {
          113  +				cycles = 4e9;
          114  +				ram = 1e9;
          115  +			};
          116  +			rarity = e.rarity or 0;
          117  +		})
          118  +	end
          119  +
          120  +end)
    75    121   
    76    122   B.stage.foreach('starlit:stageGen', {}, function(id, e)
    77    123   	local box = {type = 'fixed', fixed = {}}
    78    124   	local tex = {}
    79    125   	local ofs = vector.new(0,0,0)
    80    126   	for idx, p in ipairs(e.pieces) do
    81    127   		local ho, pieceID, pos
................................................................................
   129    175   end
   130    176   
   131    177   function B.pathFind(from, kind, what)
   132    178   	if not B.path[from] then return nil end
   133    179   	return B.path[from][kind][what]
   134    180   end
   135    181   
          182  +starlit.include 'parts'

Added mods/starlit-building/parts.lua version [01ffc64dd2].

            1  +local lib = starlit.mod.lib
            2  +local E = starlit.mod.electronics
            3  +local B = starlit.mod.building
            4  +
            5  +B.part.link('starlit_building:battery_box', {
            6  +	name = 'Battery Box';
            7  +	desc = 'A receptacle for a battery.';
            8  +	img = 'starlit-item-battery-box.png';
            9  +	fab = starlit.type.fab {
           10  +		element = {
           11  +			copper = 5;
           12  +			aluminum = 10;
           13  +		};
           14  +		cost = {power = 300};
           15  +		flag = {print=true};
           16  +		time = {print=10};
           17  +	};
           18  +	mass = 15;
           19  +	rarity = 1;
           20  +})
           21  +
           22  +B.part.link('starlit_building:electrode', {
           23  +	name = 'Electrode';
           24  +	desc = 'An electrical conductor used to make contact with a nonmetallic circuit component.';
           25  +	img = 'starlit-item-electrode.png';
           26  +	fab = starlit.type.fab {
           27  +		element = {
           28  +			copper = 1;
           29  +			aluminum = 1;
           30  +		};
           31  +		cost = {power = 150};
           32  +		flag = {print=true};
           33  +		time = {print=5};
           34  +	};
           35  +	mass = 2;
           36  +	rarity = 1;
           37  +})
           38  +
           39  +B.part.link('starlit_building:heating_element', {
           40  +	name = 'Heating Element';
           41  +	desc = 'An extremely inefficient conductor of electricity.';
           42  +	img = 'starlit-item-heating-element.png';
           43  +	fab = starlit.type.fab {
           44  +		element = {
           45  +			copper = 2;
           46  +			nickel = 2;
           47  +		};
           48  +		cost = {power = 300};
           49  +		flag = {print=true};
           50  +		time = {print=10};
           51  +	};
           52  +	mass = 4;
           53  +	rarity = 1;
           54  +})
           55  +
           56  +B.part.link('starlit_building:cable_electric', {
           57  +	name = 'Electric Cable';
           58  +	desc = 'A length of conductive metal in a protective graphene sheathe.';
           59  +	img = 'starlit-item-cable-electric.png';
           60  +	fab = starlit.type.fab {
           61  +		element = {
           62  +			copper = 16;
           63  +			carbon = 16;
           64  +		};
           65  +		cost = {power = 700};
           66  +		flag = {print=true};
           67  +		time = {print=20};
           68  +	};
           69  +	mass = 32;
           70  +	rarity = 1;
           71  +})
           72  +
           73  +B.part.link('starlit_building:transformer', {
           74  +	name = 'Transformer';
           75  +	desc = 'An electrical component used to step-up or step-down voltage levels.';
           76  +	img = 'starlit-item-transformer.png';
           77  +	fab = starlit.type.fab {
           78  +		element = {
           79  +			copper = 8;
           80  +			iron = 16;
           81  +		};
           82  +		cost = {power = 500};
           83  +		flag = {print=true};
           84  +		time = {print=20};
           85  +	};
           86  +	mass = 24;
           87  +	rarity = 1;
           88  +})

Modified mods/starlit-electronics/init.lua from [6f6bfb54e1] to [358af6b345].


Modified mods/starlit-electronics/sw.lua from [f5ad2a2c21] to [b2e1bf9d1b].

   183    183   		end;
   184    184   	}
   185    185   end
   186    186   
   187    187   starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler {
   188    188   	name = 'Compile Matter';
   189    189   	desc = "A basic suit matter compiler program. It's rather slow, but it's been ruthlessly optimized for size- and memory-efficiency by some of the Commune's most fanatic coders, to the point where every Commune nanosuit can come with the program preinstalled.";
   190         -	size = 700e3;
          190  +	size = 700e6;
   191    191   	cost = {
   192    192   		cycles = 4e9;
   193    193   		ram = .3e9;
   194    194   	};
   195    195   })
   196    196   
   197    197   starlit.item.sw.link('starlit_electronics:compile_block_commune', {
   198    198   	name = 'Compile Block';
   199    199   	kind = 'suitPower', powerKind = 'active';
   200    200   	desc = "An advanced suit matter compiler program, capable of printing complete devices and structure parts directly into the world.";
   201         -	size = 5e6;
          201  +	size = 500e6;
   202    202   	cost = {
   203    203   		cycles = 8e9;
   204    204   		ram = 1e9;
   205    205   	};
   206    206   	ui = 'starlit:compile-matter-block';
   207    207   	run = function(user, ctx)
   208    208   	end;
   209    209   })
   210    210   
   211    211   starlit.item.sw.link('starlit_electronics:compile_imperial', matterCompiler {
   212    212   	name = 'Genesis Deluxe';
   213    213   	desc = "House Bascundir has long dominated the matter compiler market in the Crystal Sea. Their firmware is excessively complex due to mountains of specialized edge-case handling, but the end result is certainly speedier than the competitors'.";
   214         -	size = 2e4;
          214  +	size = 2e9;
   215    215   	cost = {
   216         -		cycles = 100e6;
          216  +		cycles = 1e9;
   217    217   		ram = 1.5e9;
   218    218   	};
   219    219   })
   220    220   
   221    221   do local J = starlit.store.compilerJob
   222    222   	starlit.item.sw.link('starlit_electronics:driver_compiler_commune', {
   223    223   		name = 'Matter Compiler';

Modified mods/starlit-material/elements.lua from [81b3a1522a] to [0b9dddbb90].

    76     76   		color = lib.color(.7,.7,.7);
    77     77   	};
    78     78   	vanadium = {
    79     79   		name = 'vanadium', sym = 'V', n = 23; density = 6;
    80     80   		metal = true;
    81     81   		color = lib.color(.3,0.5,.3);
    82     82   	};
           83  +	nickel = {
           84  +		name = 'nickel', sym = 'ni', n = 28, density = 8.908;
           85  +		metal = true;
           86  +		color = lib.color(.7,.7,.6);
           87  +	};
    83     88   	xenon = {
    84     89   		name = 'xenon', sym = 'Xe', n = 54;  density = 0.005894;
    85     90   		gas = true;
    86     91   		color = lib.color(.5,.1,1);
    87     92   	};
    88     93   	argon = {
    89     94   		name = 'argon', sym = 'Ar', n = 18;  density = 0.001784;

Modified mods/starlit-scenario/init.lua from [739d68f851] to [ad44a3c89f].

    34     34   	E.chip.write(chip, r)
    35     35   	return chip
    36     36   end
    37     37   
    38     38   local survivalBasics = {
    39     39   		{'starlit_tech:chem_lamp', 0};
    40     40   		{'starlit_tech:crate', 0};
           41  +		{'starlit_building:battery_box', 0};
           42  +		{'starlit_building:heating_element', 0};
           43  +		{'starlit_building:electrode', 0};
           44  +		{'starlit_building:cable_electric', 0};
           45  +		{'starlit_building:transformer', 0};
    41     46   }
    42     47   
    43     48   local chipLibrary = {
    44     49   	compendium = makeChip('The Gentleman Adventurer\'s Compleat Wilderness Compendium', lib.tbl.append(survivalBasics, {
    45     50   		{'starlit_electronics:battery_chemical_imperial_small', 0};
    46     51   	}), {
    47     52   		{'starlit_electronics:shred', 0};

Modified mods/starlit-tech/init.lua from [c5d4cbc341] to [4840721039].

    94     94   end
    95     95   
    96     96   
    97     97   minetest.register_node('starlit_tech:crate', {
    98     98   	short_description = 'Crate';
    99     99   	description = starlit.ui.tooltip {
   100    100   		title = 'Crate';
   101         -		desc = 'A sturdy but lightweight storage crate made from solid carbon polymer.';
          101  +		desc = 'A sturdy but lightweight storage crate woven from graphene.';
   102    102   		props = { {title='Mass', affinity='info', desc='100g'} };
   103    103   	};
   104    104   	drawtype = 'nodebox';
   105    105   	node_box = {
   106    106   		type = 'fixed';
   107    107   		fixed = {
   108    108   			 .4,  .2,  .4;

Modified mods/starlit/interfaces.lua from [39c7d68ac6] to [d00e83c8f9].

   321    321   							if r.sw.cost and r.sw.cost.cycles then
   322    322   								table.insert(props, {title = "Compute Usage", desc=lib.math.siUI('cycles',r.sw.cost.cycles,true), affinity='info'})
   323    323   							end
   324    324   							if r.powerCost then
   325    325   								table.insert(props, {title = "Power Draw", desc=lib.math.siUI('W', r.powerCost), affinity='info'})
   326    326   							end
   327    327   							if r.speed then
   328         -								table.insert(props, {title = "Minimum Runtime", desc=lib.math.timespec(r.speed), affinity='info'})
          328  +								table.insert(props, {title = "Base Runtime", desc=lib.math.timespec(r.speed), affinity='info'})
   329    329   							end
   330    330   							table.insert(tbl, {
   331    331   								color = color, fg = fg;
   332    332   								label = r.sw.label or r.sw.name;
   333    333   								id = string.format('suit_pgm_%s_', id);
   334    334   								desc = starlit.ui.tooltip {
   335    335   									title = r.sw.name;

Modified mods/starlit/ui.lua from [5149fd5b74] to [60598b98d5].

   176    176   			maxX = math.max(state.x, maxX)
   177    177   		end
   178    178   		totalH = totalH + rowH
   179    179   		state.h = math.max(state.h, totalH) + state.padding
   180    180   		state.w = state.x + state.padding/2
   181    181   		state.x = maxX
   182    182   	elseif def.kind == 'pane' then
          183  +		local top = state.y
   183    184   		widget('scroll_container[%s,%s;%s,%s;%s;vertical]',
   184    185   			state.x, state.y, state.w, state.h,
   185    186   			def.id)
   186    187   		local y = 0
          188  +		local x,w = state.x,state.w
          189  +-- 		state.x = state.x + .75
          190  +-- 		state.w = state.w - .75
          191  +		local widgs = {}
   187    192   		for _, w in ipairs(def) do
   188    193   			local src, st = starlit.ui.build(w, state)
   189         -			widget('container[%s,%s]%scontainer_end[]', 0, y, src)
          194  +			table.insert(widgs, {
          195  +				y=y, src=src
          196  +			})
   190    197   			y=y + state.spacing + st.h
   191    198   			state.w = math.max(state.w, st.w)
   192    199   		end
          200  +		local xo, barred = 0, false
          201  +		if y-top > state.h then
          202  +			barred, xo = true, .60
          203  +		end
          204  +		for k,v in ipairs(widgs) do
          205  +			widget('container[%s,%s]%scontainer_end[]', xo, v.y, v.src)
          206  +		end
   193    207   		widget('scroll_container_end[]')
   194         -		if y > state.h then
   195         -			widget('scrollbar[%s,%s;%s,%s;vertical;%s;]',
   196         -				state.x, state.y, .5, state.h,
          208  +		if barred then
          209  +			widget('scrollbaroptions[max=%s]scrollbar[%s,%s;%s,%s;vertical;%s;]',
          210  +				(y-top-state.h)*10, x, state.y, .5, state.h,
   197    211   				def.id)
   198    212   		end
   199         -		state.w = state.w + state.padding
          213  +		state.x = x
          214  +		state.w = w + state.padding
   200    215   		state.h = state.h + state.padding/2
          216  +		state.y = state.y + state.h
   201    217   	elseif def.kind == 'list' then
   202    218   		local slotTypes = {
   203    219   			plain = {hue = 200, sat = -.1, lum = 0};
   204    220   -- 			element = {hue = 20, sat = -.3, lum = 0};
   205    221   			chip = {hue = 0, sat = -1, lum = 0};
   206    222   -- 			psi = {hue = 300, sat = 0, lum = 0};
   207    223   			power = {hue = 50, sat = 0, lum = .2};
................................................................................
   323    339   	if def.mode or def.container then
   324    340   		if def.mode then
   325    341   			l = string.format('background9[%s,%s;%s,%s;%s;false;64]',
   326    342   					originX, originY, state.w, state.h,
   327    343   					E(string.format('starlit-ui-bg-%s.png%s^[resize:128x128',
   328    344   						(def.mode == 'sw') and 'digital'
   329    345   											or 'panel', cmod))) .. l
          346  +--  			l = string.format('style_type[scrollbar;bgcolor=#1155ff]') .. l
   330    347   		end
   331    348   		if parent == nil or state.color ~= parent.color then
   332    349   			l = btnColorDef() .. l
   333    350   		end
   334    351   	end
   335    352   	if not parent then
   336    353   		return string.format('formspec_version[6]size[%s,%s]%s', state.w, state.h, l), state

Modified mods/vtlib/marshal.lua from [2822b4a0ba] to [979397aff5].

   195    195   	-- }
   196    196   	local def, name
   197    197   	if select('#', ...) >= 2 then
   198    198   		name, def = ...
   199    199   	else
   200    200   		def = ...
   201    201   	end
   202         -	name = 'struct' .. (name and ':' .. name or '');
          202  +	name = 'struct' .. (name and (':' .. name) or '');
   203    203   	report('defining struct name=%q fields=%s', name, dump(def))
   204    204   	return {
   205    205   		name = name;
   206    206   		enc = function(obj)
   207    207   		report('encoding struct name=%q vals=%s', name, dump(obj))
   208    208   			local enc = m.streamEncoder()
   209    209   			local n = 0
   210    210   			for k,ty in pairs(def) do n=n+1
   211         -				if obj[k] == nil then error('missing key '..dump(k)..' for type '..ty.name) end
          211  +				if obj[k] == nil then
          212  +					error(string.format("missing %s field %q for %s", ty.name, k, name))
          213  +				end
   212    214   				local encoded = ty.enc(obj[k])
   213    215   				enc.push(T.u8.enc(#k), size.enc(#encoded), k, encoded)
   214    216   			end
   215    217   			return size.enc(n) .. enc.peek()
   216    218   		end;
   217    219   		dec = debugger.wrap(function(blob)
   218    220   			if blob == '' then