Remove the extremely buggy potions
|
@ -1,33 +0,0 @@
|
|||
--Potions by Traxie21--
|
||||
--This mod provides no default potions. If you would like some, download potionspack at github.com/Traxie21/potionspack--
|
||||
|
||||
|
||||
--API DOCUMENTATION--
|
||||
|
||||
Potion Registering Format:
|
||||
|
||||
potions.register_potion(NAME, COLOR, EXPIRE TIME, ACTIVATION FUNCTION, EXPIRE FUNCTION)
|
||||
|
||||
NAME: Name of potion. Invalid characeters are automagically stripped from it.
|
||||
|
||||
COLOR: Color of potion image in-game, available colors: black, brown, cyan, darkblue, darkgrey, lightgrey, darkred, dull, green, orange, pink, purple, red, white, and yellow.
|
||||
|
||||
EXPIRE TIME: Number in seconds.
|
||||
|
||||
ACTIVATION FUNCTION: The function that is run when the ground is right-clicked with the potion.
|
||||
|
||||
EXPIRE FUNCTION: The function that is run when the expire time runs out.
|
||||
|
||||
|
||||
--EXAMPLE--
|
||||
|
||||
potions.register_potion("Anti Gravity", "purple", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(3, 1.5, 0.5)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been blessed with Anti Gravity for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,1,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Anti Gravity has worn off.")
|
||||
end)
|
|
@ -1,66 +0,0 @@
|
|||
local MOD_NAME = minetest.get_current_modname()
|
||||
local MOD_PATH = minetest.get_modpath(MOD_NAME)
|
||||
local Vec3 = dofile(MOD_PATH.."/lib/Vec3_1-0.lua")
|
||||
|
||||
potions = {}
|
||||
|
||||
|
||||
|
||||
function potions.register_potion(iname, color, exptime, action, expaction)
|
||||
iname = string.gsub(iname, "[-%[%]()1023456789 ]", "")
|
||||
minetest.register_craftitem(minetest.get_current_modname()..":"..iname:lower(), {
|
||||
description = iname.." Potion",
|
||||
inventory_image = "potions_bottle.png^potions_"..color..".png",
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
action(itemstack, user, pointed_thing)
|
||||
minetest.after(exptime, expaction, itemstack, user, pointed_thing)
|
||||
itemstack:take_item()
|
||||
--Particle Code
|
||||
--Potions Particles
|
||||
minetest.add_particlespawner(30, 0.2,
|
||||
pointed_thing.above, pointed_thing.above,
|
||||
{x=1, y= 2, z=1}, {x=-1, y= 2, z=-1},
|
||||
{x=0.2, y=0.2, z=0.2}, {x=-0.2, y=0.5, z=-0.2},
|
||||
5, 10,
|
||||
1, 3,
|
||||
false, "potions_"..color..".png")
|
||||
|
||||
--Shatter Particles
|
||||
minetest.add_particlespawner(40, 0.1,
|
||||
pointed_thing.above, pointed_thing.above,
|
||||
{x=2, y=0.2, z=2}, {x=-2, y=0.5, z=-2},
|
||||
{x=0, y=-6, z=0}, {x=0, y=-10, z=0},
|
||||
0.5, 2,
|
||||
0.2, 5,
|
||||
true, "potions_shatter.png")
|
||||
|
||||
local dir = Vec3(user:get_look_dir()) *20
|
||||
minetest.add_particle(
|
||||
{x=user:getpos().x, y=user:getpos().y+1.5, z=user:getpos().z}, {x=dir.x, y=dir.y, z=dir.z}, {x=0, y=-10, z=0}, 0.2,
|
||||
6, false, "potions_bottle.png^potions_"..color..".png")
|
||||
return itemstack
|
||||
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
minetest.register_craftitem("potions:glass_bottle", {
|
||||
description = "Glass Bottle",
|
||||
inventory_image = "potions_bottle.png",
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
itemstack:take_item()
|
||||
--Shatter Particles
|
||||
minetest.add_particlespawner(40, 0.1,
|
||||
pointed_thing.above, pointed_thing.above,
|
||||
{x=2, y=0.2, z=2}, {x=-2, y=0.5, z=-2},
|
||||
{x=0, y=-6, z=0}, {x=0, y=-10, z=0},
|
||||
0.5, 2,
|
||||
0.2, 5,
|
||||
true, "potions_shatter.png")
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
@ -1,398 +0,0 @@
|
|||
local THIS_VERSION = "1.0"
|
||||
|
||||
--- 3D vector class/operations.
|
||||
--
|
||||
-- Note that methods can be called in either an object-oriented way:
|
||||
-- v1 = Vec3(1, 2, 3)
|
||||
-- v2 = v1:add({ x = 2, y = 2, z = 0 })
|
||||
-- or as simple functions:
|
||||
-- Vec3.add({ x = 1, y = 2, z = 3 }, { x = 2, y = 2, z = 0 })
|
||||
--
|
||||
-- All methods that can be called on a Vec3 using ":" may be called on a table
|
||||
-- using the second functional syntax, but the first parameter MUST have the
|
||||
-- expected components "x", "y", and "z". If a vector is used as the second
|
||||
-- paramter, it may instead be a list/array with numeric indices, like
|
||||
-- { 1.0, 2.0, 3.0 } in place of { x = 1.0, y = 2.0, z = 3.0 }.
|
||||
--
|
||||
-- @author prestidigitator (as registered at forum.minetest.net)
|
||||
-- @copyright 2013, licensed under WTFPL
|
||||
--
|
||||
local Vec3 = {}
|
||||
local Vec3_meta = {}
|
||||
local Vec3_inst_meta = {}
|
||||
|
||||
Vec3.VERSION = THIS_VERSION
|
||||
|
||||
setmetatable(Vec3, Vec3_meta)
|
||||
Vec3_inst_meta.__index = Vec3
|
||||
|
||||
--- Constructs a Vec3 from three numbers.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- Vec3.new(x, y, z)
|
||||
-- Vec3(x, y, z)
|
||||
--
|
||||
-- @return a new Vec3 object
|
||||
local function Vec3_new(x, y, z)
|
||||
local obj = { x = x or 0.0, y = y or 0.0, z = z or 0.0 }
|
||||
setmetatable(obj, Vec3_inst_meta)
|
||||
return obj
|
||||
end
|
||||
Vec3.new = Vec3_new
|
||||
|
||||
--- Constructs a new copy of a Vec3.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:new_copy()
|
||||
-- Vec3.new_copy(vec)
|
||||
-- Vec3(vec)
|
||||
--
|
||||
-- @return a new Vec3 object that is a copy of the parameter
|
||||
local function Vec3_new_copy(v)
|
||||
local obj = { x = v.x or v[1] or 0.0,
|
||||
y = v.y or v[2] or 0.0,
|
||||
z = v.z or v[3] or 0.0 }
|
||||
setmetatable(obj, Vec3_inst_meta)
|
||||
return obj
|
||||
end
|
||||
Vec3.new_copy = Vec3_new_copy
|
||||
|
||||
Vec3_meta.__call = function(class, a, b, c)
|
||||
if type(a) == "table" then
|
||||
return Vec3.new_copy(a)
|
||||
else
|
||||
return Vec3.new(a, b, c)
|
||||
end
|
||||
end
|
||||
|
||||
--- Computes the square of the length of a Vec3.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:len_sq()
|
||||
-- Vec3.len_sq(vec)
|
||||
--
|
||||
-- @return a number
|
||||
local function Vec3_len_sq(v)
|
||||
return v.x^2 + v.y^2 + v.z^2
|
||||
end
|
||||
Vec3.len_sq = Vec3_len_sq
|
||||
|
||||
--- Computes the length of a Vec3.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:len()
|
||||
-- Vec3.len(vec)
|
||||
--
|
||||
-- @return a number
|
||||
local function Vec3_len(v)
|
||||
return math.sqrt(v.x^2 + v.y^2 + v.z^2)
|
||||
end
|
||||
Vec3.len = Vec3_len
|
||||
|
||||
--- Computes a unit vector pointing in the same direction as a Vec3.
|
||||
-- Undefined for a zero-vector and may throw an error.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:unit()
|
||||
-- Vec3.unit(vec)
|
||||
--
|
||||
-- @return a new Vec3 with length 1.0
|
||||
local function Vec3_unit(v)
|
||||
local len = math.sqrt(v.x^2 + v.y^2 + v.z^2)
|
||||
return Vec3.new(v.x/len, v.y/len, v.z/len)
|
||||
end
|
||||
Vec3.unit = Vec3_unit
|
||||
|
||||
--- Multiplies a Vec3 by a number.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:mul(m)
|
||||
-- Vec3.mul(vec, m)
|
||||
-- vec*m
|
||||
-- m*vec
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_mul(v, m)
|
||||
local mn = tonumber(m)
|
||||
if not mn then error("Can't multiply vector by non-scalar") end
|
||||
return Vec3.new(v.x*mn, v.y*mn, v.z*mn)
|
||||
end
|
||||
Vec3.mul = Vec3_mul
|
||||
Vec3_inst_meta.__mul = function(a, b)
|
||||
if type(a) == "table" then
|
||||
return Vec3_mul(a, b)
|
||||
else
|
||||
return Vec3_mul(b, a)
|
||||
end
|
||||
end
|
||||
|
||||
--- Divides a Vec3 by a number.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:div(m)
|
||||
-- Vec3.div(vec, m)
|
||||
-- vec/m
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_div(v, m)
|
||||
return Vec3.new(v.x/m, v.y/m, v.z/m)
|
||||
end
|
||||
Vec3.div = Vec3_div
|
||||
Vec3_inst_meta.__div = Vec3_div
|
||||
|
||||
--- Negates a Vec3 (signs of all components are inverted).
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:unm()
|
||||
-- Vec3.unm(vec)
|
||||
-- -vec
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_unm(v)
|
||||
return Vec3.new(-v.x, -v.y, -v.z)
|
||||
end
|
||||
Vec3.unm = Vec3_unm
|
||||
Vec3_inst_meta.__unm = Vec3_unm
|
||||
|
||||
--- Adds two Vec3s or a Vec3 composed of three given components.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:add(vec2)
|
||||
-- vec1:add(x, y, z)
|
||||
-- Vec3.add(vec1, vec2)
|
||||
-- Vec3.add(vec1, x, y, z)
|
||||
-- vec1 + vec2
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_add(v, a, b, c)
|
||||
if type(a) == "table" then
|
||||
return Vec3.new(v.x + (a.x or a[1] or 0.0),
|
||||
v.y + (a.y or a[2] or 0.0),
|
||||
v.z + (a.z or a[3] or 0.0))
|
||||
else
|
||||
return Vec3.new(v.x + a, v.y + b, v.z + c)
|
||||
end
|
||||
end
|
||||
Vec3.add = Vec3_add
|
||||
|
||||
--- Subtracts two Vec3s or a Vec3 composed of three given components.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:sub(vec2)
|
||||
-- vec1:sub(x, y, z)
|
||||
-- Vec3.sub(vec1, vec2)
|
||||
-- Vec3.sub(vec1, x, y, z)
|
||||
-- vec1 - vec2
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_sub(v, a, b, c)
|
||||
if type(a) == "table" then
|
||||
return Vec3.new(v.x - (a.x or a[1] or 0.0),
|
||||
v.y - (a.y or a[2] or 0.0),
|
||||
v.z - (a.z or a[3] or 0.0))
|
||||
else
|
||||
return Vec3.new(v.x - a, v.y - b, v.z - c)
|
||||
end
|
||||
end
|
||||
Vec3.sub = Vec3_sub
|
||||
|
||||
--- Tests two Vec3s or a Vec3 composed of three given components for
|
||||
-- exact component-wise equality.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:eq(vec2)
|
||||
-- vec1:eq(x, y, z)
|
||||
-- Vec3.eq(vec1, vec2)
|
||||
-- Vec3.eq(vec1, x, y, z)
|
||||
-- vec1 == vec2
|
||||
-- vec1 ~= vec2
|
||||
-- Note that because of built-in Lua logic "==" and "~=" work ONLY if
|
||||
-- vec1 and vec2 are actually Vec3s (not tables).
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_eq(v, a, b, c)
|
||||
if type(a) == "table" then
|
||||
return v.x == (a.x or a[1] or 0.0) and
|
||||
v.y == (a.y or a[2] or 0.0) and
|
||||
v.z == (a.z or a[3] or 0.0)
|
||||
else
|
||||
return v.x == a and v.y == b and v.z == c
|
||||
end
|
||||
end
|
||||
Vec3.eq = Vec3_eq
|
||||
|
||||
--- Takes the dot product of a Vec3 and a Vec3s or a Vec3 composed of
|
||||
-- three given components.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:dot(vec2)
|
||||
-- vec1:dot(x, y, z)
|
||||
-- Vec3.dot(vec1, vec2)
|
||||
-- Vec3.dot(vec1, x, y, z)
|
||||
--
|
||||
-- @return a number
|
||||
local function Vec3_dot(v, a, b, c)
|
||||
if type(a) == "table" then
|
||||
return v.x * (a.x or a[1] or 0.0) +
|
||||
v.y * (a.y or a[2] or 0.0) +
|
||||
v.z * (a.z or a[3] or 0.0)
|
||||
else
|
||||
return v.x * a + v.y * b + v.z * c
|
||||
end
|
||||
end
|
||||
Vec3.dot = Vec3_dot
|
||||
|
||||
--- Takes the cross product of a Vec3 and a Vec3s or a Vec3 composed of
|
||||
-- three given components.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:cross(vec2)
|
||||
-- vec1:cross(x, y, z)
|
||||
-- Vec3.cross(vec1, vec2)
|
||||
-- Vec3.cross(vec1, x, y, z)
|
||||
--
|
||||
-- @return a new Vec3 with the result of the operation
|
||||
local function Vec3_cross(v, a, b, c)
|
||||
local ux, uy, uz
|
||||
if type(a) == "table" then
|
||||
ux = a.x or a[1] or 0.0
|
||||
uy = a.y or a[2] or 0.0
|
||||
uz = a.z or a[3] or 0.0
|
||||
else
|
||||
ux = a or 0.0
|
||||
uy = b or 0.0
|
||||
uz = c or 0.0
|
||||
end
|
||||
|
||||
return Vec3.new(v.y*uz - v.z*uy, v.z*ux - v.x*uz, v.x*uy - v.y*ux)
|
||||
end
|
||||
Vec3.cross = Vec3_cross
|
||||
|
||||
--- Rotates this (the first) vector around the second vector by the
|
||||
-- given angle.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:rot_around(axis, angle)
|
||||
-- Vec3.rot_around(vec, axis, angle)
|
||||
--
|
||||
-- @param axis
|
||||
-- The axis about which to rotate.
|
||||
-- @param angle
|
||||
-- The angle by which to rotate this vector, in radians.
|
||||
-- @return
|
||||
-- a new Vec3 with the result of the operation.
|
||||
local function Vec3_rot_around(v, axis, angle)
|
||||
local uaxis = Vec3.new_copy(axis):unit()
|
||||
|
||||
local alen = uaxis:dotvec(v)
|
||||
local avec = uaxis:mul(alen)
|
||||
|
||||
local pvec = Vec3.subvec(v, avec)
|
||||
local rvec = uaxis:crossvec(v)
|
||||
|
||||
local v1 = pvec:mul(math.cos(angle))
|
||||
local v2 = rvec:mul(math.sin(angle))
|
||||
|
||||
return avec:addvec(v1):addvec(v2)
|
||||
end
|
||||
Vec3.rot_around = Vec3_rot_around
|
||||
|
||||
--- Adds two Vec3s. Optimized for pure Vec3/table operations by removing
|
||||
-- type checking and conditionals. If called with Vec3-likes table(s),
|
||||
-- ensure all expected components "x", "y", and "z" exist.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:addvec(vec2)
|
||||
-- Vec3.addvec(vec1, vec2)
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_addvec(v1, v2)
|
||||
return Vec3.new(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)
|
||||
end
|
||||
Vec3.addvec = Vec3_addvec
|
||||
Vec3_inst_meta.__add = Vec3_addvec
|
||||
|
||||
--- Subtracts two Vec3s. Optimized for pure Vec3/table operations by
|
||||
-- removing type checking and conditionals. If called with Vec3-likes
|
||||
-- table(s), ensure all expected components "x", "y", and "z" exist.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:subvec(vec2)
|
||||
-- Vec3.subvec(vec1, vec2)
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_subvec(v1, v2)
|
||||
return Vec3.new(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z)
|
||||
end
|
||||
Vec3.subvec = Vec3_subvec
|
||||
Vec3_inst_meta.__sub = Vec3_subvec
|
||||
|
||||
--- Tests two Vec3s for exact component-wise equality. Optimized for pure
|
||||
-- Vec3/table operations by removing type checking and conditionals.
|
||||
-- If called with Vec3-likes table(s), ensure all expected components
|
||||
-- "x", "y", and "z" exist.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:eqvec(vec2)
|
||||
-- Vec3.eqvec(vec1, vec2)
|
||||
--
|
||||
-- @return a new Vec3 object with the result of the operation
|
||||
local function Vec3_eqvec(v1, v2)
|
||||
return v1.x == v2.x and v1.y == v2.y and v1.z == v2.z
|
||||
end
|
||||
Vec3.eqvec = Vec3_eqvec
|
||||
Vec3_inst_meta.__eq = Vec3_eqvec
|
||||
|
||||
--- Takes the dot product of two Vec3s. Optimized for pure Vec3/table
|
||||
-- operations by removing type checking and conditionals. If called
|
||||
-- with Vec3-likes table(s), ensure all expected components "x", "y",
|
||||
-- and "z" exist.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:dotvec(vec2)
|
||||
-- Vec3.dotvec(vec1, vec2)
|
||||
--
|
||||
-- @return a number
|
||||
local function Vec3_dotvec(v1, v2)
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z
|
||||
end
|
||||
Vec3.dotvec = Vec3_dotvec
|
||||
|
||||
--- Takes the cross product of two Vec3s. Optimized for pure Vec3/table
|
||||
-- operations by removing type checking and conditionals. If called
|
||||
-- with Vec3-likes table(s), ensure all expected components "x", "y",
|
||||
-- and "z" exist.
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec1:crossvec(vec2)
|
||||
-- Vec3.crossvec(vec1, vec2)
|
||||
--
|
||||
-- @return a new Vec3 with the result of the operation
|
||||
local function Vec3_crossvec(v1, v2)
|
||||
return Vec3.new(v1.y*v2.z - v1.z*v2.y,
|
||||
v1.z*v2.x - v1.x*v2.z,
|
||||
v1.x*v2.y - v1.y*v2.x)
|
||||
end
|
||||
Vec3.crossvec = Vec3_crossvec
|
||||
|
||||
--- Converts Vec3 to a string with format "(x,y,z)".
|
||||
--
|
||||
-- Call with one of:
|
||||
-- vec:tostring()
|
||||
-- Vec3.tostring(vec)
|
||||
-- tostring(vec)
|
||||
--
|
||||
-- @return a string
|
||||
local function Vec3_tostring(v)
|
||||
return "("..
|
||||
(v.x or v[1] or "0")
|
||||
..","..
|
||||
(v.y or v[2] or "0")
|
||||
..","..
|
||||
(v.z or v[3] or "0")
|
||||
..")"
|
||||
end
|
||||
Vec3.tostring = Vec3_tostring
|
||||
Vec3_inst_meta.__tostring = Vec3_tostring
|
||||
|
||||
return Vec3
|
Before Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 759 B |
Before Width: | Height: | Size: 414 B |
Before Width: | Height: | Size: 164 B |
Before Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 230 B |
Before Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 171 B |
Before Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 187 B |
Before Width: | Height: | Size: 574 B |
Before Width: | Height: | Size: 337 B |
Before Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 192 B |
Before Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 154 B |
Before Width: | Height: | Size: 192 B |
|
@ -1 +0,0 @@
|
|||
potions
|
|
@ -1,161 +0,0 @@
|
|||
potions.register_potion("Anti Gravity", "purple", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(nil, 1.5, 0.5)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been blessed with Anti Gravity for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(nil,1,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Anti Gravity has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Anti Gravity II", "pink", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(3, nil, 0.1)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been blessed with Anti Gravity II for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,nil,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Anti Gravity II has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Speed", "lightgrey", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(3, 1, 1)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been blessed with Speed for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,nil,nil)
|
||||
minetest.chat_send_player(user:get_player_name(), "Speed has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Speed II", "cyan", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(5, 1, 1)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been blessed with Speed II for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,nil,nil)
|
||||
minetest.chat_send_player(user:get_player_name(), "Speed II has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Inversion", "dull", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1, -1, -0.2)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been cursed with Inversion for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,1,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Inversion has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Confusion", "dull", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(-1, nil, nil)
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been cursed with Confusion for 60 seconds!")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,1,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Confusion has worn off.")
|
||||
end)
|
||||
|
||||
potions.register_potion("What will this do", "white", 60,
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(math.random(1, 20), math.random(1, 20), math.random(-4, 2))
|
||||
minetest.chat_send_player(user:get_player_name(), "You have been given unknown powers for good or evil! (60 seconds)")
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
user:set_physics_override(1,1,1)
|
||||
minetest.chat_send_player(user:get_player_name(), "Unknown powers lost.")
|
||||
end)
|
||||
|
||||
potions.register_potion("Instant Health", "pink", 1,
|
||||
function(itemstack, user, pointed_thing)
|
||||
local hp = user:get_hp()
|
||||
user:set_hp(hp + 6)
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
end)
|
||||
|
||||
potions.register_potion("Instant Health II", "pink", 1,
|
||||
function(itemstack, user, pointed_thing)
|
||||
local hp = user:get_hp()
|
||||
local hp_raise = hp + 12
|
||||
user:set_hp(hp_raise)
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
end)
|
||||
|
||||
potions.register_potion("Regen", "purple", 35,
|
||||
function(itemstack, user, pointed_thing)
|
||||
regen_I = true
|
||||
minetest.chat_send_player(user:get_player_name(), "Regeneration I for 35 seconds")
|
||||
if regen_II == true then
|
||||
local regen
|
||||
regen = function ( )
|
||||
local hp = user:get_hp()
|
||||
if hp >= 20 then
|
||||
minetest.after(1, regen)
|
||||
elseif hp < 20 then
|
||||
user:set_hp(hp + 1)
|
||||
minetest.after(1, regen)
|
||||
end
|
||||
end
|
||||
minetest.after(1, regen)
|
||||
end
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
regen_I = false
|
||||
end)
|
||||
|
||||
potions.register_potion("Regen II", "purple", 30,
|
||||
function(itemstack, user, pointed_thing)
|
||||
regen_II = true
|
||||
minetest.chat_send_player(user:get_player_name(), "Regeneration II for 30 seconds")
|
||||
if regen_II == true then
|
||||
local regen
|
||||
regen = function ( )
|
||||
local hp = user:get_hp()
|
||||
if hp >= 20 then
|
||||
minetest.after(.5, regen)
|
||||
elseif hp < 20 then
|
||||
user:set_hp(hp + 1)
|
||||
minetest.after(.5, regen)
|
||||
end
|
||||
end
|
||||
minetest.after(.5, regen)
|
||||
end
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
regen_II = false
|
||||
end)
|
||||
|
||||
potions.register_potion("Harming", "red", 1,
|
||||
function(itemstack, user, pointed_thing)
|
||||
local hp = user:get_hp()
|
||||
local lower = hp - 3
|
||||
user:set_hp(lower)
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
end)
|
||||
|
||||
potions.register_potion("Harming II", "red", 1,
|
||||
function(itemstack, user, pointed_thing)
|
||||
local hp = user:get_hp()
|
||||
local lower = hp - 6
|
||||
user:set_hp(lower)
|
||||
end,
|
||||
|
||||
function(itemstack, user, pointed_thing)
|
||||
end)
|