summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2014-07-20 04:51:15 +0200
committerWuzzy <almikes@aol.com>2014-07-20 04:51:15 +0200
commit0df942ae753e637f428b77669322c8550a48fa3c (patch)
tree1fe6f9f9afc99bc20f196a57eae2b431ed38e98e
parent8a3127d4c568a617e462f4631eaa60f8445f6c2c (diff)
Add initial effects, potions and crafts
-rw-r--r--depends.txt3
-rw-r--r--init.lua199
2 files changed, 201 insertions, 1 deletions
diff --git a/depends.txt b/depends.txt
index 68755ec..4b53f9d 100644
--- a/depends.txt
+++ b/depends.txt
@@ -1,3 +1,4 @@
playereffects
+default
vessels?
-default?
+flowers?
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..461c5ad
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,199 @@
+pep = {}
+function pep.register_potion(potiondef)
+ local on_use
+ if(potiondef.effect_type ~= nil) then
+ on_use = function(itemstack, user, pointed_thing)
+ playereffects.apply_effect_type(potiondef.effect_type, potiondef.duration, user)
+ itemstack:take_item()
+ return itemstack
+ end
+ else
+ on_use = function(itemstack, user, pointed_thing)
+ itemstack:take_item()
+ return itemstack
+ end
+ end
+ minetest.register_node("pep:"..potiondef.basename, {
+ description = "Glass Bottle ("..potiondef.contentstring..")",
+ drawtype = "plantlike",
+ tiles = { "pep_"..potiondef.basename..".png" },
+ inventory_image = "pep_"..potiondef.basename.."_inv.png",
+ paramtype = "light",
+ walkable = false,
+ selection_box = {
+ type = "fixed",
+ fixed = { -0.25, -0.5, -0.25, 0.25, 0.4, 0.25 },
+ },
+ groups = { vessel = 1, dig_immediate = 3, attached_node =1},
+ sounds = default.node_sound_glass_defaults(),
+ on_use = on_use,
+ })
+end
+
+playereffects.register_effect_type("pepspeedplus", "High speed", nil, {"speed"},
+ function(player)
+ player:set_physics_override({speed=2})
+ end,
+ function(effect, player)
+ player:set_physics_override({speed=1})
+ end
+)
+playereffects.register_effect_type("pepspeedminus", "Low speed", nil, {"speed"},
+ function(player)
+ player:set_physics_override({speed=0.5})
+ end,
+ function(effect, player)
+ player:set_physics_override({speed=1})
+ end
+)
+playereffects.register_effect_type("pepjumpplus", "High jump", nil, {"jump"},
+ function(player)
+ player:set_physics_override({jump=2})
+ end,
+ function(effect, player)
+ player:set_physics_override({jump=1})
+ end
+)
+playereffects.register_effect_type("pepjumpminus", "Low jump", nil, {"jump"},
+ function(player)
+ player:set_physics_override({jump=0.5})
+ end,
+ function(effect, player)
+ player:set_physics_override({jump=1})
+ end
+)
+playereffects.register_effect_type("pepfloat", "No gravity", nil, {"gravity"},
+ function(player)
+ player:set_physics_override({gravity=0})
+ end,
+ function(effect, player)
+ player:set_physics_override({gravity=1})
+ end
+)
+playereffects.register_effect_type("pepregen", "Regeneration", nil, {"health"},
+ function(player)
+ player:set_hp(player:get_hp()+1)
+ end,
+ nil, nil, nil, 2
+)
+playereffects.register_effect_type("pepregen2", "Strong regeneration", nil, {"health"},
+ function(player)
+ player:set_hp(player:get_hp()+2)
+ end,
+ nil, nil, nil, 1
+)
+
+playereffects.register_effect_type("peppoison", "Poisoned", nil, {"health"},
+ function(player)
+ player:set_hp(player:get_hp()-1)
+ end,
+ nil, nil, nil, 2
+)
+playereffects.register_effect_type("pepbreath", "Perfect breath", nil, {"breath"},
+ function(player)
+ player:set_breath(player:get_breath()+2)
+ end,
+ nil, nil, nil, 1
+)
+
+pep.register_potion({
+ basename = "water",
+ contentstring = "Water",
+ effect_type = nil,
+})
+
+pep.register_potion({
+ basename = "speedplus",
+ contentstring = "Running Potion",
+ effect_type = "pepspeedplus",
+ duration = 30
+})
+
+pep.register_potion({
+ basename = "speedminus",
+ contentstring = "Slug Potion",
+ effect_type = "pepspeedminus",
+ duration = 30
+})
+pep.register_potion({
+ basename = "breath",
+ contentstring = "Air Potion",
+ effect_type = "pepbreath",
+ duration = 60,
+})
+pep.register_potion({
+ basename = "regen",
+ contentstring = "Weak Healing Potion",
+ effect_type = "pepregen",
+ duration = 10,
+})
+pep.register_potion({
+ basename = "regen2",
+ contentstring = "Strong Healing Potion",
+ effect_type = "pepregen2",
+ duration = 10,
+})
+pep.register_potion({
+ basename = "float",
+ contentstring = "Non-Gravity Potion",
+ effect_type = "pepfloat",
+ duration = 20,
+})
+pep.register_potion({
+ basename = "jumpplus",
+ contentstring = "High Jumping Potion",
+ effect_type = "pepjumpplus",
+ duration = 30,
+})
+pep.register_potion({
+ basename = "jumpminus",
+ contentstring = "Low Jumping Potion",
+ effect_type = "pepjumpminus",
+ duration = 30,
+})
+
+--[[ register crafts ]]
+if(minetest.get_modpath("default") ~= nil) then
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:breath",
+ recipe = { "default:papyrus", "pep:water" }
+ })
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:speedminus",
+ recipe = { "default:dry_shrub", "pep:water" }
+ })
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:speedplus",
+ recipe = { "default:obsidian_shard", "pep:water" }
+ })
+ if(minetest.get_modpath("flowers") ~= nil) then
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:jumpplus",
+ recipe = { "flowers:flower_geranium", "default:grass_1", "pep:water" }
+ })
+ end
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:jumpminus",
+ recipe = { "default:leaves", "default:jungleleaves", "pep:water" }
+ })
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:regen",
+ recipe = { "default:cactus", "default:junglegrass", "pep:water" }
+ })
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:regen2",
+ recipe = { "default:gold_lump", "pep:regen" }
+ })
+ minetest.register_craft({
+ type = "shapeless",
+ output = "pep:float",
+ recipe = { "default:mese_crystal", "pep:water" }
+ })
+end