1 -- Boilerplate to support localized strings if intllib mod is installed.
3 if minetest
.get_modpath("intllib") then
6 S
= function(s
) return s
end
10 function pep
.register_potion(potiondef
)
12 if(potiondef
.effect_type
~= nil) then
13 on_use
= function(itemstack
, user
, pointed_thing
)
14 playereffects
.apply_effect_type(potiondef
.effect_type
, potiondef
.duration
, user
)
19 on_use
= function(itemstack
, user
, pointed_thing
)
24 minetest
.register_craftitem("pep:"..potiondef
.basename
, {
25 description
= string.format(S("Glass Bottle (%s)"), potiondef
.contentstring
),
26 _doc_items_longdesc
= potiondef
.longdesc
,
27 _doc_items_usagehelp
= S("Hold it in your hand, then left-click to drink it."),
28 inventory_image
= "pep_"..potiondef
.basename
..".png",
29 wield_image
= "pep_"..potiondef
.basename
..".png",
36 function pep
.enable_mole_mode(playername
)
37 pep
.moles
[playername
] = true
40 function pep
.disable_mole_mode(playername
)
41 pep
.moles
[playername
] = false
44 function pep
.yaw_to_vector(yaw
)
49 return { x
=0, y
=0, z
=1}
50 elseif yaw
< (3/8)*tau
then
51 return { x
=-1, y
=0, z
=0 }
52 elseif yaw
< (5/8)*tau
then
53 return { x
=0, y
=0, z
=-1 }
54 elseif yaw
< (7/8)*tau
then
55 return { x
=1, y
=0, z
=0 }
57 return { x
=0, y
=0, z
=1}
61 function pep
.moledig(playername
)
62 local player
= minetest
.get_player_by_name(playername
)
64 local yaw
= player
:get_look_yaw()
65 -- fix stupid oddity of Minetest, adding pi/2 to the actual player's look yaw...
66 -- TODO: Remove this code as soon as Minetest fixes this.
69 local pos
= vector
.round(player
:getpos())
71 local v
= pep
.yaw_to_vector(yaw
)
73 local digpos1
= vector
.add(pos
, v
)
74 local digpos2
= { x
= digpos1
.x
, y
= digpos1
.y
+1, z
= digpos1
.z
}
76 local try_dig
= function(pos
)
77 local n
= minetest
.get_node(pos
)
78 local ndef
= minetest
.registered_nodes
[n
.name
]
79 if ndef
.walkable
and ndef
.diggable
then
80 if ndef
.can_dig
~= nil then
81 if ndef
.can_dig() then
94 local dig
= function(pos
)
96 local n
= minetest
.get_node(pos
)
97 local ndef
= minetest
.registered_nodes
[n
.name
]
98 if ndef
.sounds
~= nil then
99 minetest
.sound_play(ndef
.sounds
.dug
, { pos
= pos
})
101 -- TODO: Replace this code as soon Minetest removes support for this function
102 local drops
= minetest
.get_node_drops(n
.name
, "default:pick_steel")
103 minetest
.dig_node(pos
)
104 local inv
= player
:get_inventory()
107 table.insert(leftovers
, inv
:add_item("main", drops
[i
]))
109 for i
=1,#leftovers
do
110 minetest
.add_item(pos
, leftovers
[i
])
121 minetest
.register_globalstep(function(dtime
)
122 pep
.timer
= pep
.timer
+ dtime
123 if pep
.timer
> 0.5 then
124 for playername
, is_mole
in pairs(pep
.moles
) do
126 pep
.moledig(playername
)
133 playereffects
.register_effect_type("pepspeedplus", S("High speed"), "pep_speedplus.png", {"speed"},
135 player
:set_physics_override({speed
=2})
137 function(effect
, player
)
138 player
:set_physics_override({speed
=1})
141 playereffects
.register_effect_type("pepspeedminus", S("Low speed"), "pep_speedminus.png", {"speed"},
143 player
:set_physics_override({speed
=0.5})
145 function(effect
, player
)
146 player
:set_physics_override({speed
=1})
149 playereffects
.register_effect_type("pepspeedreset", S("Speed neutralizer"), "pep_speedreset.png", {"speed"},
150 function() end, function() end)
151 playereffects
.register_effect_type("pepjumpplus", S("High jump"), "pep_jumpplus.png", {"jump"},
153 player
:set_physics_override({jump
=2})
155 function(effect
, player
)
156 player
:set_physics_override({jump
=1})
159 playereffects
.register_effect_type("pepjumpminus", S("Low jump"), "pep_jumpminus.png", {"jump"},
161 player
:set_physics_override({jump
=0.5})
163 function(effect
, player
)
164 player
:set_physics_override({jump
=1})
167 playereffects
.register_effect_type("pepjumpreset", S("Jump height neutralizer"), "pep_jumpreset.png", {"jump"},
168 function() end, function() end)
169 playereffects
.register_effect_type("pepgrav0", S("No gravity"), "pep_grav0.png", {"gravity"},
171 player
:set_physics_override({gravity
=0})
173 function(effect
, player
)
174 player
:set_physics_override({gravity
=1})
177 playereffects
.register_effect_type("pepgravreset", S("Gravity neutralizer"), "pep_gravreset.png", {"gravity"},
178 function() end, function() end)
179 playereffects
.register_effect_type("pepregen", S("Regeneration"), "pep_regen.png", {"health"},
181 player
:set_hp(player
:get_hp()+1)
185 playereffects
.register_effect_type("pepregen2", S("Strong regeneration"), "pep_regen2.png", {"health"},
187 player
:set_hp(player
:get_hp()+2)
192 if minetest
.get_modpath("mana") ~= nil then
193 playereffects
.register_effect_type("pepmanaregen", S("Weak mana boost"), "pep_manaregen.png", {"mana"},
195 local name
= player
:get_player_name()
196 mana
.setregen(name
, mana
.getregen(name
) + 0.5)
198 function(effect
, player
)
199 local name
= player
:get_player_name()
200 mana
.setregen(name
, mana
.getregen(name
) - 0.5)
203 playereffects
.register_effect_type("pepmanaregen2", S("Strong mana boost"), "pep_manaregen2.png", {"mana"},
205 local name
= player
:get_player_name()
206 mana
.setregen(name
, mana
.getregen(name
) + 1)
208 function(effect
, player
)
209 local name
= player
:get_player_name()
210 mana
.setregen(name
, mana
.getregen(name
) - 1)
216 playereffects
.register_effect_type("pepbreath", S("Perfect breath"), "pep_breath.png", {"breath"},
218 player
:set_breath(player
:get_breath()+2)
222 playereffects
.register_effect_type("pepmole", S("Mole mode"), "pep_mole.png", {"autodig"},
224 pep
.enable_mole_mode(player
:get_player_name())
226 function(effect
, player
)
227 pep
.disable_mole_mode(player
:get_player_name())
231 pep
.register_potion({
232 basename
= "speedplus",
233 contentstring
= S("Running Potion"),
234 longdesc
= S("Drinking it will make you run faster for 30 seconds."),
235 effect_type
= "pepspeedplus",
238 pep
.register_potion({
239 basename
= "speedminus",
240 contentstring
= S("Slug Potion"),
241 longdesc
= S("Drinking it will make you walk slower for 30 seconds."),
242 effect_type
= "pepspeedminus",
245 pep
.register_potion({
246 basename
= "speedreset",
247 contentstring
= S("Speed Neutralizer"),
248 longdesc
= S("Drinking it will stop all speed effects you may currently have."),
249 effect_type
= "pepspeedreset",
252 pep
.register_potion({
254 contentstring
= S("Air Potion"),
255 longdesc
= S("Drinking it gives you breath underwater for 30 seconds."),
256 effect_type
= "pepbreath",
259 pep
.register_potion({
261 contentstring
= S("Weak Healing Potion"),
262 longdesc
= S("Drinking it makes you regenerate health. Every 2 seconds, you get 1 HP, 10 times in total."),
263 effect_type
= "pepregen",
266 pep
.register_potion({
268 contentstring
= S("Strong Healing Potion"),
269 longdesc
= S("Drinking it makes you regenerate health quickly. Every second you get 2 HP, 10 times in total."),
270 effect_type
= "pepregen2",
273 pep
.register_potion({
275 contentstring
= S("Non-Gravity Potion"),
276 longdesc
= S("When you drink this potion, gravity stops affecting you, as if you were in space. The effect lasts for 20 seconds."),
277 effect_type
= "pepgrav0",
280 pep
.register_potion({
281 basename
= "gravreset",
282 contentstring
= S("Gravity Neutralizer"),
283 longdesc
= S("Drinking it will stop all gravity effects you currently have."),
284 effect_type
= "pepgravreset",
287 pep
.register_potion({
288 basename
= "jumpplus",
289 contentstring
= S("High Jumping Potion"),
290 longdesc
= S("Drinking it will make you jump higher for 30 seconds."),
291 effect_type
= "pepjumpplus",
294 pep
.register_potion({
295 basename
= "jumpminus",
296 contentstring
= S("Low Jumping Potion"),
297 longdesc
= S("Drinking it will make you jump lower for 30 seconds."),
298 effect_type
= "pepjumpminus",
301 pep
.register_potion({
302 basename
= "jumpreset",
303 contentstring
= S("Jump Neutralizer"),
304 longdesc
= S("Drinking it will stop all jumping effects you may currently have."),
305 effect_type
= "pepjumpreset",
308 pep
.register_potion({
310 contentstring
= S("Mole Potion"),
311 longdesc
= S("Drinking it will start an effect which will magically attempt to mine any two blocks in front of you horizontally, as if you were using a steel pickaxe on them. The effect lasts for 18 seconds."),
312 effect_type
= "pepmole",
315 if(minetest
.get_modpath("mana")~=nil) then
316 pep
.register_potion({
317 basename
= "manaregen",
318 contentstring
= S("Weak Mana Potion"),
319 effect_type
= "pepmanaregen",
321 longdesc
= S("Drinking it will increase your mana regeneration rate by 0.5 for 10 seconds."),
323 pep
.register_potion({
324 basename
= "manaregen2",
325 contentstring
= S("Strong Mana Potion"),
326 effect_type
= "pepmanaregen2",
328 longdesc
= S("Drinking it will increase your mana regeneration rate by 1 for 10 seconds."),
333 --[=[ register crafts ]=]
334 --[[ normal potions ]]
335 if(minetest
.get_modpath("vessels")~=nil) then
336 if(minetest
.get_modpath("default")~=nil) then
337 minetest
.register_craft({
339 output
= "pep:breath",
340 recipe
= { "default:papyrus", "default:papyrus", "default:papyrus", "default:papyrus",
341 "default:papyrus", "default:papyrus", "default:papyrus", "default:papyrus", "vessels:glass_bottle" }
343 minetest
.register_craft({
345 output
= "pep:speedminus",
346 recipe
= { "default:dry_grass_1", "default:ice", "vessels:glass_bottle" }
348 if(minetest
.get_modpath("flowers") ~= nil) then
349 minetest
.register_craft({
351 output
= "pep:jumpplus",
352 recipe
= { "flowers:flower_tulip", "default:grass_1", "default:mese_crystal_fragment",
353 "default:mese_crystal_fragment", "vessels:glass_bottle" }
355 minetest
.register_craft({
357 output
= "pep:poisoner",
358 recipe
= { "flowers:mushroom_red", "flowers:mushroom_red", "flowers:mushroom_red", "vessels:glass_bottle" }
361 if(minetest
.get_modpath("farming") ~= nil) then
362 minetest
.register_craft({
364 output
= "pep:regen",
365 recipe
= { "default:cactus", "farming:flour", "flowers:mushroom_brown", "vessels:glass_bottle" }
369 if(minetest
.get_modpath("farming") ~= nil) then
370 minetest
.register_craft({
372 output
= "pep:regen2",
373 recipe
= { "default:gold_lump", "farming:flour", "pep:regen" }
375 if minetest
.get_modpath("mana") ~= nil then
376 minetest
.register_craft({
378 output
= "pep:manaregen",
379 recipe
= { "default:dry_shrub", "default:dry_shrub", "farming:seed_cotton", "default:mese_crystal_fragment",
380 "vessels:glass_bottle" }
384 if minetest
.get_modpath("mana") ~= nil then
385 minetest
.register_craft({
387 output
= "pep:manaregen2",
388 recipe
= { "default:dry_shrub", "default:dry_shrub", "default:dry_shrub", "default:dry_shrub", "default:junglesapling",
389 "default:acacia_sapling", "default:mese_crystal_fragment", "pep:manaregen" }
393 minetest
.register_craft({
395 output
= "pep:jumpminus",
396 recipe
= { "default:leaves", "default:jungleleaves", "default:iron_lump", "flowers:dandelion_yellow", "vessels:glass_bottle" }
398 minetest
.register_craft({
400 output
= "pep:grav0",
401 recipe
= { "default:mese_crystal", "vessels:glass_bottle" }
403 minetest
.register_craft({
406 recipe
= { "default:pick_steel", "default:shovel_steel", "vessels:glass_bottle" },
408 minetest
.register_craft({
410 output
= "pep:gravreset" ,
411 recipe
= { "pep:grav0", "default:iron_lump" }
414 if(minetest
.get_modpath("flowers") ~= nil) then
415 minetest
.register_craft({
417 output
= "pep:speedplus",
418 recipe
= { "default:pine_sapling", "default:cactus", "flowers:dandelion_yellow", "default:junglegrass", "vessels:glass_bottle" }
423 --[[ independent crafts ]]
425 minetest
.register_craft({
427 output
= "pep:speedreset",
428 recipe
= { "pep:speedplus", "pep:speedminus" }
430 minetest
.register_craft({
432 output
= "pep:jumpreset",
433 recipe
= { "pep:jumpplus", "pep:jumpminus" }