mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-23 16:30:19 +01:00
Added cloned returnmirror
This commit is contained in:
parent
b155e363e7
commit
47f1c985a9
28
mods/returnmirror/README.txt
Normal file
28
mods/returnmirror/README.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Mirror of Return
|
||||||
|
================
|
||||||
|
Version 0.1.0
|
||||||
|
|
||||||
|
## Description
|
||||||
|
This mod adds a magical item, the Mirror of Returning. This item teleports the user back to a previously
|
||||||
|
set location, at the cost of some mana (if applicable).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Rightclick with the item onto a node to set the mirror's teleport location.
|
||||||
|
Leftclick while holding the mirror to immediately teleport back to the mirror's teleport location.
|
||||||
|
Each mirror has is own teleport location and “remembers” it throughout the game, until a new
|
||||||
|
teleport location has been set.
|
||||||
|
|
||||||
|
Initially, a mirror has no teleport location set, so you have to set it before the first teleportation.
|
||||||
|
|
||||||
|
If the Mana mod [mana] is present, setting and teleporting costs mana. The default cost are:
|
||||||
|
|
||||||
|
* Setting: 20
|
||||||
|
* Teleporting back to set position: 200
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
You can change the mana costs via minetest.conf. The following settings are used:
|
||||||
|
|
||||||
|
* `returnmirror_cost_set`: Mana cost for setting (number)
|
||||||
|
* `returnmirror_cost_teleport`: Mana cost for teleporting (number)
|
||||||
|
|
||||||
|
If a setting is not present, the default cost is used.
|
1
mods/returnmirror/depends.txt
Normal file
1
mods/returnmirror/depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
mana?
|
1
mods/returnmirror/description.txt
Normal file
1
mods/returnmirror/description.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Adds the “Mirror of Returning”, a magical item which teleports the user to a previously set location.
|
103
mods/returnmirror/init.lua
Normal file
103
mods/returnmirror/init.lua
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
returnmirror = {}
|
||||||
|
returnmirror.cost_teleport = 200
|
||||||
|
returnmirror.cost_set = 20
|
||||||
|
|
||||||
|
if tonumber(minetest.setting_get("returnmirror_cost_teleport")) ~= nil then
|
||||||
|
returnmirror.cost_teleport = tonumber(minetest.setting_get("returnmirror_cost_teleport"))
|
||||||
|
end
|
||||||
|
if tonumber(minetest.setting_get("returnmirror_cost_set")) ~= nil then
|
||||||
|
returnmirror.cost_set = tonumber(minetest.setting_get("returnmirror_cost_set"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if minetest.get_modpath("mana") ~= nil then
|
||||||
|
returnmirror.mana = true
|
||||||
|
else
|
||||||
|
returnmirror.mana = false
|
||||||
|
end
|
||||||
|
|
||||||
|
returnmirror.mana_check = function(player, cost)
|
||||||
|
local allowed
|
||||||
|
if returnmirror.mana then
|
||||||
|
if mana.subtract(player:get_player_name(), cost) then
|
||||||
|
allowed = true
|
||||||
|
else
|
||||||
|
allowed = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
allowed = true
|
||||||
|
end
|
||||||
|
return allowed
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_tool("returnmirror:mirror_inactive", {
|
||||||
|
description = "Mirror of Returning",
|
||||||
|
inventory_image = "returnmirror_mirror_inactive.png",
|
||||||
|
wield_image = "returnmirror_mirror_inactive.png",
|
||||||
|
tool_capabilities = {},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if returnmirror.mana_check(placer, returnmirror.cost_set) then
|
||||||
|
local pos = placer:getpos()
|
||||||
|
local newitem = ItemStack("returnmirror:mirror_active")
|
||||||
|
newitem:set_metadata(minetest.pos_to_string(pos))
|
||||||
|
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
|
||||||
|
return newitem
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_tool("returnmirror:mirror_active", {
|
||||||
|
description = "Mirror of Returning",
|
||||||
|
stack_max = 1,
|
||||||
|
inventory_image = "returnmirror_mirror_active.png",
|
||||||
|
wield_image = "returnmirror_mirror_active.png",
|
||||||
|
tool_capabilities = {},
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
local dest_string = itemstack:get_metadata()
|
||||||
|
local dest = minetest.string_to_pos(dest_string)
|
||||||
|
if dest ~= nil then
|
||||||
|
if returnmirror.mana_check(user, returnmirror.cost_teleport) then
|
||||||
|
local src = user:getpos()
|
||||||
|
minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=src, max_hear_distance=30})
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 50,
|
||||||
|
time = 0.1,
|
||||||
|
minpos = {x=src.x-0.4, y=src.y+0.25, z=src.z-0.4},
|
||||||
|
maxpos = {x=src.x+0.4, y=src.y+0.75, z=src.z+0.4},
|
||||||
|
minvel = {x=-0.2, y=-0.2, z=-0.2},
|
||||||
|
maxvel = {x=0.2, y=0.2, z=0.2},
|
||||||
|
minexptime=3,
|
||||||
|
maxexptime=4.5,
|
||||||
|
minsize=1,
|
||||||
|
maxsize=1.25,
|
||||||
|
texture = "returnmirror_particle_departure.png",
|
||||||
|
})
|
||||||
|
user:setpos(dest)
|
||||||
|
minetest.sound_play( {name="returnmirror_teleport", gain=1}, {pos=dest, max_hear_distance=30})
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 100,
|
||||||
|
time = 0.1,
|
||||||
|
minpos = {x=dest.x-0.4, y=dest.y+0.25, z=dest.z-0.4},
|
||||||
|
maxpos = {x=dest.x+0.4, y=dest.y+0.75, z=dest.z+0.4},
|
||||||
|
minvel = {x=-0.4, y=-0.3, z=-0.4},
|
||||||
|
maxvel = {x=0.4, y=0.3, z=0.4},
|
||||||
|
minexptime=6,
|
||||||
|
maxexptime=12,
|
||||||
|
minsize=1,
|
||||||
|
maxsize=1.25,
|
||||||
|
texture = "returnmirror_particle_arrival.png",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
if returnmirror.mana_check(placer, returnmirror.cost_set) then
|
||||||
|
local pos = placer:getpos()
|
||||||
|
itemstack:set_metadata(minetest.pos_to_string(pos))
|
||||||
|
minetest.sound_play( {name="returnmirror_set", gain=1}, {pos=pos, max_hear_distance=12})
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
groups = { not_in_creative_inventory = 1 },
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_alias("returnmirror:mirror_inactive", "returnmirror:returnmirror")
|
BIN
mods/returnmirror/sounds/returnmirror_set.ogg
Normal file
BIN
mods/returnmirror/sounds/returnmirror_set.ogg
Normal file
Binary file not shown.
BIN
mods/returnmirror/sounds/returnmirror_teleport.ogg
Normal file
BIN
mods/returnmirror/sounds/returnmirror_teleport.ogg
Normal file
Binary file not shown.
BIN
mods/returnmirror/textures/returnmirror_mirror_active.png
Normal file
BIN
mods/returnmirror/textures/returnmirror_mirror_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 456 B |
BIN
mods/returnmirror/textures/returnmirror_mirror_inactive.png
Normal file
BIN
mods/returnmirror/textures/returnmirror_mirror_inactive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 298 B |
BIN
mods/returnmirror/textures/returnmirror_particle_arrival.png
Normal file
BIN
mods/returnmirror/textures/returnmirror_particle_arrival.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
BIN
mods/returnmirror/textures/returnmirror_particle_departure.png
Normal file
BIN
mods/returnmirror/textures/returnmirror_particle_departure.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 B |
Loading…
Reference in New Issue
Block a user