diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..a583fda --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,51 @@ +unused_args = false +allow_defined_top = true + +globals = { + "minetest","wings","jetpack","flyingcarpet" +} + +read_globals = { + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + -- Builtin + "vector", "ItemStack", + "dump", "DIR_DELIM", "VoxelArea", "Settings", + + -- MTG + "default", "sfinv", "creative", + + -- Playereffects and mana + "playereffects","mana", + + -- Mineclone + "mcl_loot", "tga_encoder", "mcl_util", "flowlib", "mcl_sounds", "mcl_autogroup", + "mcl_events", "biomeinfo", "mcl_damage", "mcl_particles", "mcl_worlds", "mcl_colors", + "mcl_explosions", "mcl_vars", "controls", "walkover", "mcl_meshhand", "mcl_fovapi", + "playerphysics", "mcl_hunger", "mcl_death_drop", "mcl_player", "mcl_playerplus", + "mcl_gamemode", "mcl_spawn", "mcl_skins", "mcl_sprint", "mcl_playerinfo", + "mcl_item_id", "tt", "mcl_craftguide", "doc", "mcl_dripping", + "mcl_entity_invs", "mcl_item_entity", "mcl_burning", + "mcl_minecarts", "pillager", "mobs_mc", "sounds", + "textures", "mcl_mobs", "mcl_paintings", + "mcl_grindstone", "mcl_walls", "mcl_bamboo", + "mcl_maps", "mcl_clock", "mcl_end", "mcl_starting_inventory", + "mcl_bows", "mcl_bows_s", "mcl_dye", "mcl_copper", + "mcl_flowerpots", "mcl_furnaces", "mcl_farming", + "mcl_campfires", "mcl_crafting_table", "mcl_doors", + "mcl_jukebox", "screwdriver", "mcl_itemframes", + "mcl_heads", "mcl_beacons", "xpanes", "mcl_enchanting", + "mcl_beds", "mcl_throwing", "mcl_banners", "mcl_mobspawners", + "mcl_cocoas", "mcl_smithing_table", "mcl_flowers", + "mcl_core", "mcl_torches", "mcl_target", "mesecon", "mcl_observers", + "mcl_sculk", "mcl_armor", "mcl_lanterns", "mcl_stairs", "mcl_bells", + "mcl_hamburger", "mcl_signs", "mcl_honey", "mcl_stonecutter", "mcl_fire", + "mcl_compass", "mcl_ocean", "mcl_fences", "mcl_buckets", "mcl_potions", + "tnt", "mcl_cherry_blossom", "mcl_portals", "mcl_chests", "mcl_shields", + "mcl_wip", "mcl_raids", "mcl_moon", "lightning", "mcl_weather", + "mcl_formspec", "mcl_death_messages", "mcl_bossbars", "awards", + "mcl_inventory", "mcl_title", "mcl_offhand", "hb", "mcl_experience", + "mcl_info", "mcl_credits", "tsm_railcorridors", "mcl_mapgen_core", + "mcl_structures", "settlements", "mcl_dungeons", "mcl_colors_official" +} diff --git a/Readme.md b/README.md similarity index 85% rename from Readme.md rename to README.md index 2709d1b..24412ce 100644 --- a/Readme.md +++ b/README.md @@ -5,3 +5,7 @@ Two of these mods have a dependency on [Wuzzy's playereffects mod](https://forum All of the mods can be configured extensively through the config.lua file found in each mod. Look at the readme's of the mods for more info. + +### License + +Code and images are licensed under the MIT license. diff --git a/flyingcarpet/Readme.md b/flyingcarpet/README.md similarity index 100% rename from flyingcarpet/Readme.md rename to flyingcarpet/README.md diff --git a/flyingcarpet/config.lua b/flyingcarpet/config.lua deleted file mode 100644 index a566d07..0000000 --- a/flyingcarpet/config.lua +++ /dev/null @@ -1,7 +0,0 @@ -flyingcarpet = {} - ---If you want carpets to be available only through /giveme or at admin shops, set this to false. -flyingcarpet.crafts = true - ---If you want flying carpets to be only one use, set this to true. -flyingcarpet.one_use = false diff --git a/flyingcarpet/depends.txt b/flyingcarpet/depends.txt index 4ad96d5..5e78c21 100644 --- a/flyingcarpet/depends.txt +++ b/flyingcarpet/depends.txt @@ -1 +1 @@ -default +default? diff --git a/flyingcarpet/init.lua b/flyingcarpet/init.lua index adac953..2b1e4f9 100644 --- a/flyingcarpet/init.lua +++ b/flyingcarpet/init.lua @@ -1,4 +1,5 @@ -dofile(minetest.get_modpath("flyingcarpet") .. "/config.lua") +flyingcarpet = {} +local player_properties = minetest.get_modpath("mcl_player") and mcl_player or default local function get_sign(i) if i == 0 then @@ -30,17 +31,17 @@ function carpet:on_rightclick(clicker) if self.driver and clicker == self.driver then clicker:set_detach() self.driver = nil - default.player_attached[name] = false - default.player_set_animation(clicker, "stand" , 10) - if flyingcarpet.one_use == true then + player_properties.player_attached[name] = false + player_properties.player_set_animation(clicker, "stand" , 10) + if minetest.settings:get_bool("flyingcarpet.one_use", false) == true then self.object:remove() end elseif not self.driver then self.driver = clicker clicker:set_attach(self.object, "", {x=-4,y=10.1,z=0}, {x=0,y=90,z=0}) - default.player_attached[name] = true + player_properties.player_attached[name] = true minetest.after(0.2, function() - default.player_set_animation(clicker, "sit" , 10) + player_properties.player_set_animation(clicker, "sit" , 10) end) self.object:setyaw(clicker:get_look_yaw()-math.pi/2) end @@ -156,7 +157,8 @@ minetest.register_craftitem("flyingcarpet:carpet", { end, }) -if flyingcarpet.crafts == true then +if minetest.settings:get_bool("flyingcarpet.crafts",true) == true then + if minetest.get_modpath("default") ~= nil then minetest.register_craft({ output = "flyingcarpet:carpet", recipe = { @@ -164,4 +166,13 @@ if flyingcarpet.crafts == true then {"default:mese", "default:goldblock", "default:mese"}, }, }) + elseif minetest.get_modpath("mcl_core") ~= nil then + minetest.register_craft({ + output = "flyingcarpet:carpet", + recipe = { + {"group:wool", "group:wool", "group:wool"}, + {"mesecons:redstone", "mcl_core:goldblock", "mesecons:redstone"}, + }, + }) + end end diff --git a/flyingcarpet/mod.conf b/flyingcarpet/mod.conf new file mode 100644 index 0000000..1149eab --- /dev/null +++ b/flyingcarpet/mod.conf @@ -0,0 +1,3 @@ +title = Flying Carpet +name = flyingcarpet +optional_depends = default, mcl_core, mesecons diff --git a/flyingcarpet/settingtypes.txt b/flyingcarpet/settingtypes.txt new file mode 100644 index 0000000..d73d99c --- /dev/null +++ b/flyingcarpet/settingtypes.txt @@ -0,0 +1,5 @@ +# If you want carpets to be available only through /giveme or at admin shops, set this to false. +flyingcarpet.crafts (Crafts available) bool true + +# If you want flying carpets to be only one use, set this to true. +flyingcarpet.one_use (One-use flying carpets) bool false diff --git a/jetpack/Readme.md b/jetpack/README.md similarity index 100% rename from jetpack/Readme.md rename to jetpack/README.md diff --git a/jetpack/init.lua b/jetpack/init.lua index 675cf2d..0a3df5a 100644 --- a/jetpack/init.lua +++ b/jetpack/init.lua @@ -1,5 +1,10 @@ -dofile(minetest.get_modpath("jetpack") .. "/config.lua") -if jetpack.fast == true then +local jetpack_fast = minetest.settings:get_bool("jetpack.fast", false) +local jetpack_crafts = minetest.settings:get_bool("jetpack.crafts", true) +local jetpack_time = tonumber(minetest.settings:get("jetpack.time")) or 7 +local jetpack_time_bronze = tonumber(minetest.settings:get("jetpack.time_bronze")) or 15 +local jetpack_time_gold = tonumber(minetest.settings:get("jetpack.time_gold")) or 30 + +if jetpack_fast == true then playereffects.register_effect_type("flyj", "Fly mode available", "jetpack.png", {"fly"}, function(player) local playername = player:get_player_name() @@ -43,7 +48,7 @@ minetest.register_craftitem("jetpack:jetpack", { if privs.fly == true then minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of this jetpack!") else - playereffects.apply_effect_type("flyj", jetpack.time, user) + playereffects.apply_effect_type("flyj", jetpack_time, user) itemstack:take_item() return itemstack end @@ -60,7 +65,7 @@ minetest.register_craftitem("jetpack:jetpack_bronze", { if privs.fly == true then minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of this jetpack!") else - playereffects.apply_effect_type("flyj", jetpack.time_bronze, user) + playereffects.apply_effect_type("flyj", jetpack_time_bronze, user) itemstack:take_item() return itemstack end @@ -77,18 +82,20 @@ minetest.register_craftitem("jetpack:jetpack_gold", { if privs.fly == true then minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of this jetpack!") else - playereffects.apply_effect_type("flyj", jetpack.time_gold, user) + playereffects.apply_effect_type("flyj", jetpack_time_gold, user) itemstack:take_item() return itemstack end end, }) -if jetpack.crafts == true and minetest.get_modpath("default") ~= nil then - minetest.register_craftitem("jetpack:jetpack_base", { - description = "Jetpack Tubes", - inventory_image = "jetpack_base.png", - }) +minetest.register_craftitem("jetpack:jetpack_base", { + description = "Jetpack Tubes", + inventory_image = "jetpack_base.png", +}) + +if jetpack_crafts == true then + if minetest.get_modpath("default") then minetest.register_craft({ output = "jetpack:jetpack_base", recipe = { @@ -121,10 +128,39 @@ if jetpack.crafts == true and minetest.get_modpath("default") ~= nil then {"default:diamond", "default:mese_crystal", "default:diamond"}, }, }) + end + if minetest.get_modpath("mcl_core") then + minetest.register_craft({ + output = "jetpack:jetpack_base", + recipe = { + {"mcl_core:ironblock", "mcl_minecarts:chest_minecart", "mcl_core:ironblock"}, + {"mcl_core:gold_ingot", "mcl_core:diamondblock", "mcl_core:gold_ingot"}, + {"mcl_core:lapisblock", "mcl_core:emeraldblock", "mcl_core:lapisblock"}, + }, + }) + + minetest.register_craft({ + output = "jetpack:jetpack", + recipe = { + {"mcl_core:gold_nugget", "jetpack:jetpack_base", "mcl_core:gold_nugget"}, + {"mcl_core:goldblock", "mcl_end:end_rod_green", "mcl_core:goldblock"}, + {"mcl_core:diamond", "mcl_potions:swiftness", "mcl_core:diamond"}, + }, + }) + + minetest.register_craft({ + output = "jetpack:jetpack_gold", + recipe = { + {"mcl_core:diamondblock", "jetpack:jetpack_base", "mcl_core:diamondblock"}, + {"mcl_core:emeraldblock", "mcl_core:goldblock", "mcl_core:emeraldblock"}, + {"mcl_core:diamond", "mesecons:redstone", "mcl_core:diamond"}, + }, + }) + end end --Not sure if this is a hack, but it stops unkown items appearing if jetpack.crafts is set to false, while removing them from the creative inventory. -if jetpack.crafts == false then +if jetpack_crafts == false then minetest.register_craftitem("jetpack:jetpack_base", { description = "Jetpack Tubes", inventory_image = "jetpack_base.png", diff --git a/jetpack/mod.conf b/jetpack/mod.conf new file mode 100644 index 0000000..7c52cfc --- /dev/null +++ b/jetpack/mod.conf @@ -0,0 +1,4 @@ +title = Jetpack +name = jetpack +depends = playereffects +optional_depends = default, mcl_core, mesecons diff --git a/jetpack/settingtypes.txt b/jetpack/settingtypes.txt new file mode 100644 index 0000000..75f8873 --- /dev/null +++ b/jetpack/settingtypes.txt @@ -0,0 +1,15 @@ +# This grants and revokes the fast priv along with fly when it is set to true. +# If you grant the fast priv on your server, do *not* enable it. +# As when the effect wears off, the fast priv of the player will go as well. +jetpack.fast (Grant fast privilege with jetpack) bool false + +# Times for each of the jetpack types. +# I advise increasing them if fast is not a default priv and jetpack.fast = false. +# They are at the current times because any longer allows large distances to be covered with fast. +# Even with this, the gold jetpack allows players with fast to cover almost 300 nodes. +jetpack.time (Standard jetpack time) int 7 +jetpack.time_bronze (Bronze jetpack time) int 15 +jetpack.time_gold (Gold jetpack time) int 30 + +# If you want jetpack to be available only through /giveme or at admin shops, set this to false. +jetpack.crafts (Enable crafting of jetpacks) bool true diff --git a/wings/Readme.md b/wings/README.md similarity index 100% rename from wings/Readme.md rename to wings/README.md diff --git a/wings/init.lua b/wings/init.lua index d44f3d4..f03dcf7 100644 --- a/wings/init.lua +++ b/wings/init.lua @@ -1,5 +1,17 @@ -dofile(minetest.get_modpath("wings") .. "/config.lua") -if wings.fast == true then +-- Fetch settings from settingtypes.txt or use default values +local wings_fast = minetest.settings:get_bool("wings.fast", false) +local wings_time = minetest.settings:get("wings.time") or 7 +local wings_time_bronze = minetest.settings:get("wings.time_bronze") or 15 +local wings_time_gold = minetest.settings:get("wings.time_gold") or 30 +local wings_mana_divisor = minetest.settings:get("wings.mana_divisor") or 2 +local wings_crafts = minetest.settings:get_bool("wings.crafts", true) +local wings_mana = minetest.settings:get("wings.mana") or 100 +local wings_mana_bronze = minetest.settings:get("wings.mana_bronze") or 150 +local wings_mana_gold = minetest.settings:get("wings.mana_gold") or 200 + +wings = {} +-- Register fly effect based on settings +if wings_fast == true then playereffects.register_effect_type("fly", "Fly mode available", "wings_plain.png", {"fly"}, function(player) local playername = player:get_player_name() @@ -16,35 +28,36 @@ if wings.fast == true then end, false, false) - else - playereffects.register_effect_type("fly", "Fly mode available", "wings_plain.png", {"fly"}, - function(player) - local playername = player:get_player_name() - local privs = minetest.get_player_privs(playername) - privs.fly = true - minetest.set_player_privs(playername, privs) - end, - function(effect, player) - local privs = minetest.get_player_privs(effect.playername) - privs.fly = nil - minetest.set_player_privs(effect.playername, privs) - end, - false, - false) +else + playereffects.register_effect_type("fly", "Fly mode available", "wings_plain.png", {"fly"}, + function(player) + local playername = player:get_player_name() + local privs = minetest.get_player_privs(playername) + privs.fly = true + minetest.set_player_privs(playername, privs) + end, + function(effect, player) + local privs = minetest.get_player_privs(effect.playername) + privs.fly = nil + minetest.set_player_privs(effect.playername, privs) + end, + false, + false) end +-- Check for mana availability wings.mana_check = function(player, cost) - local allowed - if minetest.get_modpath("mana") then - if mana.subtract(player:get_player_name(), cost) then - allowed = true - else - allowed = false - end - else - allowed = true - end - return allowed + local allowed + if minetest.get_modpath("mana") then + if mana.subtract(player:get_player_name(), cost) then + allowed = true + else + allowed = false + end + else + allowed = true + end + return allowed end minetest.register_craftitem("wings:wings", { @@ -58,10 +71,10 @@ minetest.register_craftitem("wings:wings", { minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of these wings!") elseif minetest.get_modpath("mana") then if wings.mana_check(user, wings.mana) then - playereffects.apply_effect_type("fly", wings.time / wings.mana_divisor, user) + playereffects.apply_effect_type("fly", wings_time / wings_mana_divisor, user) end else - playereffects.apply_effect_type("fly", wings.time, user) + playereffects.apply_effect_type("fly", wings_time, user) itemstack:take_item() return itemstack end @@ -79,10 +92,10 @@ minetest.register_craftitem("wings:wings_bronze", { minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of these wings!") elseif minetest.get_modpath("mana") then if wings.mana_check(user, wings.mana_bronze) then - playereffects.apply_effect_type("fly", wings.time_bronze / wings.mana_divisor, user) + playereffects.apply_effect_type("fly", wings_time_bronze / wings_mana_divisor, user) end else - playereffects.apply_effect_type("fly", wings.time_bronze, user) + playereffects.apply_effect_type("fly", wings_time_bronze, user) itemstack:take_item() return itemstack end @@ -100,17 +113,18 @@ minetest.register_craftitem("wings:wings_gold", { minetest.chat_send_player(playername, "You already have the fly priv, and so have no need of these wings!") elseif minetest.get_modpath("mana") then if wings.mana_check(user, wings.mana_gold) then - playereffects.apply_effect_type("fly", wings.time_gold / wings.mana_divisor, user) + playereffects.apply_effect_type("fly", wings_time_gold / wings_mana_divisor, user) end else - playereffects.apply_effect_type("fly", wings.time_gold, user) + playereffects.apply_effect_type("fly", wings_time_gold, user) itemstack:take_item() return itemstack end end, }) -if wings.crafts == true and minetest.get_modpath("default") ~= nil then +if wings_crafts == true then + if minetest.get_modpath("default") ~= nil then minetest.register_craft({ output = "wings:wings", recipe = { @@ -135,4 +149,23 @@ if wings.crafts == true and minetest.get_modpath("default") ~= nil then {"default:diamond", "default:mese_crystal", "default:diamond"}, }, }) + end +if minetest.get_modpath("mcl_core") ~= nil then + minetest.register_craft({ + output = "wings:wings", + recipe = { + {"mcl_core:diamond", "mesecons:redstone", "mcl_core:diamond"}, + {"mesecons:redstone", "mcl_core:ironblock", "mesecons:redstone"}, + {"mcl_core:diamond", "mesecons:redstone", "mcl_core:diamond"}, + }, + }) + minetest.register_craft({ + output = "wings:wings_gold", + recipe = { + {"mcl_core:diamondblock", "mesecons:redstone", "mcl_core:diamondblock"}, + {"mesecons:redstone", "mcl_core:goldblock", "mesecons:redstone"}, + {"mcl_core:diamond", "mesecons:redstone", "mcl_core:diamond"}, + }, + }) + end end diff --git a/wings/mod.conf b/wings/mod.conf new file mode 100644 index 0000000..5c10d57 --- /dev/null +++ b/wings/mod.conf @@ -0,0 +1,4 @@ +title = Wings +name = wings +depends = playereffects +optional_depends = default, mana, mcl_core, mesecons diff --git a/wings/settingtypes.txt b/wings/settingtypes.txt new file mode 100644 index 0000000..ce9ea62 --- /dev/null +++ b/wings/settingtypes.txt @@ -0,0 +1,25 @@ +# This grants and revokes the fast priv along with fly when it is set to true. +# If you grant the fast priv on your server, do *not* enable it. +# As when the effect wears off, the fast priv of the player will go as well. +wings.fast (Grant Fast Privilege with Wings) bool false + +# Times for each of the wing types. +# I advise increasing them if fast is not a default priv and wings.fast = false. +# They are at the current times because any longer allows large distances to be covered with fast. +# Even with this, the gold wings allow players with fast to cover almost 300 nodes. +wings.time (Flight Time for Standard Wings) int 7 +wings.time_bronze (Flight Time for Bronze Wings) int 15 +wings.time_gold (Flight Time for Gold Wings) int 30 + +# This is how much the time is divided by when mana is used. +# As the wings can be used an unlimited number of times, flight needs to last for a shorter period of time. +wings.mana_divisor (Mana Divisor for Wings) int 2 + +# If you want wings to be available only through /giveme or at admin shops, set this to false. +wings.crafts (Enable Crafting of Wings) bool true + +# How much mana is needed for each type of wings. +# By default, the mana mod has a limit of 200 mana. +wings.mana (Mana Cost for Standard Wings) int 100 +wings.mana_bronze (Mana Cost for Bronze Wings) int 150 +wings.mana_gold (Mana Cost for Gold Wings) int 200