mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Rename minetest.*
to core.*
in devtest
This commit is contained in:
parent
d849d51c2d
commit
88c7a54e08
78 changed files with 914 additions and 914 deletions
|
@ -1,4 +1,4 @@
|
|||
local S = minetest.get_translator("testpathfinder")
|
||||
local S = core.get_translator("testpathfinder")
|
||||
|
||||
-- Config parameters
|
||||
|
||||
|
@ -37,26 +37,26 @@ local function find_path_for_player(player, itemstack)
|
|||
local pos1 = vector.round(player:get_pos())
|
||||
-- Don't bother calling pathfinder for high distance to avoid freezing
|
||||
if (not IGNORE_MAX_DISTANCE_SAFEGUARD) and (vector.distance(pos1, pos2) > MAX_DIRECT_DISTANCE) then
|
||||
minetest.chat_send_player(player:get_player_name(), S("Destination too far away! Set a destination (via placing) within a distance of @1 and try again!", MAX_DIRECT_DISTANCE))
|
||||
core.chat_send_player(player:get_player_name(), S("Destination too far away! Set a destination (via placing) within a distance of @1 and try again!", MAX_DIRECT_DISTANCE))
|
||||
return
|
||||
end
|
||||
local str = S("Path from @1 to @2:",
|
||||
minetest.pos_to_string(pos1),
|
||||
minetest.pos_to_string(pos2))
|
||||
core.pos_to_string(pos1),
|
||||
core.pos_to_string(pos2))
|
||||
|
||||
minetest.chat_send_player(player:get_player_name(), str)
|
||||
local time_start = minetest.get_us_time()
|
||||
local path = minetest.find_path(pos1, pos2, MAX_SEARCH_DISTANCE, MAX_JUMP, MAX_DROP, algo)
|
||||
local time_end = minetest.get_us_time()
|
||||
core.chat_send_player(player:get_player_name(), str)
|
||||
local time_start = core.get_us_time()
|
||||
local path = core.find_path(pos1, pos2, MAX_SEARCH_DISTANCE, MAX_JUMP, MAX_DROP, algo)
|
||||
local time_end = core.get_us_time()
|
||||
local time_diff = time_end - time_start
|
||||
str = ""
|
||||
if not path then
|
||||
minetest.chat_send_player(player:get_player_name(), S("No path!"))
|
||||
minetest.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000))
|
||||
core.chat_send_player(player:get_player_name(), S("No path!"))
|
||||
core.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000))
|
||||
return
|
||||
end
|
||||
for s=1, #path do
|
||||
str = str .. minetest.pos_to_string(path[s]) .. "\n"
|
||||
str = str .. core.pos_to_string(path[s]) .. "\n"
|
||||
local t
|
||||
if s == #path then
|
||||
t = "testpathfinder_waypoint_end.png"
|
||||
|
@ -66,18 +66,18 @@ local function find_path_for_player(player, itemstack)
|
|||
local c = math.floor(((#path-s)/#path)*255)
|
||||
t = string.format("testpathfinder_waypoint.png^[multiply:#%02x%02x00", 0xFF-c, c)
|
||||
end
|
||||
minetest.add_particle({
|
||||
core.add_particle({
|
||||
pos = path[s],
|
||||
expirationtime = 5 + 0.2 * s,
|
||||
playername = player:get_player_name(),
|
||||
glow = minetest.LIGHT_MAX,
|
||||
glow = core.LIGHT_MAX,
|
||||
texture = t,
|
||||
size = 3,
|
||||
})
|
||||
end
|
||||
minetest.chat_send_player(player:get_player_name(), str)
|
||||
minetest.chat_send_player(player:get_player_name(), S("Path length: @1", #path))
|
||||
minetest.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000))
|
||||
core.chat_send_player(player:get_player_name(), str)
|
||||
core.chat_send_player(player:get_player_name(), S("Path length: @1", #path))
|
||||
core.chat_send_player(player:get_player_name(), S("Time: @1 ms", time_diff/1000))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,7 +93,7 @@ local function set_destination(itemstack, user, pointed_thing)
|
|||
meta:set_int("pos_x", pos.x)
|
||||
meta:set_int("pos_y", pos.y)
|
||||
meta:set_int("pos_z", pos.z)
|
||||
minetest.chat_send_player(user:get_player_name(), S("Destination set to @1", minetest.pos_to_string(pos)))
|
||||
core.chat_send_player(user:get_player_name(), S("Destination set to @1", core.pos_to_string(pos)))
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
@ -112,7 +112,7 @@ local function find_path_or_set_algorithm(itemstack, user, pointed_thing)
|
|||
local algo = meta:get_int("algorithm")
|
||||
algo = (algo + 1) % #algorithms
|
||||
meta:set_int("algorithm", algo)
|
||||
minetest.chat_send_player(user:get_player_name(), S("Algorithm: @1", algorithms[algo+1]))
|
||||
core.chat_send_player(user:get_player_name(), S("Algorithm: @1", algorithms[algo+1]))
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
@ -120,7 +120,7 @@ end
|
|||
-- Punch: Find path
|
||||
-- Sneak+punch: Select pathfinding algorithm
|
||||
-- Place: Select destination node
|
||||
minetest.register_tool("testpathfinder:testpathfinder", {
|
||||
core.register_tool("testpathfinder:testpathfinder", {
|
||||
description = S("Pathfinder Tester") .."\n"..
|
||||
S("Finds path between 2 points") .."\n"..
|
||||
S("Place on node: Select destination") .."\n"..
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue