Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lottpotion = {}
- dofile(minetest.get_modpath("lottpotion").."/cauldron.lua")
- lottpotion = {
- players = {},
- effects = {
- phys_override = function(sname, name, fname, time, sdata, flags)
- local def = {
- on_use = function(itemstack, user, pointed_thing)
- lottpotion.grant(time, user:get_player_name(), fname.."_"..flags.type..sdata.type, name, flags)
- local playerpos = user:getpos();
- minetest.add_particlespawner(
- 7, --amount
- 0.1, --time
- {x=playerpos.x-1, y=playerpos.y+1, z=playerpos.z-1}, --minpos
- {x=playerpos.x+1, y=playerpos.y+1, z=playerpos.z+1}, --maxpos
- {x=-0, y=3, z=-0}, --minvel
- {x=0, y=4, z=0}, --maxvel
- {x=-0.5,y=0,z=-0.5}, --minacc
- {x=0.5,y=1,z=0.5}, --maxacc
- 0.1, --minexptime
- 0.2, --maxexptime
- 1, --minsize
- 1, --maxsize
- false, --collisiondetection
- "bubble.png" --texture
- )
- -- play sound
- local pos = user:getpos()
- minetest.sound_play("pop", {
- pos = pos,
- gain = 1.0,
- max_hear_distance = 5
- })
- itemstack:take_item()
- return itemstack
- end,
- lottpotion = {
- speed = 0,
- jump = 0,
- gravity = 0,
- air = 0,
- },
- }
- return def
- end,
- fixhp = function(sname, name, fname, time, sdata, flags)
- local def = {
- on_use = function(itemstack, user, pointed_thing)
- for i=0, (sdata.time or 0) do
- minetest.after(i, function()
- local hp = user:get_hp()
- if flags.inv==true then
- hp = hp - (sdata.hp or 3)
- else
- hp = hp + (sdata.hp or 3)
- end
- hp = math.min(20, hp)
- hp = math.max(0, hp)
- user:set_hp(hp)
- end)
- end
- local playerpos = user:getpos();
- minetest.add_particlespawner(
- 7, --amount
- 0.1, --time
- {x=playerpos.x-1, y=playerpos.y+1, z=playerpos.z-1}, --minpos
- {x=playerpos.x+1, y=playerpos.y+1, z=playerpos.z+1}, --maxpos
- {x=-0, y=3, z=-0}, --minvel
- {x=0, y=4, z=0}, --maxvel
- {x=-0.5,y=0,z=-0.5}, --minacc
- {x=0.5,y=1,z=0.5}, --maxacc
- 0.1, --minexptime
- 0.2, --maxexptime
- 1, --minsize
- 1, --maxsize
- false, --collisiondetection
- "bubble.png" --texture
- )
- -- play sound
- local pos = user:getpos()
- minetest.sound_play("pop", {
- pos = pos,
- gain = 1.0,
- max_hear_distance = 5
- })
- itemstack:take_item()
- return itemstack
- end,
- }
- def.mobs = {
- on_near = def.on_use,
- }
- return def
- end,
- air = function(sname, name, fname, time, sdata, flags)
- local def = {
- on_use = function(itemstack, user, pointed_thing)
- local lottpotion_e = lottpotion.players[user:get_player_name()]
- lottpotion_e.air = lottpotion_e.air + (sdata.time or 0)
- for i=0, (sdata.time or 0) do
- minetest.after(i, function()
- local br = user:get_breath()
- if flags.inv==true then
- br = br - (sdata.br or 3)
- else
- br = br + (sdata.br or 3)
- end
- br = math.min(11, br)
- br = math.max(0, br)
- user:set_breath(br)
- if i==(sdata.time or 0) then
- lottpotion_e.air = lottpotion_e.air - (sdata.time or 0)
- end
- end)
- end
- local playerpos = user:getpos();
- minetest.add_particlespawner(
- 7, --amount
- 0.1, --time
- {x=playerpos.x-1, y=playerpos.y+1, z=playerpos.z-1}, --minpos
- {x=playerpos.x+1, y=playerpos.y+1, z=playerpos.z+1}, --maxpos
- {x=-0, y=3, z=-0}, --minvel
- {x=0, y=4, z=0}, --maxvel
- {x=-0.5,y=0,z=-0.5}, --minacc
- {x=0.5,y=1,z=0.5}, --maxacc
- 0.1, --minexptime
- 0.2, --maxexptime
- 1, --minsize
- 1, --maxsize
- false, --collisiondetection
- "bubble.png" --texture
- )
- -- play sound
- local pos = user:getpos()
- local pos = user:getpos()
- minetest.sound_play("pop", {
- pos = pos,
- gain = 1.0,
- max_hear_distance = 5
- })
- itemstack:take_item()
- return itemstack
- end,
- }
- return def
- end,
- },
- grant = function(time, playername, potion_name, type, flags)
- local rootdef = minetest.registered_items[potion_name]
- if rootdef == nil then
- return
- end
- if rootdef.lottpotion == nil then
- return
- end
- local def = {}
- for name, val in pairs(rootdef.lottpotion) do
- def[name] = val
- end
- if flags.inv==true then
- def.gravity = 0 - def.gravity
- def.speed = 0 - def.speed
- def.jump = 0 - def.jump
- end
- lottpotion.addPrefs(playername, def.speed, def.jump, def.gravity)
- lottpotion.refresh(playername)
- --Disable physical effects
- minetest.after(time, function()
- lottpotion.addPrefs(playername, 0-def.speed, 0-def.jump, 0-def.gravity)
- lottpotion.refresh(playername)
- --minetest.chat_send_all(types[time])
- end)
- end,
- addPrefs = function(playername, speed, jump, gravity)
- local prefs = lottpotion.players[playername]
- prefs.speed = prefs.speed + speed
- prefs.jump = prefs.jump + jump
- prefs.gravity = prefs.gravity + gravity
- end,
- refresh = function(playername)
- if minetest.get_player_by_name(playername)~=nil then
- local prefs = lottpotion.players[playername]
- minetest.get_player_by_name(playername):set_physics_override(prefs.speed, prefs.jump, prefs.gravity)
- end
- end,
- -- Register potions
- register_potion = function(sname, name, fname, time, def)
- local tps = {"", "corrupted"}
- for t=1, #tps do
- for i=1, #def.types do
- local sdata = def.types[i]
- local item_def = {
- description = "Potion of "..name.." "..sdata.type.." "..tps[t],
- inventory_image = "lottpotion_"..(def.texture or sname)..".png^lottpotion_"..tps[t]..sdata.type..".png^lottpotion_bottle.png",
- drawtype = "plantlike",
- paramtype = "light",
- walkable = false,
- stack_max = 1,
- groups = {dig_immediate=3,attached_node=1,vessel=1},
- sounds = default.node_sound_glass_defaults(),
- }
- item_def.tiles = {item_def.inventory_image}
- local flags = {
- inv = false,
- type = tps[t],
- }
- if t == 2 then
- flags.inv = true
- end
- for name, val in pairs(lottpotion.effects[def.effect](sname, name, fname, time, sdata, flags)) do
- item_def[name] = val
- end
- for name, val in pairs(sdata.set) do
- item_def[name] = val
- end
- for name, val in pairs(sdata.effects) do
- item_def.lottpotion[name] = val
- end
- minetest.register_node(fname.."_"..tps[t]..sdata.type, item_def)
- --potions.register_liquid(i..tps[t]..sname, name.." ("..tps[t].." "..i..")", item_def.on_use)
- if minetest.get_modpath("lottthrowing")~=nil then
- lottpotion.register_arrow(fname.."_"..tps[t]..sdata.type, i..tps[t]..sname, name.." ("..tps[t].." "..i..")", item_def.on_use,
- item_def.description, item_def.inventory_image)
- end
- end
- end
- end,
- }
- lottpotion.register_potion("regeneration", "Regeneration", "lottpotion:regeneration", 100, {
- effect = "fixhp",
- types = {
- {
- type = 1,
- hp = 1,
- time = 10,
- set = {},
- effects = {
- },
- },
- {
- type = 2,
- hp = 2,
- time = 120,
- set = {},
- effects = {
- },
- },
- }
- })
- lottpotion.register_potion("health", "Health", "lottpotion:health", 300, {
- effect = "fixhp",
- types = {
- {
- type = 1,
- hp = 5,
- set = {},
- effects = {
- },
- },
- {
- type = 2,
- hp = 10,
- set = {},
- effects = {
- },
- },
- }
- })
- lottpotion.register_potion("speed", "Swiftness", "lottpotion:speed", 100, {
- effect = "phys_override",
- types = {
- {
- type = 1,
- time = 10,
- set = {},
- effects = {
- speed = 1,
- },
- },
- {
- type = 2,
- time = 100,
- set = {},
- effects = {
- speed = 1,
- },
- },
- }
- })
- minetest.register_on_joinplayer(function(player)
- lottpotion.players[player:get_player_name()] = {
- speed = 1,
- jump = 1,
- gravity = 1,
- air = 0,
- }
- end)
- minetest.register_chatcommand("effects", {
- params = "none",
- description = "Effects info",
- func = function(name, param)
- minetest.chat_send_player(name, "effects:")
- local lottpotion_e = lottpotion.players[name]
- if lottpotion_e~=nil then
- for potion_name, val in pairs(lottpotion_e) do
- minetest.chat_send_player(name, potion_name .. "=" .. val)
- end
- end
- end,
- })
- function lottpotion.can_dig(pos, player)
- local meta = minetest.get_meta(pos)
- local inv = meta:get_inventory()
- if not ( inv:is_empty("src1") and inv:is_empty("src2") and inv:is_empty("src3")) or
- not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
- --minetest.chat_send_player(player:get_player_name(), "Brewer cannot be removed because it is not empty")
- return false
- else
- return true
- end
- end
- function lottpotion.swap_node(pos, name)
- local node = minetest.get_node(pos)
- if node.name ~= name then
- node.name = name
- minetest.swap_node(pos, node)
- end
- return node.name
- end
- dofile(minetest.get_modpath("lottpotion").."/potionbrewing.lua")
- dofile(minetest.get_modpath("lottpotion").."/invisibility.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement