diff --git a/game.conf b/game.conf index 5cf1691..54f7ccd 100644 --- a/game.conf +++ b/game.conf @@ -1,5 +1,5 @@ name = Lexa description = Lexa lexa lexa allowed_mapgens = singlenode -disabled_settings=!enable_damage, !creative_mode +disabled_settings = !enable_damage, !creative_mode author = Aurailus diff --git a/minetest.conf b/minetest.conf index 3d44ddb..5d57ac3 100644 --- a/minetest.conf +++ b/minetest.conf @@ -1,5 +1,4 @@ time_speed = 0 -max_forceloaded_blocks = 10000 -active_object_send_range_blocks = 8 active_block_range = 16 recent_chat_messages = 0 +active_object_send_range_blocks = 8 diff --git a/mods/lexa_base/init.lua b/mods/lexa_base/init.lua index 7796bd9..db53340 100644 --- a/mods/lexa_base/init.lua +++ b/mods/lexa_base/init.lua @@ -14,3 +14,4 @@ end lexa.require('settings') lexa.require('util') lexa.require('hand') +lexa.require('privilege') diff --git a/mods/lexa_base/script/hand.lua b/mods/lexa_base/script/hand.lua index ce284da..c599831 100644 --- a/mods/lexa_base/script/hand.lua +++ b/mods/lexa_base/script/hand.lua @@ -13,7 +13,7 @@ minetest.register_tool('lexa_base:hand_game', { } }, groups = { - -- not_in_creative_inventory = 1 + not_in_creative_inventory = 1 } }) @@ -29,15 +29,23 @@ minetest.register_tool('lexa_base:hand_build', { } }, groups = { - -- not_in_creative_inventory = 1 + not_in_creative_inventory = 1 } }) --- Update the player's hand on join. +-- Update the player's hand and inventory on join. minetest.register_on_joinplayer(function(player) local inv = player:get_inventory() inv:set_size('hand', 1) inv:set_list('hand', { 'lexa_base:hand_game' }) + + player:set_clouds({ + density = 0.4, + height = 140, + speed = { x = 1, z = 1 } + }) + + player:set_armor_groups({ immortal = 1 }) end) -- Don't consume items on place. diff --git a/mods/lexa_base/script/privilege.lua b/mods/lexa_base/script/privilege.lua new file mode 100644 index 0000000..e2d754e --- /dev/null +++ b/mods/lexa_base/script/privilege.lua @@ -0,0 +1,4 @@ +minetest.register_privilege('cheats', { + description = 'Allows the player to use cheat commands.', + give_to_singleplayer = false +}) diff --git a/mods/lexa_conveyor/models/lexa_conveyor_machine.b3d b/mods/lexa_conveyor/models/lexa_conveyor_machine.b3d index 1d19dd9..37d7cf2 100644 Binary files a/mods/lexa_conveyor/models/lexa_conveyor_machine.b3d and b/mods/lexa_conveyor/models/lexa_conveyor_machine.b3d differ diff --git a/mods/lexa_enemy/script/enemy/spider.lua b/mods/lexa_enemy/script/enemy/spider.lua index 7b50d6d..799f442 100644 --- a/mods/lexa_enemy/script/enemy/spider.lua +++ b/mods/lexa_enemy/script/enemy/spider.lua @@ -70,9 +70,10 @@ minetest.register_entity('lexa_enemy:spider', { }) -minetest.register_chatcommand('spawnenemy', { - params = '', - description = 'Spawns an enemy', +minetest.register_chatcommand('spawn_enemy', { + params = '', + privs = { cheats = true }, + description = 'Spawns an enemy at the player\'s position.', func = function(name, type) local player = minetest.get_player_by_name(name) minetest.add_entity(vector.round(player:get_pos()), 'lexa_enemy:spider', type) diff --git a/mods/lexa_hud/init.lua b/mods/lexa_hud/init.lua index c410aad..bb60fed 100644 --- a/mods/lexa_hud/init.lua +++ b/mods/lexa_hud/init.lua @@ -1,6 +1,7 @@ lexa.hud = {} lexa.require('state') +lexa.require('inventory') lexa.require('match_bar') lexa.require('build_menu') lexa.require('material_status') diff --git a/mods/lexa_hud/script/build_menu.lua b/mods/lexa_hud/script/build_menu.lua index 6edb7a4..d7da936 100644 --- a/mods/lexa_hud/script/build_menu.lua +++ b/mods/lexa_hud/script/build_menu.lua @@ -8,9 +8,9 @@ local item_lists = { { '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' } + -- { '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' }, + { 'lexa_turret:turret_base' }, + { 'lexa_tools:pickaxe', 'lexa_tools:wrench' } } minetest.register_craftitem('lexa_hud:item_placeholder', { @@ -65,7 +65,7 @@ table.insert(lexa.hud.callbacks.register, function(player) menu.selected = { _ = 1 } menu.ind = 1 - for i = 6, 1, -1 do + for i = 5, 1, -1 do menu.selected[i] = 1 elems['menu_category_' .. i] = player:hud_add({ hud_elem_type = 'image', @@ -73,7 +73,7 @@ table.insert(lexa.hud.callbacks.register, function(player) text = get_category_icon(i), scale = { x = 3, y = 3 }, alignment = { x = -1, y = -1 }, - offset = { x = -CATEGORY_PADDING, y = -(6 - i) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 5 / 2 } + offset = { x = -CATEGORY_PADDING, y = -(5 - i) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 4 / 2 } }) end @@ -156,7 +156,7 @@ function render_selected(player, state, inv) z_index = 100, alignment = { x = 1, y = 1 }, offset = { x = -80 - 19 * 3 * (inv_size - item_ind + 1), - y = -48 - (6 - category_ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 5 / 2 } + y = -48 - (5 - category_ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 4 / 2 } }) elems.menu_label = player:hud_add({ @@ -166,7 +166,7 @@ function render_selected(player, state, inv) scale = { x = 2, y = 2 }, alignment = { x = -1, y = -1 }, offset = { x = -CATEGORY_PADDING - 52, - y = -(6 - category_ind) * (36 + CATEGORY_SPACING) - LABEL_BUFFER + (36 + CATEGORY_SPACING) * 5 / 2 } + y = -(5 - category_ind) * (36 + CATEGORY_SPACING) - LABEL_BUFFER + (36 + CATEGORY_SPACING) * 4 / 2 } }) end @@ -191,17 +191,17 @@ function render_categories(player, state, ind, last_ind) scale = { x = 3, y = 3 }, alignment = { x = 1, y = 1 }, offset = { x = -80 - 19 * 3 * size, - y = -48 - (6 - ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 5 / 2 } + y = -48 - (5 - ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 4 / 2 } }) - -- elems.menu_list_inventory = player:hud_add({ - -- hud_elem_type = 'inventory', - -- text = 'menu_category_' .. ind, - -- number = size, - -- position = { x = 1, y = 0.5 }, - -- offset = { x = -80 + 1 - 19 * 3 * size, - -- y = -48 - (6 - ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 5 / 2 } - -- }) + elems.menu_list_inventory = player:hud_add({ + hud_elem_type = 'inventory', + text = 'menu_category_' .. ind, + number = size, + position = { x = 1, y = 0.5 }, + offset = { x = -80 + 1 - 19 * 3 * size, + y = -48 - (5 - ind) * (36 + CATEGORY_SPACING) + (36 + CATEGORY_SPACING) * 4 / 2 } + }) render_selected(player, state, inv) end @@ -243,7 +243,7 @@ minetest.register_globalstep(function(dtime) render_selected(player, state, inv) else local last_ind = menu.selected._ - menu.selected._ = (menu.selected._ + ind_delta - 1) % 6 + 1 + menu.selected._ = (menu.selected._ + ind_delta - 1) % 5 + 1 render_categories(player, state, menu.selected._, last_ind) end diff --git a/mods/lexa_hud/script/inventory.lua b/mods/lexa_hud/script/inventory.lua new file mode 100644 index 0000000..4e3af9c --- /dev/null +++ b/mods/lexa_hud/script/inventory.lua @@ -0,0 +1,30 @@ +local default_formspec = nil + +table.insert(lexa.hud.callbacks.register, function(player) + local function update_formspec() + player:set_inventory_formspec([[ + formspec_version[3] + size[4,2] + button_exit[1,0.5;2,1;lexa_respawn;Respawn] + label[1.3, 1.75;Lexa v 0.0.1] + ]]) + end + + if not default_formspec then + minetest.after(0.01, function() + default_formspec = player:get_inventory_formspec() + update_formspec() + end) + else + update_formspec() + end +end) + +table.insert(lexa.hud.callbacks.unregister, function(player) + player:set_inventory_formspec(default_formspec) +end) + +minetest.register_on_player_receive_fields(function(player, name, fields) + if name ~= '' or not fields.lexa_respawn then return end + lexa.match.respawn(player:get_player_name()) +end) diff --git a/mods/lexa_hud/script/match_bar.lua b/mods/lexa_hud/script/match_bar.lua index 61c890a..588433b 100644 --- a/mods/lexa_hud/script/match_bar.lua +++ b/mods/lexa_hud/script/match_bar.lua @@ -131,15 +131,6 @@ table.insert(lexa.hud.callbacks.register, function(player) refresh_hud(true) end) -minetest.register_chatcommand('set_status', { - params = ' ', - func = function(name, param) - local key, value = param:match('^(%S+)%s+(.+)$') - status[key] = tonumber(value) - refresh_hud() - end -}) - minetest.register_globalstep(function(delta) status.wait = math.max(0, status.wait - delta) if not last_status or math.ceil(status.wait * 10) ~= math.ceil(last_status.wait * 10) then refresh_hud() end diff --git a/mods/lexa_hud/script/material_status.lua b/mods/lexa_hud/script/material_status.lua index c7b4ae0..5fc0a79 100644 --- a/mods/lexa_hud/script/material_status.lua +++ b/mods/lexa_hud/script/material_status.lua @@ -1,48 +1,33 @@ -local status = { - copper = 16, - titanium = 200, - cobalt = 99, - iridium = 34 -} - -local hud_status = {} - -local last_status = nil +local materials = {} local function get_status_text() - if not status.copper and not status.titanium and not status.cobalt and not status.iridium then - return '' + if not materials.copper and not materials.titanium and not materials.cobalt and not materials.iridium then + return lexa.text.render_text('') end local str = '' - if status.copper then - str = str .. '[!ore_copper][!ss][!ss]' .. status.copper + if materials.copper then + str = str .. '[!ore_copper][!ss][!ss]' .. materials.copper end - if status.titanium then - if status.copper then str = str .. ' ' end - str = str .. '[!ore_titanium][!ss][!ss]' .. status.titanium + if materials.titanium then + if materials.copper then str = str .. ' ' end + str = str .. '[!ore_titanium][!ss][!ss]' .. materials.titanium end - if status.cobalt then - if status.copper or status.titanium then str = str .. ' ' end - str = str .. '[!ore_cobalt][!ss][!ss]' .. status.cobalt + if materials.cobalt then + if materials.copper or materials.titanium then str = str .. ' ' end + str = str .. '[!ore_cobalt][!ss][!ss]' .. materials.cobalt end - if status.iridium then - if status.copper or status.titanium or status.cobalt then str = str .. ' ' end - str = str .. '[!ore_iridium][!ss][!ss]' .. status.iridium + if materials.iridium then + if materials.copper or materials.titanium or status.cobalt then str = str .. ' ' end + str = str .. '[!ore_iridium][!ss][!ss]' .. materials.iridium end return lexa.text.render_text(str) end -local function refresh_hud(force) - local changed = not last_status or - last_status.copper ~= status.copper or - last_status.titanium ~= status.titanium or - last_status.cobalt ~= status.cobalt or - last_status.iridium ~= status.iridium - - if not changed and not force then return end +function lexa.hud.update_materials(new) + materials = new local text, width = get_status_text() local bar_width = width * 2/3 + 12 @@ -51,13 +36,15 @@ local function refresh_hud(force) local elems = state.elements local player = minetest.get_player_by_name(name) - player:hud_change(elems.material_background, 'text', '[combine:' .. bar_width .. - 'x12:0,0=lexa_hud_materials_left.png:4,0=lexa_hud_materials_middle.png\\^[resize\\:' .. - (bar_width - 8) .. 'x12:' .. (bar_width - 4) .. ',0=lexa_hud_materials_right.png') + if width == 0 then + player:hud_change(elems.material_background, 'text', 'lexa_hud_hidden.png') + else + player:hud_change(elems.material_background, 'text', '[combine:' .. bar_width .. + 'x12:0,0=lexa_hud_materials_left.png:4,0=lexa_hud_materials_middle.png\\^[resize\\:' .. + (bar_width - 8) .. 'x12:' .. (bar_width - 4) .. ',0=lexa_hud_materials_right.png') + end player:hud_change(elems.material_text, 'text', text) - - last_status = table.copy(status) end end @@ -83,5 +70,5 @@ table.insert(lexa.hud.callbacks.register, function(player) offset = { x = 0, y = -13 } }) - refresh_hud(true) + lexa.hud.update_materials(materials) end) diff --git a/mods/lexa_hud/script/state.lua b/mods/lexa_hud/script/state.lua index 3ab8266..0f8a6c4 100644 --- a/mods/lexa_hud/script/state.lua +++ b/mods/lexa_hud/script/state.lua @@ -36,8 +36,9 @@ end -- Register a command to allow manually switching modes -- -minetest.register_chatcommand('mode_toggle', { - description = 'Toggle mode between build and game', +minetest.register_chatcommand('toggle_mode', { + description = 'Toggles the player\'s mode between build and game', + privs = { cheats = true }, func = function(name) lexa.hud.set_active(name, not lexa.hud.state[name]) local inv = minetest.get_player_by_name(name):get_inventory() diff --git a/mods/lexa_hud/textures/lexa_hud_category_icon.png b/mods/lexa_hud/textures/lexa_hud_category_icon.png index a95cded..9203464 100644 Binary files a/mods/lexa_hud/textures/lexa_hud_category_icon.png and b/mods/lexa_hud/textures/lexa_hud_category_icon.png differ diff --git a/mods/lexa_hud/textures/lexa_hud_category_icon_full.png b/mods/lexa_hud/textures/lexa_hud_category_icon_full.png new file mode 100644 index 0000000..a95cded Binary files /dev/null and b/mods/lexa_hud/textures/lexa_hud_category_icon_full.png differ diff --git a/mods/lexa_map/maps/mountain.meta.lua b/mods/lexa_map/maps/mountain.meta.lua new file mode 100644 index 0000000..ba57897 --- /dev/null +++ b/mods/lexa_map/maps/mountain.meta.lua @@ -0,0 +1,4 @@ +return { + size = { x = 320, y = 153, z = 323 }, + spawn = { x = 86, y = 39, z = 127 } +} diff --git a/mods/lexa_map/maps/mountain.mts b/mods/lexa_map/maps/mountain.mts new file mode 100644 index 0000000..edd940b Binary files /dev/null and b/mods/lexa_map/maps/mountain.mts differ diff --git a/mods/lexa_map/maps/mountain_old.mts b/mods/lexa_map/maps/mountain_old.mts new file mode 100644 index 0000000..693f1e9 Binary files /dev/null and b/mods/lexa_map/maps/mountain_old.mts differ diff --git a/mods/lexa_map/script/ground.lua b/mods/lexa_map/script/ground.lua index 39a2013..8eebcc9 100644 --- a/mods/lexa_map/script/ground.lua +++ b/mods/lexa_map/script/ground.lua @@ -14,16 +14,19 @@ lexa.map.register_node_variations('water', { 'deep', 'shallow' }, { tiles = { 'lexa_map_water' } }) +local grass_under = { + green = 'lexa_map_dirt_beach.png', + teal = 'lexa_map_stone_mountain.png' +} + 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 }, function(variant) - local under = { - green = 'lexa_map_dirt_beach.png', - teal = 'lexa_map_stone_mountain.png' - } - return '([combine:16x16:0,0=' .. under[variant] .. ')^lexa_map_grass_side_' .. variant .. '.png' + return { name = grass_under[variant], scale = 2 } + end, + function(variant) + return '([combine:16x16:0,0=' .. grass_under[variant] .. ')^lexa_map_grass_side_' .. variant .. '.png' end } }) @@ -31,5 +34,6 @@ lexa.map.register_node_variations('grass', { 'green', 'teal' }, { minetest.register_node('lexa_map:light', { tiles = { 'lexa_map_light.png' }, description = 'Light', + groups = { dig_build = 1 }, light_source = minetest.LIGHT_MAX }) diff --git a/mods/lexa_map/script/ore.lua b/mods/lexa_map/script/ore.lua deleted file mode 100644 index 1a72170..0000000 --- a/mods/lexa_map/script/ore.lua +++ /dev/null @@ -1,98 +0,0 @@ --- 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 - --- 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 - --- 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 --- }) - --- 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 = '', --- 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 --- }) diff --git a/mods/lexa_map/script/util.lua b/mods/lexa_map/script/util.lua index 3aa5f19..646b097 100644 --- a/mods/lexa_map/script/util.lua +++ b/mods/lexa_map/script/util.lua @@ -15,7 +15,7 @@ function lexa.map.register_node_variations(name, variations, def) end minetest.register_node(identifier, table.merge({ - groups = { build_dig = 1 } + groups = { dig_build = 1 } }, table.merge(def, { description = description, tiles = tiles, diff --git a/mods/lexa_match/init.lua b/mods/lexa_match/init.lua index 1c04ebd..e9458cc 100644 --- a/mods/lexa_match/init.lua +++ b/mods/lexa_match/init.lua @@ -1,37 +1,37 @@ --- lexa.require('') +lexa.require('init') -local waves = { - wave_start = 0, - wave_max = 10, - wave_cooldown = 60 * 3, - wave_cooldown_difficulty_factor = 0.9, +-- local waves = { +-- wave_start = 0, +-- wave_max = 10, +-- wave_cooldown = 60 * 3, +-- wave_cooldown_difficulty_factor = 0.9, - difficulty_incr = 0.1, - difficulty_max = 100, +-- difficulty_incr = 0.1, +-- difficulty_max = 100, - enemies = { - bomber = { - difficulty_min = 0, - difficulty_cost = 1, - }, - gunner = { - difficulty_min = 20, - difficulty_cost = 3, - } - }, +-- enemies = { +-- bomber = { +-- difficulty_min = 0, +-- difficulty_cost = 1, +-- }, +-- gunner = { +-- difficulty_min = 20, +-- difficulty_cost = 3, +-- } +-- }, - spawns = { - [1] = { - difficulty_min = 0 - }, - [2] = { - difficulty_min = 10 - }, - [3] = { - difficulty_min = 100 - }, - [4] = { - difficulty_min = 100 - } - } -} +-- spawns = { +-- [1] = { +-- difficulty_min = 0 +-- }, +-- [2] = { +-- difficulty_min = 10 +-- }, +-- [3] = { +-- difficulty_min = 100 +-- }, +-- [4] = { +-- difficulty_min = 100 +-- } +-- } +-- } diff --git a/mods/lexa_match/mod.conf b/mods/lexa_match/mod.conf index ebc38e0..c2c9a0c 100644 --- a/mods/lexa_match/mod.conf +++ b/mods/lexa_match/mod.conf @@ -2,4 +2,4 @@ title = Match name = lexa_match author = Aurailus description = Controls enemy spawning, material counts, and stuffs like that. -depends = lexa_base +depends = lexa_base, lexa_nav diff --git a/mods/lexa_match/script/init.lua b/mods/lexa_match/script/init.lua new file mode 100644 index 0000000..889dbf8 --- /dev/null +++ b/mods/lexa_match/script/init.lua @@ -0,0 +1,137 @@ +lexa.match = {} + +-- +-- The main status object, contains information relating to the current match. +-- If nil, no match has been started. Can be initialized by calling lexa.match.start_match(). +-- +-- # Properties +-- +-- ## def +-- +-- A definition table containing the match's parameters. +-- +-- map: string, The map name, default, default 'mountain'. +-- waves: number, The number of waves in the match, default 10. +-- wait: number, The time between waves, default 180. +-- enemies_initial: number, The number of enemies in each wave, default 10. +-- enemies_mult: number, The number of additional enemies to add each wave, default 5. +-- materials: table, A materials table (defined below) of initial materials, default nil. +-- +-- ## map_meta +-- +-- size: vector, the dimensions of the map +-- spawn: vector, the position of the player spawn +-- +-- ## status +-- +-- Information about the current wave time, enemies, and count. +-- +-- wave: number, The current wave number. +-- wave_max: number, The maximum number of waves. +-- wait: number, The time until the enemies spawn, if 0 they have spawned. +-- wait_max: number, The full timer value. +-- enemies: number, The number of enemies remaining. +-- enemies_max: number, The initial number of enemies spawned. +-- +-- ## materials +-- +-- A key-value table of materials and their counts. +-- If a count is nil, it should be treated as 0 and not displayed on the hud. +-- +-- ## Graph +-- +-- A graph representation of the map, for enemy pathfinding. +-- + +lexa.match.state = nil + +-- The root directory for map files. +local map_root = minetest.get_modpath('lexa_map') .. '/maps/' + +-- +-- Starts a match based on the provided definitions. +-- +-- # Definition keys: +-- +-- waves: The number of waves in the match, default 10. +-- wait: The time between waves, default 180. +-- enemies_initial: The number of enemies in each wave, default 10. +-- enemies_mult: The number of additional enemies to add each wave, default 5. +-- materials: A materials object of initial materials, default nil. +-- + +lexa.match.start_match = function(def) + minetest.chat_send_all(' ') + minetest.chat_send_all('Starting match...') + minetest.chat_send_all(' ') + + def.map = def.map or 'mountain' + local map_meta = dofile(map_root .. def.map .. '.meta.lua') + minetest.place_schematic(vector.new(0, 0, 0), map_root .. def.map .. '.mts') + + for _, player in ipairs(minetest.get_connected_players()) do player:set_pos(map_meta.spawn) end + + lexa.match.state = { + def = def, + map_meta = map_meta, + status = { + wave = 1, + wave_max = def.waves or 10, + wait = def.wait or 180, + wait_max = def.wait or 180, + enemies = 0, + enemies_max = 0 + }, + materials = def.materials or {}, + graph = lexa.nav.build_graph(map_meta.spawn) + } + + lexa.hud.update_materials(lexa.match.state.materials) + + minetest.chat_send_all(' ') + minetest.chat_send_all('Match started, have fun!') + minetest.chat_send_all(' ') + minetest.after(5, function() minetest.chat_send_all(' ') end) +end + +minetest.register_on_joinplayer(function() + if lexa.match.state then return end + lexa.match.start_match({ + waves = 10, + wait = 180, + enemies_initial = 10, + enemies_mult = 5, + materials = { + copper = 25 + } + }) +end) + +function lexa.match.respawn(name) + if not lexa.match.state then + minetest.chat_send_player(name, 'Please run /start_match first!') + return + end + minetest.get_player_by_name(name):set_pos(lexa.match.state.map_meta.spawn) +end + +minetest.register_chatcommand('respawn', { + description = 'Returns the player to the spawn.', + func = function(name) + lexa.match.respawn(name) + end +}) + +function lexa.match.set_materials(materials) + if not lexa.match.state then + minetest.chat_send_player(name, 'Please run /start_match first!') + return + end + + local last = lexa.match.state.materials + lexa.match.state.materials = materials + + if last.copper ~= materials.copper or last.titanium ~= materials.titanium or last.cobalt ~= materials.cobalt then + lexa.hud.update_materials(materials) + end +end diff --git a/mods/lexa_materials/script/chunk.lua b/mods/lexa_materials/script/chunk.lua index 42e37f4..dfc0e03 100644 --- a/mods/lexa_materials/script/chunk.lua +++ b/mods/lexa_materials/script/chunk.lua @@ -17,7 +17,8 @@ minetest.register_entity('lexa_materials:ore_chunk', { minetest.register_chatcommand('spawn_ore', { params = '', - description = 'Spawns an ore chunk', + privs = { cheats = true }, + description = 'Spawns an ore chunk of the type specified.', 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) diff --git a/mods/lexa_materials/script/register.lua b/mods/lexa_materials/script/register.lua index 37cd41c..577b93d 100644 --- a/mods/lexa_materials/script/register.lua +++ b/mods/lexa_materials/script/register.lua @@ -10,3 +10,20 @@ lexa.materials.material_list = { 'coal', 'copper', 'titanium', 'cobalt', 'iridiu for _, material in ipairs(lexa.materials.material_list) do lexa.materials.register(material) end + +minetest.register_chatcommand('give_material', { + params = ' ', + description = 'Gives materials to the player.', + privs = { cheats = true }, + func = function(name, params) + local type, amount = params:match('^(%S+) (-?%d+)$') + if not type or not amount then + minetest.chat_send_player(name, 'Invalid params.') + return false + end + + local materials = table.copy(lexa.match.state.materials) + materials[type] = (materials[type] or 0) + tonumber(amount) + lexa.match.set_materials(materials) + end +}) diff --git a/mods/lexa_nav/init.lua b/mods/lexa_nav/init.lua index 1954164..3a4c9b5 100644 --- a/mods/lexa_nav/init.lua +++ b/mods/lexa_nav/init.lua @@ -1,32 +1,13 @@ lexa.nav = {} lexa.require('rpq') -lexa.require('load') lexa.require('astar') lexa.require('nodes') lexa.require('graph') -lexa.nav.graph = nil -local spawn_pos = { x = 9, y = 2, z = -36 } -local map_min = { x = -85, y = -38, z = -156 } -local map_size = { x = 320, y = 160, z = 320 } - -function init_graph() - local res, graph_duration = lexa.nav.build_graph(spawn_pos) - lexa.nav.graph = res - -- minetest.chat_send_all('Graphed ' .. navigation.graph.count .. ' nodes in ' .. graph_duration .. ' ms.') -end - -minetest.register_chatcommand('refresh_graph', { - params = '', - description = 'Graphs navigation nodes', - func = function(name) - init_graph() - end -}) - minetest.register_chatcommand('test_paths', { params = '', + privs = { cheats = true }, description = 'Graphs paths from enemy spawns to player spawn', func = function(name) if lexa.nav.graph == nil then @@ -58,10 +39,3 @@ minetest.register_chatcommand('test_paths', { end end }) - -minetest.after(1, function() - 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) -end) diff --git a/mods/lexa_nav/script/load.lua b/mods/lexa_nav/script/load.lua index 6ea1480..7d78e2b 100644 --- a/mods/lexa_nav/script/load.lua +++ b/mods/lexa_nav/script/load.lua @@ -1,59 +1,59 @@ --- The minimum max_forceloaded_blocks for the game to work -local REQUIRED_FORCELOADED_BLOCKS = 10000 +-- -- The minimum max_forceloaded_blocks for the game to work +-- local REQUIRED_FORCELOADED_BLOCKS = 10000 --- If the max_forceloaded_blocks is less than what is required, prevent the game from being run. -local forceload_is_good = tonumber((minetest.settings:get('max_forceloaded_blocks') or 0)) >= REQUIRED_FORCELOADED_BLOCKS +-- -- If the max_forceloaded_blocks is less than what is required, prevent the game from being run. +-- local forceload_is_good = tonumber((minetest.settings:get('max_forceloaded_blocks') or 0)) >= REQUIRED_FORCELOADED_BLOCKS -if not forceload_is_good then - minetest.register_on_joinplayer(function(player) - minetest.kick_player(player:get_player_name(), - '\n\nThe server is misconfigured, please set max_forceloaded_blocks = 10000 in minetest.conf.') - end) -end +-- if not forceload_is_good then +-- minetest.register_on_joinplayer(function(player) +-- minetest.kick_player(player:get_player_name(), +-- '\n\nThe server is misconfigured, please set max_forceloaded_blocks = 10000 in minetest.conf.') +-- end) +-- end --- --- Emerges and forceloads the area between min_pos and max_pos (inclusive) --- When the load is complete, calls the callback function with three parameters: --- A function to unload the loaded area, the number of blocks loaded, and the time it took to emerge the area in ms. --- --- @param min_pos - The minimum position of the area to emerge --- @param max_pos - The maximum position of the area to emerge --- @param callback - The callback to call when the area is emerged. --- +-- -- +-- -- Emerges and forceloads the area between min_pos and max_pos (inclusive) +-- -- When the load is complete, calls the callback function with three parameters: +-- -- A function to unload the loaded area, the number of blocks loaded, and the time it took to emerge the area in ms. +-- -- +-- -- @param min_pos - The minimum position of the area to emerge +-- -- @param max_pos - The maximum position of the area to emerge +-- -- @param callback - The callback to call when the area is emerged. +-- -- -function lexa.nav.load_area(min_pos, max_pos, cb) - local start_time = minetest.get_us_time() +-- function lexa.nav.load_area(min_pos, max_pos, cb) +-- local start_time = minetest.get_us_time() - local function free() - for x = math.floor(min_pos.x / 16), math.ceil(max_pos.x / 16) do - for z = math.floor(min_pos.y / 16), math.ceil(max_pos.y / 16) do - for y = math.floor(min_pos.z / 16), math.ceil(max_pos.z / 16) do - minetest.forceload_free_block({ x = x, y = y, z = z }, true) - end - end - end - end +-- local function free() +-- for x = math.floor(min_pos.x / 16), math.ceil(max_pos.x / 16) do +-- for z = math.floor(min_pos.y / 16), math.ceil(max_pos.y / 16) do +-- for y = math.floor(min_pos.z / 16), math.ceil(max_pos.z / 16) do +-- minetest.forceload_free_block({ x = x, y = y, z = z }, true) +-- end +-- end +-- end +-- end - local function forceload() - local loaded = 0 +-- local function forceload() +-- local loaded = 0 - for x = math.floor(min_pos.x / 16), math.ceil(max_pos.x / 16) do - for z = math.floor(min_pos.y / 16), math.ceil(max_pos.y / 16) do - for y = math.floor(min_pos.z / 16), math.ceil(max_pos.z / 16) do - local pos = { x = x, y = y, z = z } - if not minetest.forceload_block(pos, true) then - minetest.chat_send_all('[Error] Failed to forceload block at ' .. minetest.pos_to_string(pos) .. '.') - end - loaded = loaded + 1 - end - end - end +-- for x = math.floor(min_pos.x / 16), math.ceil(max_pos.x / 16) do +-- for z = math.floor(min_pos.y / 16), math.ceil(max_pos.y / 16) do +-- for y = math.floor(min_pos.z / 16), math.ceil(max_pos.z / 16) do +-- local pos = { x = x, y = y, z = z } +-- if not minetest.forceload_block(pos, true) then +-- minetest.chat_send_all('[Error] Failed to forceload block at ' .. minetest.pos_to_string(pos) .. '.') +-- end +-- loaded = loaded + 1 +-- end +-- end +-- end - local duration = math.floor((minetest.get_us_time() - start_time) / 1000) - cb(free, loaded, duration) - end +-- local duration = math.floor((minetest.get_us_time() - start_time) / 1000) +-- cb(free, loaded, duration) +-- end - minetest.emerge_area(min_pos, max_pos, function(_, _, remaining) - if remaining == 0 then forceload() end - end) -end +-- minetest.emerge_area(min_pos, max_pos, function(_, _, remaining) +-- if remaining == 0 then forceload() end +-- end) +-- end diff --git a/mods/lexa_nav/script/nodes.lua b/mods/lexa_nav/script/nodes.lua index b11e435..add66c6 100644 --- a/mods/lexa_nav/script/nodes.lua +++ b/mods/lexa_nav/script/nodes.lua @@ -43,7 +43,7 @@ function register_nav_node(def) nav_node = 1, nav_traversable = def.traversable and 1 or 0, nav_visible = 1, - build_dig = 1 + dig_build = 1 }, _navigation = navigation, on_place = function(stack, player, target) @@ -73,42 +73,33 @@ function register_nav_node(def) }) end --- --- Toggles the visibility of the navigation nodes --- using active block modifiers and commands. --- - --- minetest.register_abm({ --- label = 'Make navigation nodes visible', --- nodenames = { 'group:nav_hidden' }, --- interval = 1, --- chance = 1, --- min_y = -150, --- max_y = 150, --- action = function(pos, node) --- if not nav_visible then return end --- local node_name = node.name:gsub('_hidden', '') --- minetest.set_node(pos, { name = node_name }) --- end --- }) - --- minetest.register_abm({ --- label = 'Making navigation nodes hidden', --- nodenames = { 'group:nav_visible' }, --- interval = 1, --- chance = 1, --- min_y = -150, --- max_y = 150, --- action = function(pos, node) --- if nav_visible then return end --- local node_name = node.name .. '_hidden' --- minetest.set_node(pos, { name = node_name }) --- end --- }) - minetest.register_chatcommand('toggle_nav', { description = 'Toggle nav node visibility', - func = function() nav_visible = not nav_visible end + privs = { cheats = true }, + func = function() + nav_visible = not nav_visible + + if not lexa.match.state then return end + local voxel = minetest.get_voxel_manip(vector.new(0, 0, 0), lexa.match.state.map_meta.size) + local data = voxel:get_data() + + local nodes = {} + for name, def in pairs(minetest.registered_nodes) do + if def.groups.nav_node and + ((nav_visible and def.groups.nav_hidden) or + (not nav_visible and def.groups.nav_visible)) then + local alt = nav_visible and name:gsub('_hidden', '') or name .. '_hidden' + nodes[minetest.get_content_id(name)] = minetest.get_content_id(alt) + end + end + + for i = 1, #data do + if nodes[data[i]] then data[i] = nodes[data[i]] end + end + + voxel:set_data(data) + voxel:write_to_map() + end }) -- @@ -157,17 +148,3 @@ register_nav_node({ traversable = true, spawn = 'enemy' }) - -minetest.register_alias('navigation:nav', 'lexa_nav:ground') -minetest.register_alias('navigation:nav_positive_magnet', 'lexa_nav:magnet_pos') -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') diff --git a/mods/lexa_tools/init.lua b/mods/lexa_tools/init.lua new file mode 100644 index 0000000..89738c2 --- /dev/null +++ b/mods/lexa_tools/init.lua @@ -0,0 +1,2 @@ +lexa.require('pickaxe') +lexa.require('wrench') diff --git a/mods/lexa_tools/mod.conf b/mods/lexa_tools/mod.conf new file mode 100644 index 0000000..22a4850 --- /dev/null +++ b/mods/lexa_tools/mod.conf @@ -0,0 +1,5 @@ +title = Hand Tools +name = lexa_tools +author = Aurailus +description = Hand tools for repairing and mining quickly. +depends = lexa_base diff --git a/mods/lexa_tools/script/pickaxe.lua b/mods/lexa_tools/script/pickaxe.lua new file mode 100644 index 0000000..011e859 --- /dev/null +++ b/mods/lexa_tools/script/pickaxe.lua @@ -0,0 +1,4 @@ +minetest.register_tool('lexa_tools:pickaxe', { + description = 'Pickaxe', + inventory_image = 'lexa_tools_pickaxe.png' +}) diff --git a/mods/lexa_tools/script/wrench.lua b/mods/lexa_tools/script/wrench.lua new file mode 100644 index 0000000..e581853 --- /dev/null +++ b/mods/lexa_tools/script/wrench.lua @@ -0,0 +1,4 @@ +minetest.register_tool('lexa_tools:wrench', { + description = 'Wrench', + inventory_image = 'lexa_tools_wrench.png' +}) diff --git a/mods/lexa_tools/textures/lexa_tools_pickaxe.png b/mods/lexa_tools/textures/lexa_tools_pickaxe.png new file mode 100644 index 0000000..80e6fa2 Binary files /dev/null and b/mods/lexa_tools/textures/lexa_tools_pickaxe.png differ diff --git a/mods/lexa_tools/textures/lexa_tools_wrench.png b/mods/lexa_tools/textures/lexa_tools_wrench.png new file mode 100644 index 0000000..eb76e5f Binary files /dev/null and b/mods/lexa_tools/textures/lexa_tools_wrench.png differ diff --git a/mods/lexa_turret/init.lua b/mods/lexa_turret/init.lua new file mode 100644 index 0000000..8f37498 --- /dev/null +++ b/mods/lexa_turret/init.lua @@ -0,0 +1 @@ +lexa.require('turret') diff --git a/mods/lexa_turret/mod.conf b/mods/lexa_turret/mod.conf new file mode 100644 index 0000000..ff41a35 --- /dev/null +++ b/mods/lexa_turret/mod.conf @@ -0,0 +1,5 @@ +title = Turrets +name = lexa_turret +author = Aurailus +description = Turrets that shoot enemies. +depends = lexa_base, lexa_enemy diff --git a/mods/lexa_turret/models/_Blender/lexa_turret_base.blend b/mods/lexa_turret/models/_Blender/lexa_turret_base.blend new file mode 100644 index 0000000..92f8c89 Binary files /dev/null and b/mods/lexa_turret/models/_Blender/lexa_turret_base.blend differ diff --git a/mods/lexa_turret/models/_Blender/lexa_turret_base.blend1 b/mods/lexa_turret/models/_Blender/lexa_turret_base.blend1 new file mode 100644 index 0000000..ad7fcb1 Binary files /dev/null and b/mods/lexa_turret/models/_Blender/lexa_turret_base.blend1 differ diff --git a/mods/lexa_turret/models/lexa_turret_base.b3d b/mods/lexa_turret/models/lexa_turret_base.b3d new file mode 100644 index 0000000..37d7cf2 Binary files /dev/null and b/mods/lexa_turret/models/lexa_turret_base.b3d differ diff --git a/mods/lexa_turret/script/turret.lua b/mods/lexa_turret/script/turret.lua new file mode 100644 index 0000000..aac8351 --- /dev/null +++ b/mods/lexa_turret/script/turret.lua @@ -0,0 +1,64 @@ +minetest.register_node('lexa_turret:turret_base', { + description = 'Turret', + _cost = { copper = 50 }, + drawtype = 'mesh', + use_texture_alpha = 'clip', + mesh = 'lexa_turret_base.b3d', + tiles = { 'lexa_turret_base.png' }, + use_texture_alpha = 'opaque', + selection_box = { + type = 'fixed', + fixed = { + { -8/16, -2/16, -8/16, 8/16, 8/16, 8/16 }, + { -10/16, -8/16, -10/16, 10/16, -2/16, 10/16 } + } + }, + collision_box = { + type = 'fixed', + fixed = { -8/16, -8/16, -8/16, 8/16, 8/16, 8/16 } + }, + paramtype = 'light', + sunlight_propagates = true, + groups = { + conveyor = 3, + dig_game = 1, + }, + drop = '', + after_place_node = function(pos) + minetest.set_node(vector.add(pos, vector.new(0, 1, 0)), { name = 'lexa_turret:turret_mid' }) + minetest.set_node(vector.add(pos, vector.new(0, 2, 0)), { name = 'lexa_turret:turret_top' }) + end, + after_dig_node = function(pos) + minetest.set_node(vector.add(pos, vector.new(0, 1, 0)), { name = 'air' }) + minetest.set_node(vector.add(pos, vector.new(0, 2, 0)), { name = 'air' }) + end + -- _conveyor_function = function(node_pos, item, delta) + -- 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) + -- 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 = lexa.conveyor.speed + -- item.object:set_velocity(obj_vel) + -- end + -- end, +}) + +minetest.register_node('lexa_turret:turret_mid', { + tiles = { 'lexa_turret_side.png' } +}) + +minetest.register_node('lexa_turret:turret_top', { + tiles = { 'lexa_turret_side.png' } +}) diff --git a/mods/lexa_turret/textures/lexa_turret_base.png b/mods/lexa_turret/textures/lexa_turret_base.png new file mode 100644 index 0000000..802e9b2 Binary files /dev/null and b/mods/lexa_turret/textures/lexa_turret_base.png differ diff --git a/mods/lexa_turret/textures/lexa_turret_side.png b/mods/lexa_turret/textures/lexa_turret_side.png new file mode 100644 index 0000000..ce4e908 Binary files /dev/null and b/mods/lexa_turret/textures/lexa_turret_side.png differ