Lua · Examples · Grenades
Grenade path
Draws the predicted path and landing ring of the grenade in your hand.
Uses: nade.held, draw.line3d, draw.circle3d
grenade_path.lua
-- name: Nade Path
-- author: Adolfjon
-- version: 1.0
-- description: Path and landing spot of the held grenade.
ui.color("path", "Path colour", color(255, 255, 255, 200))
ui.color("land", "Landing colour", color(255, 200, 80, 255))
local radius = { smoke = 144, molotov = 120, he = 100, flash = 40, decoy = 20 }
function on_frame()
local h = nade.held()
if not h then return end
local col = ui.get("path")
for i = 2, #h.path do
draw.line3d(h.path[i - 1], h.path[i], col, 2)
end
draw.circle3d(h.landing, radius[h.type] or 40, ui.get("land"), 2)
local sx, sy, ok = draw.world_to_screen(h.landing.x, h.landing.y, h.landing.z + 12)
if ok then
local t = h.type .. string.format(" %.1fs", h.seconds)
local tw = draw.text_size(t, 13)
draw.text_outline(sx - tw / 2, sy - 16, t, ui.get("land"), 13)
end
endInstall it
- Press Copy on the code above.
- In the menu, open Lua and press From Clipboard. The file is named from its
-- name:line. - Turn the script on in the list. Its settings show on its own tab.
Change anything you like and press Save (Ctrl+S) in the editor; the script reloads at once. See Getting started for the other ways to add scripts.