Adjusted marker colors when no space to blink. Added double tap to tp

This commit is contained in:
0siribix 2021-08-22 23:02:00 -05:00
parent 04132662ce
commit 6c3e9a1393
3 changed files with 21 additions and 3 deletions

View File

@ -1,9 +1,9 @@
--[[ To Do:
Add tool wear and repair
Use place marker button twice in the same place to blink there
Localize
Maybe switch to first weapon in hotbar when blinking behind players or mobs
Clean up and document code
Put messages in HUD instead of in chat
]]
@ -36,6 +36,9 @@ local display_time = core.settings:get("blink:display_time") or 6.0
-- Public areas username. Any areas owned by this user are considered public and will allow users to blink
local public_username = core.settings:get("blink:public_username") or ""
-- If placing a second marker in the same place as an existing one, tp there
local double_tap_tp = core.settings:get("blink:double_tap_tp") or true
blink.valid_entities = {
["mobs_animal"] = true,
@ -97,6 +100,7 @@ function blink_tp(user, marker)
local no_space_to_blink = false
local rc = Raycast(origin, dpos, true, false)
-- When I first wrote this code, I thought that all this calculation might cause server lag but it actually does very well
for pt in rc do
if blink_behind and pt.type == "object" then
if pt.ref ~= user then -- Raycast intersects with players head first
@ -137,7 +141,12 @@ function blink_tp(user, marker)
end
end
local oldpos
if blink.active_marker[username] then
if double_tap_tp and marker then
oldpos = blink.active_marker[username]:get_pos()
end
blink.active_marker[username]:remove()
blink.active_marker[username] = nil
end
@ -168,6 +177,12 @@ function blink_tp(user, marker)
end
end
if (not no_space_to_blink) and oldpos and math.floor(oldpos.x) == math.floor(dpos.x) and
math.floor(oldpos.y) == math.floor(dpos.y) and
math.floor(oldpos.z) == math.floor(dpos.z) then
marker = nil
end
if marker == nil then
if not no_space_to_blink then
dpos.y = dpos.y - 0.5

View File

@ -1,5 +1,5 @@
#Maximum distance to blink
blink_distance (Blink Distance) int 15
blink_distance (Blink Distance) int 20
#Allow Blink into protected areas
tp_into_prot (Blink into protected areas) bool false
@ -19,5 +19,8 @@ blink_behind (Blink Behind) bool true
#Time to show destination marker
display_time (Display Time) float 6.0
# Any areas owned by this user are considered public and will allow users to blink. Recommend to create a non-use user account for the purpose of allowing blink in protected areas (e.g. user called allow_blink). Note that anyone can add the user to their protected area to allow anyone to blink in their area.
#Any areas owned by this user are considered public and will allow users to blink. Recommend to create a non-use user account for the purpose of allowing blink in protected areas (e.g. user called allow_blink). Note that anyone can add the user to their protected area to allow anyone to blink in their area.
public_username (Public areas username) string ""
#Use Blink Rune at the same location while a marker is active to tp there.
double_tap_tp (Double Tap to Blink) bool true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

After

Width:  |  Height:  |  Size: 144 B