added example
This commit is contained in:
75
autoexec.lua
75
autoexec.lua
@@ -1,5 +1,9 @@
|
|||||||
simulated_resolution = v2(1920, 1080)
|
simulated_resolution = v2(1920, 1080)
|
||||||
|
|
||||||
|
function round(n)
|
||||||
|
return n + 0.5 - (n + 0.5) % 1
|
||||||
|
end
|
||||||
|
|
||||||
function coords_to_screenwriter(coord1, coord2)
|
function coords_to_screenwriter(coord1, coord2)
|
||||||
|
|
||||||
local x_left, x_right, y_top, y_bottom, width, height
|
local x_left, x_right, y_top, y_bottom, width, height
|
||||||
@@ -46,11 +50,23 @@ function coords_partial_to_screenwriter(pos_px, scale_px, anchor)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function action_value_input(f)
|
||||||
|
local resp, str = input.get(f.name, bgcolor, 64, 3)
|
||||||
|
while (resp ~= 0) do system.wait(0) end
|
||||||
|
|
||||||
|
f.value_i = tonumber(resp)
|
||||||
|
end
|
||||||
|
|
||||||
local bgcolor = '000000'
|
local bgcolor = '000000'
|
||||||
local bgopacity = '000000'
|
local bgopacity = '000000'
|
||||||
|
|
||||||
local menu_options = menu.add_feature('session info', 'parent')
|
local menu_options = menu.add_feature('session info', 'parent')
|
||||||
|
|
||||||
|
local menu_enable = menu.add_feature('enable', 'toggle', menu_options.id)
|
||||||
|
menu_enable.on = true
|
||||||
|
|
||||||
|
local menu_blank0 = menu.add_feature('', 'action', menu_options.id)
|
||||||
|
|
||||||
local options_textshadow = menu.add_feature('text shadow', 'toggle', menu_options.id)
|
local options_textshadow = menu.add_feature('text shadow', 'toggle', menu_options.id)
|
||||||
local options_disablebg = menu.add_feature('disable background', 'toggle', menu_options.id)
|
local options_disablebg = menu.add_feature('disable background', 'toggle', menu_options.id)
|
||||||
local options_bgcolor = menu.add_feature('background color', 'action', menu_options.id, function(f)
|
local options_bgcolor = menu.add_feature('background color', 'action', menu_options.id, function(f)
|
||||||
@@ -74,32 +90,57 @@ local options_bgcolor = menu.add_feature('background color', 'action', menu_opti
|
|||||||
end
|
end
|
||||||
|
|
||||||
end)
|
end)
|
||||||
local options_opacity = menu.add_feature('background opacity', 'action_value_i', menu_options.id)
|
local options_opacity = menu.add_feature('background opacity', 'action_value_i', menu_options.id, action_value_input)
|
||||||
options_opacity.min_i = 0
|
options_opacity.min_i = 0
|
||||||
options_opacity.max_i = 100
|
options_opacity.max_i = 100
|
||||||
options_opacity.value_i = 100
|
options_opacity.value_i = 100
|
||||||
|
|
||||||
menu.create_thread(function()
|
local options_pos = menu.add_feature('position', 'parent', menu_options.id)
|
||||||
|
local options_pos_x = menu.add_feature('x', 'action_value_i', options_pos.id, action_value_input)
|
||||||
|
options_pos_x.min_i = 0
|
||||||
|
options_pos_x.max_i = simulated_resolution.x
|
||||||
|
options_pos_x.value_i = 320
|
||||||
|
local options_pos_y = menu.add_feature('y', 'action_value_i', options_pos.id, action_value_input)
|
||||||
|
options_pos_y.min_i = 0
|
||||||
|
options_pos_y.max_i = simulated_resolution.y
|
||||||
|
options_pos_y.value_i = 20
|
||||||
|
local options_pos_width = menu.add_feature('width', 'action_value_i', options_pos.id, action_value_input)
|
||||||
|
options_pos_width.min_i = 0
|
||||||
|
options_pos_width.max_i = simulated_resolution.x
|
||||||
|
options_pos_width.value_i = 200
|
||||||
|
local options_pos_height = menu.add_feature('height', 'action_value_i', options_pos.id, action_value_input)
|
||||||
|
options_pos_height.min_i = 0
|
||||||
|
options_pos_height.max_i = simulated_resolution.y
|
||||||
|
options_pos_height.value_i = 200
|
||||||
|
|
||||||
|
local options_disp = menu.add_feature('display', 'parent', menu_options.id)
|
||||||
|
local options_disp_host = menu.add_feature('host', 'toggle', options_pos.id, action_value_input)
|
||||||
|
options_disp_host.on = true
|
||||||
|
|
||||||
|
menu.create_thread(function(f)
|
||||||
while true do
|
while true do
|
||||||
|
|
||||||
local base = v2(320, 20)
|
if menu_enable.on then
|
||||||
|
local base = v2(options_pos_x.value_i, options_pos_y.value_i)
|
||||||
|
|
||||||
if (not(options_disablebg.on)) then
|
if (not(options_disablebg.on)) then
|
||||||
local pos, scale = coords_partial_to_screenwriter(base, v2(200, 200), 4)
|
local pos, scale = coords_partial_to_screenwriter(base, v2(options_pos_width.value_i, options_pos_height.value_i), 4)
|
||||||
local opacity = string.format('%x', math.floor(options_opacity.value_i * 2.55))
|
local opacity = string.format('%x', round(options_opacity.value_i * 2.55))
|
||||||
while opacity:len() < 2 do
|
while opacity:len() < 2 do
|
||||||
opacity = '0'..opacity
|
opacity = '0'..opacity
|
||||||
|
end
|
||||||
|
scriptdraw.draw_rect(pos, scale, tonumber('0x'..opacity..bgcolor))
|
||||||
|
end
|
||||||
|
|
||||||
|
local textFlags = 0
|
||||||
|
if options_textshadow.on then
|
||||||
|
textFlags = 2
|
||||||
end
|
end
|
||||||
print('0x'..opacity..bgcolor)
|
|
||||||
scriptdraw.draw_rect(pos, scale, tonumber('0x'..opacity..bgcolor))
|
|
||||||
end
|
|
||||||
|
|
||||||
local textFlags = 0
|
|
||||||
if options_textshadow.on then
|
|
||||||
textFlags = 2
|
|
||||||
end
|
|
||||||
|
|
||||||
--scriptdraw.draw_text(scale, v2(0, 0), v2(1, 1), 1, 0XFFFFFFFF, textFlags)
|
local
|
||||||
|
|
||||||
|
--scriptdraw.draw_text(scale, v2(0, 0), v2(1, 1), 1, 0XFFFFFFFF, textFlags)
|
||||||
|
end
|
||||||
system.wait(0)
|
system.wait(0)
|
||||||
end
|
end
|
||||||
end, nil)
|
end, nil)
|
||||||
6
examples/rgba.lua
Normal file
6
examples/rgba.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- 0-255, 0-255, 0-255, 0-100
|
||||||
|
function rgba(R, G, B, A)
|
||||||
|
A = A or 100
|
||||||
|
A = A + 0.5 - (A + 0.5) % 1
|
||||||
|
return ((R&0x0ff)<<0x00)|((G&0x0ff)<<0x08)|((B&0x0ff)<<0x10)|((A&0x0ff)<<0x18)
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user