added flight potion
This commit is contained in:
parent
57ac061f67
commit
621be8bb84
@ -6,7 +6,7 @@ Ethereal Mapgen mod for Minetest (works on all except v6)
|
||||
- https://forum.minetest.net/viewtopic.php?f=11&t=14638
|
||||
|
||||
## Lucky Blocks
|
||||
45
|
||||
46
|
||||
|
||||
## Changelog
|
||||
|
||||
@ -17,6 +17,7 @@ Ethereal Mapgen mod for Minetest (works on all except v6)
|
||||
- Rewrite stairs and add auto-select function
|
||||
- Added Lemonade
|
||||
- Added smaller redwood trees, to grow large variety 2 saplings required
|
||||
- Added Flight Potion (etherium dust arch, fire dust middle, empty bottle bottom)
|
||||
|
||||
### 1.27
|
||||
|
||||
|
146
flight.lua
Normal file
146
flight.lua
Normal file
@ -0,0 +1,146 @@
|
||||
local timer_check = 5 -- seconds per check
|
||||
local flight_secs = 5 * 60 -- seconds of flight
|
||||
local S = ethereal.intllib
|
||||
|
||||
|
||||
-- disable flight
|
||||
local function set_flight(user, set)
|
||||
|
||||
local privs = minetest.get_player_privs(user:get_player_name())
|
||||
privs.fly = set
|
||||
minetest.set_player_privs(user:get_player_name(), privs)
|
||||
end
|
||||
|
||||
|
||||
-- after function
|
||||
local function ethereal_set_flight(user)
|
||||
|
||||
local meta = user:get_meta() ; if not meta then return end
|
||||
local timer = tonumber(meta:get_string("ethereal:fly_timer"))
|
||||
local privs = minetest.get_player_privs(user:get_player_name())
|
||||
|
||||
-- timer ran out, remove 'fly' privelage
|
||||
if not timer or timer <= 0 then
|
||||
set_flight(user, nil)
|
||||
return
|
||||
end
|
||||
|
||||
-- have we already applied 'fly' privelage?
|
||||
if not privs.fly then
|
||||
set_flight(user, true)
|
||||
end
|
||||
|
||||
-- handle timer
|
||||
timer = timer - timer_check
|
||||
|
||||
local name = user:get_player_name()
|
||||
|
||||
if timer < 10 then
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
minetest.get_color_escape_sequence("#ff5500")
|
||||
.. S("Flight timer about to expire!"))
|
||||
|
||||
minetest.sound_play("default_dig_dig_immediate",
|
||||
{to_player = name, gain = 1.0}, true)
|
||||
end
|
||||
|
||||
meta:set_string("ethereal:fly_timer", timer) -- lower timer
|
||||
|
||||
minetest.after(timer_check, function()
|
||||
ethereal_set_flight(user)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
-- on join / leave
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
||||
local meta = player:get_meta() ; if not meta then return end
|
||||
local privs = minetest.get_player_privs(player:get_player_name())
|
||||
|
||||
if privs.fly then
|
||||
|
||||
local timer = tonumber(meta:get_string("ethereal:fly_timer"))
|
||||
|
||||
if timer <= 0 then
|
||||
set_flight(player, nil)
|
||||
else
|
||||
ethereal_set_flight(player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- potion item
|
||||
minetest.register_node("ethereal:flight_potion", {
|
||||
description = S("Flight Potion"),
|
||||
drawtype = "plantlike",
|
||||
tiles = {"ethereal_flight_potion.png"},
|
||||
inventory_image = "ethereal_flight_potion.png",
|
||||
wield_image = "ethereal_flight_potion.png",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.2, -0.37, -0.2, 0.2, 0.31, 0.2}
|
||||
},
|
||||
groups = {dig_immediate = 3},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
-- get privs
|
||||
local name = user:get_player_name()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
local meta = user:get_meta()
|
||||
local timer = meta:get_string("ethereal:fly_timer")
|
||||
|
||||
if privs.fly then
|
||||
minetest.chat_send_player(name,
|
||||
minetest.get_color_escape_sequence("#ffff00")
|
||||
.. S("Flight already granted, @1 seconds left!", timer))
|
||||
return
|
||||
end
|
||||
|
||||
if not meta then return end
|
||||
|
||||
meta:set_string("ethereal:fly_timer", flight_secs)
|
||||
|
||||
minetest.chat_send_player(name,
|
||||
minetest.get_color_escape_sequence("#1eff00")
|
||||
.. S("Flight granted, you have @1 seconds!", flight_secs))
|
||||
|
||||
ethereal_set_flight(user)
|
||||
|
||||
-- take item
|
||||
itemstack:take_item()
|
||||
|
||||
-- return empty bottle
|
||||
local inv = user:get_inventory()
|
||||
|
||||
if inv:room_for_item("main", {name = "vessels:glass_bottle"}) then
|
||||
user:get_inventory():add_item("main", "vessels:glass_bottle")
|
||||
else
|
||||
local pos = user:get_pos()
|
||||
pos.y = pos.y + 0.5
|
||||
minetest.add_item(pos, {name = "vessels:glass_bottle"})
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- recipe
|
||||
if ethereal.flight then
|
||||
minetest.register_craft({
|
||||
output = "ethereal:flight_potion",
|
||||
recipe = {
|
||||
{"ethereal:etherium_dust", "ethereal:etherium_dust", "ethereal:etherium_dust"},
|
||||
{"ethereal:etherium_dust", "ethereal:fire_dust", "ethereal:etherium_dust"},
|
||||
{"ethereal:etherium_dust", "vessels:glass_bottle", "ethereal:etherium_dust"},
|
||||
}
|
||||
})
|
||||
end
|
5
init.lua
5
init.lua
@ -19,6 +19,7 @@ ethereal = {
|
||||
papyruswalk = minetest.settings:get_bool('ethereal.papyruswalk', true),
|
||||
lilywalk = minetest.settings:get_bool('ethereal.lilywalk', true),
|
||||
xcraft = minetest.settings:get_bool('ethereal.xcraft', true),
|
||||
flight = minetest.settings:get_bool('ethereal.flight', true),
|
||||
|
||||
glacier = minetest.settings:get('ethereal.glacier') or 1,
|
||||
bamboo = minetest.settings:get('ethereal.bamboo') or 1,
|
||||
@ -109,6 +110,10 @@ dofile(path .. "/compatibility.lua")
|
||||
dofile(path .. "/stairs.lua")
|
||||
dofile(path .. "/lucky_block.lua")
|
||||
|
||||
if ethereal.flight then
|
||||
dofile(path .. "/flight.lua")
|
||||
end
|
||||
|
||||
-- Set bonemeal aliases
|
||||
if minetest.get_modpath("bonemeal") then
|
||||
minetest.register_alias("ethereal:bone", "bonemeal:bone")
|
||||
|
@ -33,6 +33,7 @@ lucky_block:add_blocks({
|
||||
{"dro", {"ethereal:willow_sapling"} ,5},
|
||||
{"dro", {"ethereal:mushroom_sapling"} ,5},
|
||||
{"dro", {"ethereal:palm_sapling"} ,5},
|
||||
{"dro", {"ethereal:flight_potion", 1},
|
||||
{"dro", {"ethereal:birch_sapling"} ,5},
|
||||
{"dro", {"ethereal:redwood_sapling"} ,1},
|
||||
{"dro", {"ethereal:prairie_dirt"}, 10},
|
||||
|
@ -11,6 +11,7 @@ ethereal.torchdrop = true -- torches drop when touching water
|
||||
ethereal.papyruswalk = true -- papyrus can be walked on
|
||||
ethereal.lilywalk = true -- waterlilies can be walked on
|
||||
ethereal.xcraft = true -- allow cheat crafts for cobble->gravel->dirt->sand, ice->snow, dry dirt->desert sand
|
||||
ethereal.flight = true -- allow flight potion recipe
|
||||
|
||||
-- Set following to 1 to enable biome or false to disable
|
||||
ethereal.glacier = 1 -- Ice glaciers with snow
|
||||
|
@ -6,6 +6,7 @@ ethereal.torchdrop (Torches drop when in water) bool true
|
||||
ethereal.papyruswalk (Papyrus and Bamboo are walkable) bool true
|
||||
ethereal.lilywalk (Lilypads are walkable) bool true
|
||||
ethereal.xcraft (Enable X-Craft cheats) bool true
|
||||
ethereal.flight (Enable Flight Potion) bool true
|
||||
|
||||
ethereal.glacier (Glacier biome, 1 = Enable / 0 = Disable) int 1
|
||||
ethereal.bambo (Bamboo biome, 1 = Enable / 0 = Disable) int 1
|
||||
|
BIN
textures/ethereal_flight_potion.png
Normal file
BIN
textures/ethereal_flight_potion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 B |
Loading…
Reference in New Issue
Block a user