Reorganize a bunch of things, fix refactored code :)

master
Auri 2021-12-20 22:24:54 -08:00
parent 697b15238e
commit 592a50672e
71 changed files with 572 additions and 217 deletions

View File

@ -1,16 +1,16 @@
-- Global game table.
_G.lexa = {}
function lexa.get_script_path()
return minetest.get_modpath(minetest.get_current_modname()) .. '/script/'
end
--
-- Shorthand dofile that will load a file from the mod's script directory.
-- .lua file extension not needed.
--
function lexa.require(path)
return dofile(lexa.get_script_path() .. path .. '.lua')
return dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/script/'.. path .. '.lua')
end
local path = lexa.get_script_path()
dofile(path .. 'settings.lua')
dofile(path .. 'util.lua')
dofile(path .. 'hand.lua')
-- Load base functionality.
lexa.require('settings')
lexa.require('util')
lexa.require('hand')

View File

@ -3,14 +3,13 @@
--
-- Hand for use in game mode.
minetest.register_item('lexa_base:hand_game', {
minetest.register_tool('lexa_base:hand_game', {
range = 10.0,
inventory_image = 'lexa_base_hand_game',
inventory_image = 'lexa_base_hand_game.png',
tool_capabilities = {
full_punch_interval = 0,
groupcaps = {
dig_game = { times = { [1] = 0.1 }, uses = 0 }
dig_build = { times = { [1] = 0.1 }, uses = 0 },
}
},
groups = {
@ -19,14 +18,14 @@ minetest.register_item('lexa_base:hand_game', {
})
-- Hand for use in build mode.
minetest.register_item('lexa_base:hand_build', {
minetest.register_tool('lexa_base:hand_build', {
range = 10.0,
inventory_image = 'lexa_base_hand_build',
inventory_image = 'lexa_base_hand_build.png',
tool_capabilities = {
full_punch_interval = 0,
groupcaps = {
dig_game = { times = { [1] = 0.1 }, uses = 0 }
dig_build = { times = { [1] = 0.1 }, uses = 0 },
dig_game = { times = { [1] = 0.1 }, uses = 0 },
dig_build = { times = { [1] = 0.1 }, uses = 0 }
}
},
groups = {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 B

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,7 @@
lexa.conveyor = {}
lexa.conveyor.speed = 1
lexa.require('belt')
lexa.require('junction')
lexa.require('distributor')
lexa.require('entity')

View File

@ -0,0 +1,211 @@
local collision_boxes = {
vertical_bottom = {
{ -7/16, -8/16, -8/16, 7/16, 0, 8/16 },
{ -7/16, 0/16, 4/16, 7/16, 8/16, 8/16 },
{ -7/16, 0/16, 0, 7/16, 4/16, 4/16 }
},
vertical_mid = {
{ -7/16, -8/16, -4/16, 7/16, 0, 8/16 },
{ -7/16, 0/16, 4/16, 7/16, 8/16, 8/16 },
{ -7/16, 0/16, 0, 7/16, 4/16, 4/16 },
{ -7/16, -8/16, -8/16, 7/16, -4/16, -4/16 }
},
vertical_top = {
{ -7/16, -8/16, -4/16, 7/16, 0, 8/16 },
{ -7/16, -8/16, -8/16, 7/16, -4/16, -4/16 }
},
horizontal = { -7/16, -8/16, -8/16, 7/16, 0, 8/16 }
}
local conveyor_functions = {
horizontal = function(node_pos, item, delta)
local node = minetest.get_node(node_pos)
local dir = minetest.facedir_to_dir(node.param2)
local obj_pos = item.object:get_pos()
local obj_vel = item.object:get_velocity()
local obj_pos_rel = vector.subtract(obj_pos, node_pos)
if obj_pos_rel.y > 0.5 then
-- Make the item fall if it's not on the surface of the block.
obj_vel.y = obj_vel.y - 9.8 * delta
item.object:set_velocity(obj_vel)
elseif obj_pos_rel.y < 0.5 then
-- Put it back on the block if it's below the surface, set vel.y to 0.
obj_pos.y = node_pos.y + 0.5
obj_vel.y = 0
item.object:set_pos(obj_pos)
item.object:set_velocity(obj_vel)
else
-- Move the item along the conveyor's normal towards the middle.
local main_axis = dir.x ~= 0 and 'x' or 'z'
local norm_axis = dir.x == 0 and 'x' or 'z'
if obj_pos_rel[norm_axis] > 0.05 then
obj_vel[norm_axis] = -1 * lexa.conveyor.speed
elseif obj_pos_rel[norm_axis] < -0.05 then
obj_vel[norm_axis] = lexa.conveyor.speed
else
obj_vel[norm_axis] = 0
-- Move the item along the conveyor's direction.
obj_vel[main_axis] = dir[main_axis] * lexa.conveyor.speed
end
item.object:set_velocity(obj_vel)
end
end
}
minetest.override_item('air', {
_conveyor_function = function(pos, item, delta)
local obj_vel = item.object:get_velocity()
obj_vel.y = obj_vel.y - 9.8 * delta
item.object:set_velocity(obj_vel)
end
})
local selection_boxes = {
vertical_mid = { -7/16, -8/16, -8/16, 7/16, 8/16, 8/16 },
vertical_bottom = { -7/16, -8/16, -8/16, 7/16, 8/16, 8/16 },
horizontal = { -7/16, -8/16, -8/16, 7/16, 0, 8/16 }
}
local merge_check_dirs = {
{ x = -1, y = 0, z = 0 },
{ x = 1, y = 0, z = 0 },
{ x = 0, y = 0, z = -1 },
{ x = 0, y = 0, z = 1 },
{ x = -1, y = 1, z = 0 },
{ x = 1, y = 1, z = 0 },
{ x = 0, y = 1, z = -1 },
{ x = 0, y = 1, z = 1 }
}
function pos_is_conveyor(pos, dir)
local node = minetest.get_node(pos)
if dir ~= nil and dir ~= node.param2 then return 0 end
return ((minetest.registered_nodes[node.name] or {}).groups or {}).conveyor or 0
end
function handle_update_conveyors(pos, update_neighbors)
local node = minetest.get_node(pos)
local dir = minetest.facedir_to_dir(node.param2)
local type = node.name:match('vertical') and 2 or 1
local adj = {
front = pos_is_conveyor(vector.add(pos, dir), node.param2),
back = pos_is_conveyor(vector.subtract(pos, dir), node.param2),
above = pos_is_conveyor(vector.add(vector.add(pos, dir), { x = 0, y = 1, z = 0 }), node.param2),
below = pos_is_conveyor(vector.add(vector.subtract(pos, dir), { x = 0, y = -1, z = 0 }), node.param2),
}
local type_changed = false
if adj.above ~= 0 or adj.below ~= 0 then
if adj.above ~= 0 and adj.below ~= 0 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_vertical_mid', param2 = node.param2 })
elseif adj.above ~= 0 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_vertical_bottom', param2 = node.param2 })
elseif adj.below ~= 0 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_vertical_top', param2 = node.param2 })
end
if type == 1 then type_changed = true end
else
if adj.front == 1 and adj.back == 1 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_horizontal_mid', param2 = node.param2 })
elseif adj.front == 1 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_horizontal_start', param2 = node.param2 })
elseif adj.back == 1 then
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_horizontal_end', param2 = node.param2 })
else
minetest.swap_node(pos, { name = 'lexa_conveyor:belt_mono', param2 = node.param2 })
end
if type == 2 then type_changed = true end
end
if update_neighbors or type_changed then
if adj.front ~= 0 then
handle_update_conveyors(vector.add(pos, dir))
end
if adj.back ~= 0 then
handle_update_conveyors(vector.subtract(pos, dir))
end
if adj.above ~= 0 then
handle_update_conveyors(vector.add(vector.add(pos, dir), { x = 0, y = 1, z = 0 }))
end
if adj.below ~= 0 then
handle_update_conveyors(vector.add(vector.subtract(pos, dir), { x = 0, y = -1, z = 0 }))
end
end
end
function handle_construct_conveyor(pos)
handle_update_conveyors(pos, true)
end
function handle_destruct_conveyor(pos, node)
local dir = minetest.facedir_to_dir(node.param2)
local adj = {
front = pos_is_conveyor(vector.add(pos, dir)),
back = pos_is_conveyor(vector.subtract(pos, dir)),
above = pos_is_conveyor(vector.add(vector.add(pos, dir), { x = 0, y = 1, z = 0 })),
below = pos_is_conveyor(vector.add(vector.subtract(pos, dir), { x = 0, y = -1, z = 0 })),
}
if adj.front ~= 0 then
handle_update_conveyors(vector.add(pos, dir))
end
if adj.back ~= 0 then
handle_update_conveyors(vector.subtract(pos, dir))
end
if adj.above ~= 0 then
handle_update_conveyors(vector.add(vector.add(pos, dir), { x = 0, y = 1, z = 0 }))
end
if adj.below ~= 0 then
handle_update_conveyors(vector.add(vector.subtract(pos, dir), { x = 0, y = -1, z = 0 }))
end
end
for _, type in ipairs({ 'horizontal_start', 'horizontal_mid', 'horizontal_end',
'mono', 'vertical_bottom', 'vertical_mid', 'vertical_top' }) do
local collision_box = collision_boxes[type] or collision_boxes.horizontal
local selection_box = selection_boxes[type] or selection_boxes.horizontal
minetest.register_node('lexa_conveyor:belt_' .. type, {
drawtype = 'mesh',
mesh = 'lexa_conveyor_belt_' .. type .. '.b3d',
tiles = { { name = 'lexa_conveyor_belt_strip.png', animation = {
type = 'vertical_frames',
aspect_w = 14,
aspect_h = 8,
length = 0.25
} }, 'lexa_conveyor_belt_frame.png' },
description = 'Belt',
_cost = { copper = 2 },
selection_box = {
type = 'fixed',
fixed = selection_box
},
collision_box = {
type = 'fixed',
fixed = collision_box
},
paramtype = 'light',
paramtype2 = 'facedir',
sunlight_propagates = true,
groups = {
dig_game = 1,
conveyor = type:match('vertical') and 2 or 1,
not_in_creative_inventory = type ~= 'mono' and 1 or 0
},
_conveyor_function = conveyor_functions[type] or conveyor_functions.horizontal,
drop = '',
on_construct = handle_construct_conveyor,
after_destruct = handle_destruct_conveyor
})
end

View File

@ -1,12 +1,10 @@
local conveyor_speed = 1
minetest.register_node('machine:distributor', {
minetest.register_node('lexa_conveyor:distributor', {
description = 'Distributor',
_cost = { copper = 5 },
drawtype = 'mesh',
use_texture_alpha = 'clip',
mesh = 'machine_distributor.b3d',
tiles = { 'machine_distributor.png' },
mesh = 'lexa_conveyor_machine.b3d',
tiles = { 'lexa_conveyor_distributor.png' },
use_texture_alpha = 'opaque',
selection_box = {
type = 'fixed',
@ -24,7 +22,7 @@ minetest.register_node('machine:distributor', {
sunlight_propagates = true,
groups = {
conveyor = 3,
creative_dig = 1,
dig_game = 1,
},
_conveyor_function = function(node_pos, item, delta)
local node = minetest.get_node(node_pos)
@ -80,7 +78,7 @@ minetest.register_node('machine:distributor', {
end
elseif obj_pos_rel[main_axis] * util.sign(dir[main_axis]) <= -0.05 then
-- Move the item
item.object:set_velocity(vector.multiply(dir, conveyor_speed))
item.object:set_velocity(vector.multiply(dir, lexa.conveyor.speed))
end
end
end,

View File

@ -0,0 +1,62 @@
--
-- Functions for conveyor item enities to call to interact with the conveyor.
--
lexa.conveyor.entity = {}
lexa.conveyor.entity.on_activate = function(self)
self.last_vel = vector.new(0, 0, 0)
self.death_time = 0
end
lexa.conveyor.entity.on_step = function(self, delta)
local node_pos = vector.round(vector.add(self.object:get_pos(), vector.new(0, -0.5, 0)))
if not self.conveyor_function or not self.last_pos or self.last_pos ~= node_pos then
self.conveyor_function = minetest.registered_nodes[minetest.get_node(node_pos).name]._conveyor_function or false
end
if self.conveyor_function and self.conveyor_function ~= false then
local found = false
local others = minetest.get_objects_inside_radius(
vector.add(self.object:get_pos(), vector.multiply(self.last_vel, 0.2)), 0.2)
for _, obj in ipairs(others) do
local lua = obj:get_luaentity()
if obj ~= self.object and lua and lua.name == 'lexa_map:ore_chunk' then
found = true
break
end
end
if not found then
self.conveyor_function(node_pos, self, delta)
self.last_vel = self.object:get_velocity()
else
self.object:set_velocity(vector.new(0, 0, 0))
end
else
self.death_time = self.death_time + delta
if self.death_time > 1 then
self.object:remove()
else
if self.death_time > 0.25 then
if (self.death_time * 5) % 2 < 0.75 then
if not self.hidden then
self.object:set_properties({ textures = { 'lexa_hud_hidden.png' } })
self.hidden = true
end
else
if self.hidden then
self.object:set_properties({ textures = { 'lexa_materials_chunk_' .. self.type .. '.png' } })
self.hidden = false
end
end
end
local obj_pos = self.object:get_pos()
obj_pos.y = node_pos.y + 0.99
self.object:set_velocity(vector.new(0, 0, 0))
self.object:set_pos(obj_pos)
end
end
end

View File

@ -1,12 +1,10 @@
local conveyor_speed = 1
minetest.register_node('machine:junction', {
minetest.register_node('lexa_conveyor:junction', {
description = 'Junction',
_cost = { copper = 5 },
drawtype = 'mesh',
use_texture_alpha = 'clip',
mesh = 'machine_distributor.b3d',
tiles = { 'machine_junction.png' },
mesh = 'lexa_conveyor_machine.b3d',
tiles = { 'lexa_conveyor_junction.png' },
use_texture_alpha = 'opaque',
selection_box = {
type = 'fixed',
@ -23,7 +21,7 @@ minetest.register_node('machine:junction', {
sunlight_propagates = true,
groups = {
conveyor = 3,
creative_dig = 1,
dig_game = 1,
},
_conveyor_function = function(node_pos, item, delta)
local obj_pos = item.object:get_pos()
@ -42,7 +40,7 @@ minetest.register_node('machine:junction', {
item.object:set_velocity(obj_vel)
elseif obj_vel.x == 0 and obj_vel.z == 0 then
-- Give the item a default direction to stop it from stalling
obj_vel.x = conveyor_speed
obj_vel.x = lexa.conveyor.speed
item.object:set_velocity(obj_vel)
end
end,

View File

@ -1,4 +1 @@
lexa.require('conveyor')
lexa.require('junction')
lexa.require('distributor')
lexa.require('mining_drill')
lexa.require('drill')

View File

@ -0,0 +1,5 @@
title = Factory
name = lexa_factory
author = Aurailus
description = Machines to place in the world.
depends = lexa_base

View File

@ -1,9 +1,10 @@
minetest.register_entity('machine:mining_drill_entity', {
minetest.register_entity('lexa_factory:drill_entity', {
visual = 'mesh',
visual_size = vector.new(10, 10, 10),
textures = { 'machine_mining_drill.png' },
mesh = 'machine_mining_drill_entity.b3d',
textures = { 'lexa_factory_drill.png' },
mesh = 'lexa_factory_drill_entity.b3d',
pointable = false,
static_save = false,
on_activate = function(self, static_data)
self.node_pos = (minetest.deserialize(static_data) or {}).node_pos
minetest.after(math.random() * 10, function() self.object:set_animation({ x = 0, y = 375 }, 30, 0, true) end)
@ -13,13 +14,13 @@ minetest.register_entity('machine:mining_drill_entity', {
end
})
minetest.register_node('machine:mining_drill', {
description = 'Mining Drill',
minetest.register_node('lexa_factory:drill', {
description = 'Drill',
_cost = { copper = 10 },
drawtype = 'mesh',
use_texture_alpha = 'clip',
mesh = 'machine_mining_drill_node.b3d',
tiles = { 'machine_mining_drill.png' },
mesh = 'lexa_factory_drill_node.b3d',
tiles = { 'lexa_factory_drill.png' },
selection_box = {
type = 'fixed',
fixed = {
@ -39,7 +40,7 @@ minetest.register_node('machine:mining_drill', {
},
drop = '',
on_construct = function(pos)
minetest.add_entity(pos, 'machine:mining_drill_entity', minetest.serialize({ node_pos = pos }))
minetest.add_entity(pos, 'lexa_factory:drill_entity', minetest.serialize({ node_pos = pos }))
end,
after_destruct = function(pos)
local entities = minetest.get_objects_in_area(pos, pos)

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -2,4 +2,4 @@ title = Hud
name = lexa_hud
author = Aurailus
description = Match bar, resource display, and custom hotbar.
depends = lexa_base, lexa_text, lexa_terrain, lexa_wall, lexa_machine, lexa_conveyor
depends = lexa_base, lexa_text, lexa_map, lexa_wall, lexa_factory, lexa_conveyor

View File

@ -5,10 +5,10 @@ local DEFAULT_INVENTORY_SIZE = 32
local LABEL_BUFFER = 48
local item_lists = {
{ 'machine:conveyor_mono', 'machine:distributor', 'machine:junction' },
{ 'machine:mining_drill' },
{ 'wall:bottom_cobalt', 'wall:bottom_titanium', 'wall:bottom_copper', 'wall:ladder' },
{ 'terrain:grass_teal', 'terrain:stone_mountain', 'terrain:log_1_birch', 'terrain:leaves_birch', 'terrain:fern_teal', 'terrain:tall_grass_teal' },
{ 'lexa_conveyor:belt_mono', 'lexa_conveyor:distributor', 'lexa_conveyor:junction' },
{ 'lexa_factory:drill' },
{ 'lexa_wall:bottom_cobalt', 'lexa_wall:bottom_titanium', 'lexa_wall:bottom_copper', 'lexa_wall:ladder' },
{ 'lexa_map:grass_teal', 'lexa_map:stone_mountain', 'lexa_map:log_1_birch', 'lexa_map:leaves_birch', 'lexa_map:fern_teal', 'lexa_map:tall_grass_teal' },
{ 'air' },
{ 'air' }
}
@ -17,10 +17,11 @@ minetest.register_craftitem('lexa_hud:item_placeholder', {
stack_max = 1,
description = ' ',
short_description = ' ',
groups = { not_in_creative_inventory = 1 },
inventory_image = 'lexa_hud_item_placeholder.png',
on_place = function(_, player, target)
local name = player:get_player_name()
local menu = hud.state[name].menu_state
local menu = lexa.hud.state[name].menu_state
local inv = player:get_inventory()
local item = inv:get_stack('menu_category_' .. menu.selected._, menu.selected[menu.selected._])
local def = minetest.registered_items[item:get_name()]
@ -49,9 +50,9 @@ local function get_category_icon(i, active)
.. ',0=lexa_hud_category_icon.png^[multiply:' .. color .. ')'
end
table.insert(hud.callbacks.register, function(player)
table.insert(lexa.hud.callbacks.register, function(player)
local name = player:get_player_name()
local state = hud.state[name]
local state = lexa.hud.state[name]
local elems = state.elements
state.menu_state = {}
local menu = state.menu_state
@ -141,14 +142,16 @@ function render_selected(player, state, inv)
if elems.menu_selected then player:hud_remove(elems.menu_selected) end
if elems.menu_label then player:hud_remove(elems.menu_label) end
local item_def = minetest.registered_items[inv:get_stack('menu_category_' .. category_ind, item_ind):get_name()]
local item_iden = inv:get_stack('menu_category_' .. category_ind, item_ind):get_name()
local item_def = minetest.registered_items[item_iden]
assert(item_def, '[lexa_hud] item definition not found for \'' .. item_iden .. '\'.')
local item_name = item_def.description or item_def.name
local item_cost = get_cost_str(item_def._cost or {})
elems.menu_selected = player:hud_add({
hud_elem_type = 'image',
position = { x = 1, y = 0.5 },
text = 'hud_item_selected.png',
text = 'lexa_hud_item_selected.png',
scale = { x = 3, y = 3 },
z_index = 100,
alignment = { x = 1, y = 1 },
@ -159,7 +162,7 @@ function render_selected(player, state, inv)
elems.menu_label = player:hud_add({
hud_elem_type = 'image',
position = { x = 1, y = 0.5 },
text = text.render_text(item_name .. item_cost),
text = lexa.text.render_text(item_name .. item_cost),
scale = { x = 2, y = 2 },
alignment = { x = -1, y = -1 },
offset = { x = -CATEGORY_PADDING - 52,
@ -204,7 +207,7 @@ function render_categories(player, state, ind, last_ind)
end
minetest.register_globalstep(function(dtime)
for name, state in pairs(hud.state) do
for name, state in pairs(lexa.hud.state) do
local menu = state.menu_state
local player = minetest.get_player_by_name(name)

View File

@ -1,9 +1,9 @@
-- Register some glyphs used in the bar.
local path = minetest.get_modpath(minetest.get_current_modname()) .. '/textures/'
text.register_glyph('count_time', path .. 'lexa_hud_glyph_time.png')
text.register_glyph('count_wave', path .. 'lexa_hud_glyph_wave.png')
text.register_glyph('count_enemies', path .. 'lexa_hud_glyph_enemies.png')
text.register_glyph('count_wave_active', path .. 'lexa_hud_glyph_wave_active.png')
local glyph_path = minetest.get_modpath(minetest.get_current_modname()) .. '/textures/'
lexa.text.register_glyph('count_time', glyph_path .. 'lexa_hud_glyph_time.png')
lexa.text.register_glyph('count_wave', glyph_path .. 'lexa_hud_glyph_wave.png')
lexa.text.register_glyph('count_enemies', glyph_path .. 'lexa_hud_glyph_enemies.png')
lexa.text.register_glyph('count_wave_active', glyph_path .. 'lexa_hud_glyph_wave_active.png')
-- The width of the bar in pixels
local BAR_FULL_WIDTH = 239
@ -59,7 +59,7 @@ local function refresh_hud(force)
(status.wait > 0 and math.floor(status.wait) ~= math.floor(last_status.wait))
if wave_status_changed then
player:hud_change(elems.match_wave_status, 'text', text.render_text(
player:hud_change(elems.match_wave_status, 'text', lexa.text.render_text(
(status.wait == 0 and ('[!count_enemies] ' .. status.enemies)
or ('[!count_time] ' .. format_time(math.floor(status.wait)))) .. ' Remaining...'))
end
@ -70,7 +70,7 @@ local function refresh_hud(force)
last_status.wave ~= status.wave
if match_status_changed or wave_active_changed then
player:hud_change(elems.match_match_status, 'text', text.render_text('[!count_wave' ..
player:hud_change(elems.match_match_status, 'text', lexa.text.render_text('[!count_wave' ..
(status.wait == 0 and '_active' or '') .. '] Wave ' .. status.wave ..
(status.wave_max and status.wave_max > 0 and ('/' .. status.wave_max) or '')))
end
@ -80,7 +80,7 @@ local function refresh_hud(force)
end
-- Add the elements to the hud for the player specified.
table.insert(hud.callbacks.register, function(player)
table.insert(lexa.hud.callbacks.register, function(player)
local elems = lexa.hud.state[player:get_player_name()].elements
elems.match_bar_background = player:hud_add({

View File

@ -32,7 +32,7 @@ local function get_status_text()
str = str .. '[!ore_iridium][!ss][!ss]' .. status.iridium
end
return text.render_text(str)
return lexa.text.render_text(str)
end
local function refresh_hud(force)

View File

@ -20,7 +20,7 @@ end
-- Sets the hud state for the given player by name
--
function hud.set_active(name, active)
function lexa.hud.set_active(name, active)
if active and not lexa.hud.state[name] then
lexa.hud.state[name] = {
elements = {}
@ -40,6 +40,8 @@ minetest.register_chatcommand('mode_toggle', {
description = 'Toggle mode between build and game',
func = function(name)
lexa.hud.set_active(name, not lexa.hud.state[name])
local inv = minetest.get_player_by_name(name):get_inventory()
inv:set_list('hand', { 'lexa_base:hand_' .. (lexa.hud.state[name] and 'game' or 'build') })
end
})

View File

@ -2,13 +2,5 @@ lexa.map = {}
lexa.require('util')
lexa.require('ground')
lexa.require('ore')
lexa.require('decoration')
lexa.require('tree')
local glyph_path = minetest.get_modpath(minetest.get_current_modname()) .. '/textures/'
lexa.text.register_glyph('ore_copper', glyph_path .. 'lexa_map_glyph_ore_copper.png')
lexa.text.register_glyph('ore_titanium', glyph_path .. 'lexa_map_glyph_ore_titanium.png')
lexa.text.register_glyph('ore_cobalt', glyph_path .. 'lexa_map_glyph_ore_cobalt.png')
lexa.text.register_glyph('ore_iridium', glyph_path .. 'lexa_map_glyph_ore_iridium.png')

View File

@ -1,4 +1,4 @@
terrain.register_node_variations('fern', { 'green', 'teal' }, {
lexa.map.register_node_variations('fern', { 'green', 'teal' }, {
drawtype = 'mesh',
mesh = 'lexa_map_fern.b3d',
tiles = { 'lexa_map_fern' },
@ -10,11 +10,10 @@ terrain.register_node_variations('fern', { 'green', 'teal' }, {
selection_box = {
type = 'fixed',
fixed = { -4/16, -8/16, -4/16, 4/16, -4/16, 4/16 }
},
groups = { creative_dig = 1 }
}
})
terrain.register_node_variations('tall_grass', { 'green', 'teal' }, {
lexa.map.register_node_variations('tall_grass', { 'green', 'teal' }, {
drawtype = 'plantlike',
tiles = { 'lexa_map_tall_grass' },
use_texture_alpha = 'clip',
@ -27,7 +26,6 @@ terrain.register_node_variations('tall_grass', { 'green', 'teal' }, {
type = 'fixed',
fixed = { -7/16, -8/16, -7/16, 7/16, 0/16, 7/16 }
},
groups = { creative_dig = 1 },
on_construct = function(pos)
minetest.swap_node(pos, { name = minetest.get_node(pos).name, param2 = math.floor(math.random() * 24) * 20 })
print(minetest.get_node(pos).param2)

View File

@ -1,24 +1,20 @@
terrain.register_node_variations('stone', { 'base', 'beach', 'black', 'mountain', 'shist' }, {
tiles = { { name = 'lexa_map_stone', align_style = 'world', scale = 2 } },
groups = { creative_dig = 1 }
lexa.map.register_node_variations('stone', { 'base', 'beach', 'black', 'mountain', 'shist' }, {
tiles = { { name = 'lexa_map_stone', align_style = 'world', scale = 2 } }
})
terrain.register_node_variations('dirt', { 'beach' }, {
tiles = { { name = 'lexa_map_dirt', align_style = 'world', scale = 2 } },
groups = { creative_dig = 1 }
lexa.map.register_node_variations('dirt', { 'beach' }, {
tiles = { { name = 'lexa_map_dirt', align_style = 'world', scale = 2 } }
})
terrain.register_node_variations('sand', { 'beach' }, {
tiles = { { name = 'lexa_map_sand', align_style = 'world', scale = 2 } },
groups = { creative_dig = 1 }
lexa.map.register_node_variations('sand', { 'beach' }, {
tiles = { { name = 'lexa_map_sand', align_style = 'world', scale = 2 } }
})
terrain.register_node_variations('water', { 'deep', 'shallow' }, {
tiles = { 'lexa_map_water' },
groups = { creative_dig = 1 }
lexa.map.register_node_variations('water', { 'deep', 'shallow' }, {
tiles = { 'lexa_map_water' }
})
terrain.register_node_variations('grass', { 'green', 'teal' }, {
lexa.map.register_node_variations('grass', { 'green', 'teal' }, {
tiles = {
{ name = 'lexa_map_grass_top', align_style = 'world', scale = 4 },
{ name = 'lexa_map_grass_top', align_style = 'world', scale = 4 },
@ -29,16 +25,11 @@ terrain.register_node_variations('grass', { 'green', 'teal' }, {
}
return '([combine:16x16:0,0=' .. under[variant] .. ')^lexa_map_grass_side_' .. variant .. '.png'
end
},
groups = { creative_dig = 1 }
}
})
minetest.register_node('lexa_map:light', {
tiles = { 'lexa_map_light.png' },
description = 'Light',
light_source = minetest.LIGHT_MAX,
groups = { creative_dig = 1 }
light_source = minetest.LIGHT_MAX
})
minetest.register_alias('terrain:ground', 'lexa_map:light')

View File

@ -1,99 +1,98 @@
local ores = { 'coal', 'copper', 'titanium', 'cobalt', 'iridium' }
-- local ores = { 'coal', 'copper', 'titanium', 'cobalt', 'iridium' }
minetest.register_entity('lexa_map:ore_chunk', {
visual = 'mesh',
visual_size = vector.new(10, 10, 10),
mesh = 'lexa_map_chunk.b3d',
-- physical = true,
-- stepheight = 4.1/16,
static_save = false,
collisionbox = { -4/16, -8/16 -4/16, 4/16, -4/16, 4/16 },
selectionbox = { -4/16, -8/16, -4/16, 4/16, -4/16, 4/16 },
on_activate = function(self, static_data)
self.last_vel = vector.new(0, 0, 0)
self.death_time = 0
self.type = static_data
self.object:set_properties({ textures = { 'lexa_map_chunk_' .. self.type .. '.png' } })
self.object:set_rotation(vector.new(0, math.rad(math.floor(math.random() * 12) * 30), 0))
end,
on_punch = function(self)
self.object:remove()
end,
on_step = function(self, delta)
local node_pos = vector.round(vector.add(self.object:get_pos(), vector.new(0, -0.5, 0)))
if not self.conveyor_function or not self.last_pos or self.last_pos ~= node_pos then
self.conveyor_function = minetest.registered_nodes[minetest.get_node(node_pos).name]._conveyor_function or false
end
-- minetest.register_entity('lexa_map:ore_chunk', {
-- visual = 'mesh',
-- visual_size = vector.new(10, 10, 10),
-- mesh = 'lexa_map_chunk.b3d',
-- -- physical = true,
-- -- stepheight = 4.1/16,
-- static_save = false,
-- collisionbox = { -4/16, -8/16 -4/16, 4/16, -4/16, 4/16 },
-- selectionbox = { -4/16, -8/16, -4/16, 4/16, -4/16, 4/16 },
-- on_activate = function(self, static_data)
-- self.last_vel = vector.new(0, 0, 0)
-- self.death_time = 0
-- self.type = static_data
-- self.object:set_properties({ textures = { 'lexa_map_chunk_' .. self.type .. '.png' } })
-- self.object:set_rotation(vector.new(0, math.rad(math.floor(math.random() * 12) * 30), 0))
-- end,
-- on_punch = function(self)
-- self.object:remove()
-- end,
-- on_step = function(self, delta)
-- local node_pos = vector.round(vector.add(self.object:get_pos(), vector.new(0, -0.5, 0)))
-- if not self.conveyor_function or not self.last_pos or self.last_pos ~= node_pos then
-- self.conveyor_function = minetest.registered_nodes[minetest.get_node(node_pos).name]._conveyor_function or false
-- end
if self.conveyor_function and self.conveyor_function ~= false then
local found = false
local others = minetest.get_objects_inside_radius(
vector.add(self.object:get_pos(), vector.multiply(self.last_vel, 0.2)), 0.2)
for _, obj in ipairs(others) do
local lua = obj:get_luaentity()
if obj ~= self.object and lua and lua.name == 'lexa_map:ore_chunk' then
found = true
break
end
end
-- if self.conveyor_function and self.conveyor_function ~= false then
-- local found = false
-- local others = minetest.get_objects_inside_radius(
-- vector.add(self.object:get_pos(), vector.multiply(self.last_vel, 0.2)), 0.2)
-- for _, obj in ipairs(others) do
-- local lua = obj:get_luaentity()
-- if obj ~= self.object and lua and lua.name == 'lexa_map:ore_chunk' then
-- found = true
-- break
-- end
-- end
if not found then
self.conveyor_function(node_pos, self, delta)
self.last_vel = self.object:get_velocity()
else
self.object:set_velocity(vector.new(0, 0, 0))
end
else
self.death_time = self.death_time + delta
if self.death_time > 1 then
self.object:remove()
else
if self.death_time > 0.25 then
if (self.death_time * 5) % 2 < 0.75 then
if not self.hidden then
self.object:set_properties({ textures = { 'lexa_hud_hidden.png' } })
self.hidden = true
end
else
if self.hidden then
self.object:set_properties({ textures = { 'lexa_map_chunk_' .. self.type .. '.png' } })
self.hidden = false
end
end
end
-- if not found then
-- self.conveyor_function(node_pos, self, delta)
-- self.last_vel = self.object:get_velocity()
-- else
-- self.object:set_velocity(vector.new(0, 0, 0))
-- end
-- else
-- self.death_time = self.death_time + delta
-- if self.death_time > 1 then
-- self.object:remove()
-- else
-- if self.death_time > 0.25 then
-- if (self.death_time * 5) % 2 < 0.75 then
-- if not self.hidden then
-- self.object:set_properties({ textures = { 'lexa_hud_hidden.png' } })
-- self.hidden = true
-- end
-- else
-- if self.hidden then
-- self.object:set_properties({ textures = { 'lexa_map_chunk_' .. self.type .. '.png' } })
-- self.hidden = false
-- end
-- end
-- end
local obj_pos = self.object:get_pos()
obj_pos.y = node_pos.y + 0.99
-- local obj_pos = self.object:get_pos()
-- obj_pos.y = node_pos.y + 0.99
self.object:set_velocity(vector.new(0, 0, 0))
self.object:set_pos(obj_pos)
end
end
end,
get_staticdata = function(self)
return self.type
end
})
-- self.object:set_velocity(vector.new(0, 0, 0))
-- self.object:set_pos(obj_pos)
-- end
-- end
-- end,
-- get_staticdata = function(self)
-- return self.type
-- end
-- })
for _, type in ipairs(ores) do
terrain.register_node_variations('ore_' .. type, { 'base', 'beach', 'black', 'mountain', 'shist' }, {
drawtype = 'mesh',
mesh = 'lexa_map_ore.b3d',
tiles = {
{ name = 'lexa_map_stone', align_style = 'world', scale = 2 },
function() return 'lexa_map_ore_' .. type .. '.png' end
},
description = type .. ' Ore',
paramtype2 = 'facedir',
groups = { creative_dig = 1 }
})
end
-- for _, type in ipairs(ores) do
-- lexa.map.register_node_variations('ore_' .. type, { 'base', 'beach', 'black', 'mountain', 'shist' }, {
-- drawtype = 'mesh',
-- mesh = 'lexa_map_ore.b3d',
-- tiles = {
-- { name = 'lexa_map_stone', align_style = 'world', scale = 2 },
-- function() return 'lexa_map_ore_' .. type .. '.png' end
-- },
-- description = type .. ' Ore',
-- paramtype2 = 'facedir'
-- })
-- end
minetest.register_chatcommand('spawnore', {
params = '<type>',
description = 'Spawns an ore chunk',
func = function(name, type)
local player = minetest.get_player_by_name(name)
minetest.add_entity(vector.round(player:get_pos()), 'lexa_map:ore_chunk', type)
end
})
-- minetest.register_chatcommand('spawnore', {
-- params = '<type>',
-- description = 'Spawns an ore chunk',
-- func = function(name, type)
-- local player = minetest.get_player_by_name(name)
-- minetest.add_entity(vector.round(player:get_pos()), 'lexa_map:ore_chunk', type)
-- end
-- })

View File

@ -10,7 +10,6 @@ lexa.map.register_node_variations('log_' .. 1, { 'birch', 'palm' }, table.merge(
'[combine:26x16:0,' .. (-(4 - 1) * 16) .. '=lexa_map_log_side',
'lexa_map_log_top'
},
groups = { creative_dig = 1 },
on_construct = function(pos)
local i = pos.y % 4 + 1
minetest.swap_node(pos, { name = minetest.get_node(pos).name:gsub('_1', '_' .. i) })
@ -23,7 +22,7 @@ for i = 2, 4 do
'[combine:26x16:0,' .. (-(4 - i) * 16) .. '=lexa_map_log_side',
'lexa_map_log_top'
},
groups = { creative_dig = 1, not_in_creative_inventory = 1 },
groups = { build_dig = 1, not_in_creative_inventory = 1 },
on_construct = function(pos)
local i = pos.y % 4 + 1
minetest.swap_node(pos, { name = minetest.get_node(pos).name:gsub('_1', '_' .. i) })
@ -35,6 +34,5 @@ lexa.map.register_node_variations('leaves', { 'birch', 'palm' }, {
description = 'Leaves',
drawtype = 'allfaces',
paramtype = 'light',
tiles = { 'lexa_map_leaves' },
groups = { creative_dig = 1 }
tiles = { 'lexa_map_leaves' }
})

View File

@ -1,7 +1,7 @@
function lexa.map.register_node_variations(name, variations, def)
for _, variant in ipairs(variations) do
local identifier = 'lexa_map:' .. name .. '_' .. variant
local name = util.title_case(variant) .. ' ' .. util.title_case(name)
local description = lexa.util.title_case(variant) .. ' ' .. lexa.util.title_case(name)
local tiles = table.copy(def.tiles)
for i, tile in ipairs(tiles) do
@ -14,12 +14,12 @@ function lexa.map.register_node_variations(name, variations, def)
end
end
minetest.register_node(identifier, table.merge(def, {
description = name,
minetest.register_node(identifier, table.merge({
groups = { build_dig = 1 }
}, table.merge(def, {
description = description,
tiles = tiles,
drop = ''
}))
minetest.register_alias('terrain:' .. name .. '_' .. variant, identifier)
})))
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 B

View File

@ -1,3 +1,5 @@
-- lexa.require('')
local waves = {
wave_start = 0,
wave_max = 10,

5
mods/lexa_match/mod.conf Normal file
View File

@ -0,0 +1,5 @@
title = Match
name = lexa_match
author = Aurailus
description = Controls enemy spawning, material counts, and stuffs like that.
depends = lexa_base

View File

@ -0,0 +1,5 @@
lexa.materials = {}
lexa.require('ore')
lexa.require('chunk')
lexa.require('register')

View File

@ -0,0 +1,5 @@
title = Materials
name = lexa_materials
author = Aurailus
description = Registers ores and their materials.
depends = lexa_base, lexa_map, lexa_text, lexa_conveyor

View File

@ -0,0 +1,25 @@
minetest.register_entity('lexa_materials:ore_chunk', {
visual = 'mesh',
mesh = 'lexa_materials_chunk.b3d',
visual_size = vector.new(10, 10, 10),
collisionbox = { -4/16, -8/16 -4/16, 4/16, -4/16, 4/16 },
selectionbox = { -4/16, -8/16, -4/16, 4/16, -4/16, 4/16 },
on_activate = function(self, static_data)
lexa.conveyor.entity.on_activate(self)
self.type = static_data
self.object:set_properties({ textures = { 'lexa_materials_chunk_' .. self.type .. '.png' } })
self.object:set_rotation(vector.new(0, math.rad(math.floor(math.random() * 12) * 30), 0))
end,
on_punch = function(self) self.object:remove() end,
on_step = lexa.conveyor.entity.on_step,
get_staticdata = function(self) return self.type end
})
minetest.register_chatcommand('spawn_ore', {
params = '<type>',
description = 'Spawns an ore chunk',
func = function(name, type)
local player = minetest.get_player_by_name(name)
minetest.add_entity(vector.round(player:get_pos()), 'lexa_materials:ore_chunk', type)
end
})

View File

@ -0,0 +1,19 @@
lexa.materials.register_ore = function(type)
for _, stone in ipairs({ 'base', 'beach', 'black', 'mountain', 'shist' }) do
minetest.register_node('lexa_materials:ore_' .. type .. '_' .. stone, {
description = lexa.util.title_case(stone) .. ' ' .. lexa.util.title_case(type) .. ' Ore',
drawtype = 'mesh',
mesh = 'lexa_materials_ore.b3d',
tiles = {
{ name = 'lexa_map_stone_' .. stone .. '.png', align_style = 'world', scale = 2 },
'lexa_materials_ore_' .. type .. '.png'
},
paramtype2 = 'facedir',
groups = {
build_dig = 1,
ore = 1
},
_ore_type = type
})
end
end

View File

@ -0,0 +1,12 @@
local glyph_path = minetest.get_modpath(minetest.get_current_modname()) .. '/textures/'
lexa.materials.register = function(name)
lexa.materials.register_ore(name)
lexa.text.register_glyph('ore_' .. name, glyph_path .. 'lexa_materials_glyph_ore_' .. name .. '.png')
end
lexa.materials.material_list = { 'coal', 'copper', 'titanium', 'cobalt', 'iridium' }
for _, material in ipairs(lexa.materials.material_list) do
lexa.materials.register(material)
end

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -47,7 +47,7 @@ minetest.register_chatcommand('test_paths', {
pos = node,
size = 16,
expirationtime = 3,
texture = 'navigation_indicator.png'
texture = 'lexa_nav_indicator.png'
})
end
@ -60,7 +60,7 @@ minetest.register_chatcommand('test_paths', {
})
minetest.after(1, function()
navigation.load_area(map_min, vector.add(map_min, map_size), function(_, loaded, forceload_duration)
lexa.nav.load_area(map_min, vector.add(map_min, map_size), function(_, loaded, forceload_duration)
-- minetest.chat_send_all('Force loaded ' .. loaded .. ' blocks in ' .. forceload_duration .. 'ms.')
init_graph()
end)

View File

@ -79,7 +79,7 @@ function lexa.nav.build_graph(start)
if not graph.nodes[pos.y][pos.x] then graph.nodes[pos.y][pos.x] = {} end
if not graph.nodes[pos.y][pos.x][pos.z] then graph.nodes[pos.y][pos.x][pos.z] = BASE_COST end
for adj, _ in pairs(navigation.adjacent_list) do
for adj, _ in pairs(lexa.nav.adjacent_list) do
local adj_pos = { x = pos.x + adj.x, y = pos.y + adj.y, z = pos.z + adj.z }
local adj_pos_str = minetest.pos_to_string(adj_pos)

View File

@ -28,7 +28,7 @@ function register_nav_node(def)
spawn = def.spawn
}
minetest.register_node('navigation:' .. def.name, {
minetest.register_node('lexa_nav:' .. def.name, {
description = def.name,
drawtype = 'glasslike_framed',
tiles = {
@ -43,7 +43,7 @@ function register_nav_node(def)
nav_node = 1,
nav_traversable = def.traversable and 1 or 0,
nav_visible = 1,
creative_dig = 1
build_dig = 1
},
_navigation = navigation,
on_place = function(stack, player, target)
@ -66,7 +66,7 @@ function register_nav_node(def)
nav_node = 1,
nav_traversable = def.traversable and 1 or 0,
nav_hidden = 1,
creative_dig = 1,
build_dig = 1,
not_in_creative_inventory = 1
},
_navigation = navigation
@ -123,7 +123,7 @@ register_nav_node({
})
register_nav_node({
name = 'nav_positive_magnet',
name = 'magnet_pos',
color = '#3DFF7E',
traversable = true,
placeable = true,
@ -131,7 +131,7 @@ register_nav_node({
})
register_nav_node({
name = 'nav_negative_magnet',
name = 'magnet_neg',
color = '#F56642',
traversable = true,
placeable = true,
@ -145,14 +145,14 @@ register_nav_node({
})
register_nav_node({
name = 'player_spawn',
name = 'spawn_player',
color = '#FFED47',
traversable = true,
spawn = 'player'
})
register_nav_node({
name = 'enemy_spawn',
name = 'spawn_enemy',
color = '#C53DFF',
traversable = true,
spawn = 'enemy'
@ -164,3 +164,10 @@ minetest.register_alias('navigation:nav_negative_magnet', 'lexa_nav:magnet_neg')
minetest.register_alias('navigation:barrier', 'lexa_nav:barrier')
minetest.register_alias('navigation:player_spawn', 'lexa_nav:spawn_player')
minetest.register_alias('navigation:enemy_spawn', 'lexa_nav:spawn_enemy')
minetest.register_alias('navigation:nav_hidden', 'lexa_nav:ground_hidden')
minetest.register_alias('navigation:nav_positive_magnet_hidden', 'lexa_nav:magnet_pos_hidden')
minetest.register_alias('navigation:nav_negative_magnet_hidden', 'lexa_nav:magnet_neg_hidden')
minetest.register_alias('navigation:barrier_hidden', 'lexa_nav:barrier_hidden')
minetest.register_alias('navigation:player_spawn_hidden', 'lexa_nav:spawn_player_hidden')
minetest.register_alias('navigation:enemy_spawn_hidden', 'lexa_nav:spawn_enemy_hidden')

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -5,4 +5,4 @@ function lexa.text.register_glyph(name, path)
lexa.text.glyphs[name] = { file = file, width = lexa.text.get_file_width(path) }
end
lexa.text.register_glyph('ss', minetest.get_modpath('lexa_text') .. '/textures/text_ss.png')
lexa.text.register_glyph('ss', minetest.get_modpath('lexa_text') .. '/textures/lexa_text_ss.png')

View File

@ -3,7 +3,7 @@ lexa.text.char_widths = {}
local modpath = minetest.get_modpath('lexa_text') .. '/textures/'
for _, path in ipairs(minetest.get_dir_list(modpath, false)) do
local name = path:match('ch_([^%.]+)%.png')
if name then lexa.text.char_widths[name] = lexa.text.get_file_width(modpath .. 'text_' .. name .. '.png') end
if name then lexa.text.char_widths[name] = lexa.text.get_file_width(modpath .. 'ch_' .. name .. '.png') end
end
function lexa.text.render_text(text)
@ -24,7 +24,7 @@ function lexa.text.render_text(text)
if not glyph_tbl then
print('Glyph not found: ' .. glyph)
name = 'text_unknown.png'
name = 'ch_unknown.png'
width = 5
else
name = glyph_tbl.file
@ -34,7 +34,7 @@ function lexa.text.render_text(text)
else
local alias = lexa.text.char_aliases[char] or char
width = (lexa.text.char_widths[alias] or 1) - 1
name = 'text_' .. alias .. '.png'
name = 'ch_' .. alias .. '.png'
i = i + 1
end

View File

@ -1,4 +1,5 @@
local lexa.text.char_aliases = {
-- A list of character -> filename aliases, for symbol characters.
lexa.text.char_aliases = {
[' '] = 'space',
['!'] = 'exc',
['"'] = 'quote',
@ -33,8 +34,10 @@ local lexa.text.char_aliases = {
['~'] = 'tilde'
}
-- Returns the width of a png image located at `path`.
function lexa.text.get_file_width(path)
local f = io.open(path, 'rb')
assert(f, '[lexa_text] file \'' .. path .. '\' not found.')
f:seek('set', 16)
return tonumber(string.format('0x%x%x%x%x', f:read(4):byte(1, 4)))
end

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -33,7 +33,7 @@ minetest.register_node('lexa_wall:ladder', {
node_box = node_box_ladder,
climbable = true,
groups = {
creative_dig = 1,
dig_game = 1,
attached_node = 1
},
drop = '',

View File

@ -68,7 +68,7 @@ for _, type in ipairs({ 'copper', 'titanium', 'cobalt' }) do
connects_to = { 'group:wall_bottom' },
drop = '',
groups = {
creative_dig = 1,
dig_game = 1,
wall_bottom = 1,
wall = 1
},
@ -91,7 +91,7 @@ for _, type in ipairs({ 'copper', 'titanium', 'cobalt' }) do
drop = '',
groups = {
not_in_creative_inventory = 1,
creative_dig = 1,
dig_game = 1,
wall_top = 1,
wall = 1
}

11
workspace.code-workspace Normal file
View File

@ -0,0 +1,11 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 100
}
}