1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 06:11:47 +02:00

Add [warps]; Reformat and update update_sources for future scripted use

This commit is contained in:
Wouters Dorian
2015-07-09 00:59:05 +02:00
parent e0874db012
commit be03e62452
12 changed files with 905 additions and 99 deletions

19
mods/warps/LICENSE Normal file
View File

@ -0,0 +1,19 @@
warps- a minetest mod that adds more farming crops
See spdx.org/licenses to see what the License Identifiers used below mean.
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
All source code (lua):
(C) Auke Kok <sofar@foo-projects.org>
LGPL-2.0+
All textures, models:
(C) Auke Kok <sofar@foo-projects.org>
CC-BY-SA-3.0
All sounds: read sounds/LICENSE
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

37
mods/warps/README Normal file
View File

@ -0,0 +1,37 @@
"Warps" - a simple warp mod for minetest.
========
/setwarp [name]
/delwarp [name]
/warp [name]
/listwarps
priv: warp_admin - set/change/delete warps
priv: warp_user - list, and use warps
warps are stored in the world folder file "warps.txt".
A warpstone can be given or found in the creative inventory (item
id: warps:warpstone). This warpstone can be placed on the ground
and be programmed to warp players who punch it to a certain warp
location (one of the warps in /listwarps). Right-clicking the item
as a warp_admin user will allow you to program the warpstone. The
warpstone can be removed by shift-punching the warp stone.
All warps are delayed by ~5 seconds. You have to stand still for
that duration, otherwise the warp will be cancelled. This may avoid
warp spamming and warping out of combat a bit. There's a bit
of variation in time due to the timer resolution in minetest
being rather large.
========
Copyright (C) 2015 - Auke Kok <sofar@foo-projects.org>
"warps" is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1
of the license, or (at your option) any later version.

1
mods/warps/depends.txt Normal file
View File

@ -0,0 +1 @@
default

View File

@ -0,0 +1 @@
Warp locations and warp stones (portal stones)

250
mods/warps/init.lua Normal file
View File

@ -0,0 +1,250 @@
--[[
Copyright (C) 2015 - Auke Kok <sofar@foo-projects.org>
"warps" is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1
of the license, or (at your option) any later version.
--]]
warps = {}
warps_queue = {}
queue_state = 0
local warps_freeze = 5
-- t = time in usec
-- p = player obj
-- w = warp name
local warp = function(player, dest)
for i = 1,table.getn(warps) do
if warps[i].name == dest then
player:setpos({x = warps[i].x, y = warps[i].y, z = warps[i].z})
-- MT Core FIXME
-- get functions don't output proper values for set!
-- https://github.com/minetest/minetest/issues/2658
player:set_look_yaw(warps[i].yaw - (math.pi/2))
player:set_look_pitch(0 - warps[i].pitch)
minetest.chat_send_player(player:get_player_name(), "Warped to \"" .. dest .. "\"")
minetest.log("action", player:get_player_name() .. " warped to \"" .. dest .. "\"")
minetest.sound_play("warps_plop", {
pos = {x = warps[i].x, y = warps[i].y, z = warps[i].z},
})
return
end
end
minetest.chat_send_player(player:get_player_name(), "Unknown warp \"" .. dest .. "\"")
end
do_warp_queue = function()
if table.getn(warps_queue) == 0 then
queue_state = 0
return
end
local t = minetest.get_us_time()
for i = table.getn(warps_queue),1,-1 do
local e = warps_queue[i]
if e.p:getpos().x == e.pos.x and e.p:getpos().y == e.pos.y and e.p:getpos().z == e.pos.z then
if t > e.t then
warp(e.p, e.w)
table.remove(warps_queue, i)
end
else
minetest.sound_stop(e.sh)
minetest.chat_send_player(e.p:get_player_name(), "You have to stand still for " .. warps_freeze .. " seconds!")
table.remove(warps_queue, i)
end
end
if table.getn(warps_queue) == 0 then
queue_state = 0
return
end
minetest.after(1, do_warp_queue)
end
local warp_queue_add = function(player, dest)
table.insert(warps_queue, {
t = minetest.get_us_time() + ( warps_freeze * 1000000 ),
pos = player:getpos(),
p = player,
w = dest,
sh = minetest.sound_play("warps_woosh", { pos = player:getpos() })
})
minetest.chat_send_player(player:get_player_name(), "Don't move for " .. warps_freeze .. " seconds!")
if queue_state == 0 then
queue_state = 1
minetest.after(1, do_warp_queue)
end
end
local worldpath = minetest.get_worldpath()
local save = function ()
local fh,err = io.open(worldpath .. "/warps.txt", "w")
if err then
print("No existing warps to read.")
return
end
for i = 1,table.getn(warps) do
local s = warps[i].name .. " " .. warps[i].x .. " " .. warps[i].y .. " " .. warps[i].z .. " " .. warps[i].yaw .. " " .. warps[i].pitch .. "\n"
fh:write(s)
end
fh:close()
end
local load = function ()
local fh,err = io.open(worldpath .. "/warps.txt", "r")
if err then
minetest.log("action", "[warps] loaded ")
return
end
while true do
local line = fh:read()
if line == nil then
break
end
local paramlist = string.split(line, " ")
local w = {
name = paramlist[1],
x = tonumber(paramlist[2]),
y = tonumber(paramlist[3]),
z = tonumber(paramlist[4]),
yaw = tonumber(paramlist[5]),
pitch = tonumber(paramlist[6])
}
table.insert(warps, w)
end
fh:close()
minetest.log("action", "[warps] loaded " .. table.getn(warps) .. " warp location(s)")
end
minetest.register_privilege("warp_admin", {
description = "Allows modification of warp points",
give_to_singleplayer = true,
default = false
})
minetest.register_privilege("warp_user", {
description = "Allows use of warp points",
give_to_singleplayer = true,
default = true
})
minetest.register_chatcommand("setwarp", {
params = "name",
description = "Set a warp location to the players location",
privs = { warp_admin = true },
func = function(name, param)
local h = "created"
for i = 1,table.getn(warps) do
if warps[i].name == param then
table.remove(warps, i)
h = "changed"
break
end
end
local player = minetest.get_player_by_name(name)
local pos = player:getpos()
table.insert(warps, { name = param, x = pos.x, y = pos.y, z = pos.z, yaw = player:get_look_yaw(), pitch = player:get_look_pitch() })
save()
minetest.log("action", name .. " " .. h .. " warp \"" .. param .. "\": " .. pos.x .. ", " .. pos.y .. ", " .. pos.z)
return true, h .. " warp \"" .. param .. "\""
end,
})
minetest.register_chatcommand("delwarp", {
params = "name",
description = "Set a warp location to the players location",
privs = { warp_admin = true },
func = function(name, param)
for i = 1,table.getn(warps) do
if warps[i].name == param then
table.remove(warps, i)
minetest.log("action", name .. " removed warp \"" .. param .. "\"")
return true, "Removed warp \"" .. param .. "\""
end
end
return false, "Unknown warp location \"" .. param .. "\""
end,
})
minetest.register_chatcommand("listwarps", {
params = "name",
description = "List known warp locations",
privs = { warp_user = true },
func = function(name, param)
local s = "List of known warp locations:\n"
for i = 1,table.getn(warps) do
s = s .. "- " .. warps[i].name .. "\n"
end
return true, s
end
})
minetest.register_chatcommand("warp", {
params = "name",
description = "Warp to a warp location",
privs = { warp_user = true },
func = function(name, param)
local player = minetest.get_player_by_name(name)
warp_queue_add(player, param)
end
})
minetest.register_node("warps:warpstone", {
visual = "mesh",
mesh = "warps_warpstone.obj",
description = "A Warp Stone",
tiles = { "warps_warpstone.png" },
drawtype = "mesh",
sunlight_propagates = true,
walkable = false,
paramtype = "light",
groups = { choppy=3 },
light_source = 8,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.5, 0.25}
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"field[destination;Warp Destination;]")
meta:set_string("infotext", "Uninitialized Warp Stone")
end,
on_receive_fields = function(pos, formname, fields, sender)
if not minetest.check_player_privs(sender:get_player_name(), {warp_admin = true}) then
minetest.chat_send_player(sender:get_player_name(), "You do not have permission to modify warp stones")
return false
end
if not fields.destination then
return
end
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"field[destination;Warp Destination;" .. fields.destination .. "]")
meta:set_string("infotext", "Warp stone to " .. fields.destination)
meta:set_string("warps_destination", fields.destination)
minetest.log("action", sender:get_player_name() .. " changed warp stone to \"" .. fields.destination .. "\"")
end,
on_punch = function(pos, node, puncher, pointed_thingo)
if puncher:get_player_control().sneak and minetest.check_player_privs(puncher:get_player_name(), {warp_admin = true}) then
minetest.remove_node(pos)
minetest.chat_send_player(puncher:get_player_name(), "Warp stone removed!")
return
end
local meta = minetest.get_meta(pos)
local destination = meta:get_string("warps_destination")
if destination == "" then
minetest.chat_send_player(puncher:get_player_name(), "Unknown warp location for this warp stone, cannot warp!")
return false
end
warp_queue_add(puncher, destination)
end,
})
-- load existing warps
load()

View File

@ -0,0 +1,70 @@
# Blender v2.60 (sub 0) OBJ File: ''
# www.blender.org
mtllib warps_warpstone.mtl
o Plane
v 0.000345 -0.332211 0.238072
v -0.238873 -0.332211 -0.000181
v -0.187467 0.347788 0.000753
v 0.003339 0.347788 0.186987
v -0.000061 0.473738 -0.000013
v -0.000061 -0.400212 -0.000013
v 0.238345 -0.332211 0.000071
v 0.187345 0.347788 -0.000779
v -0.000467 -0.332211 -0.238097
v -0.003461 0.347788 -0.187013
vt 0.247005 0.000534
vt 0.000000 0.000534
vt 0.000000 0.499516
vt 0.247005 0.499516
vt 0.744000 0.749758
vt 0.744000 0.501019
vt 0.248498 0.501019
vt 0.248498 0.749758
vt 0.495503 0.000534
vt 0.248498 0.000534
vt 0.248498 0.499516
vt 0.495503 0.499516
vt 0.744000 1.000000
vt 0.744000 0.751261
vt 0.248498 0.751261
vt 0.248498 1.000000
vt 0.247005 1.000000
vt 0.247005 0.752012
vt 0.000746 1.000000
vt 0.497742 0.249273
vt 0.744000 0.001285
vt 0.744000 0.249273
vt 0.744000 0.251528
vt 0.497742 0.499516
vt 0.744000 0.499516
vt 0.247005 0.749758
vt 0.000746 0.749758
vt 0.247005 0.501770
vt 0.000000 0.751261
vt 0.000000 0.999249
vt 0.246259 0.751261
vt 0.743254 0.000534
vt 0.496995 0.248522
vt 0.496995 0.000534
vt 0.496995 0.250776
vt 0.496995 0.498764
vt 0.743254 0.250776
vt 0.000000 0.501019
vt 0.246259 0.501019
vt 0.000000 0.749006
g Plane_Plane_Material.001
usemtl Material.001
s off
f 2/1 1/2 4/3 3/4
f 1/5 7/6 8/7 4/8
f 7/9 9/10 10/11 8/12
f 9/13 2/14 3/15 10/16
s 1
f 5/17 3/18 4/19
f 1/20 2/21 6/22
f 7/23 1/24 6/25
f 5/26 4/27 8/28
f 5/29 8/30 10/31
f 9/32 7/33 6/34
f 6/35 2/36 9/37
f 5/38 10/39 3/40

10
mods/warps/sounds/LICENSE Normal file
View File

@ -0,0 +1,10 @@
File: warps_plop.ogg
Original: 19987__acclivity__fingerplop1.flac
Url: https://www.freesound.org/people/acclivity/sounds/19987/
License: CC-BY-NC-3.0
File: warps_woosh.ogg
Original: 112837__dymewiz__whoosh-21.wav
Url: https://www.freesound.org/people/Dymewiz/sounds/112837/
License: CC-BY-3.0

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B