mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
Upload
This commit is contained in:
66
lua/includes/extensions/util/worldpicker.lua
Normal file
66
lua/includes/extensions/util/worldpicker.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
--
|
||||
--
|
||||
-- worldpicker is for picking an entity from the game while you have the GUI open.
|
||||
-- Calling util.worldpicker.Start( func ) will hide all GUI and let you pick an entity from
|
||||
-- the game world. Once selected it will call your passed function with the trace.
|
||||
--
|
||||
-- It's used in the icon editor
|
||||
--
|
||||
--
|
||||
|
||||
local bDoing = false
|
||||
local fnAction = nil
|
||||
|
||||
util.worldpicker = {
|
||||
--
|
||||
-- Start world picking
|
||||
--
|
||||
Start = function( func )
|
||||
|
||||
bDoing = true
|
||||
fnAction = func
|
||||
gui.EnableScreenClicker( true )
|
||||
|
||||
end,
|
||||
|
||||
--
|
||||
-- Finish world picking - you shouldn't have to call this (called from hook below)
|
||||
--
|
||||
Finish = function( tr )
|
||||
|
||||
bDoing = false
|
||||
fnAction( tr )
|
||||
gui.EnableScreenClicker( false )
|
||||
|
||||
end,
|
||||
|
||||
Active = function() return bDoing end
|
||||
}
|
||||
|
||||
hook.Add( "VGUIMousePressAllowed", "WorldPickerMouseDisable", function( code )
|
||||
|
||||
if ( !bDoing ) then return false end
|
||||
|
||||
local dir = gui.ScreenToVector( input.GetCursorPos() )
|
||||
local tr = util.TraceLine( {
|
||||
start = LocalPlayer():GetShootPos(),
|
||||
endpos = LocalPlayer():GetShootPos() + dir * 32768,
|
||||
filter = LocalPlayer()
|
||||
} )
|
||||
|
||||
util.worldpicker.Finish( tr )
|
||||
|
||||
-- Don't register this click
|
||||
return true
|
||||
|
||||
end )
|
||||
Reference in New Issue
Block a user