commit c8d27e27631794ecd7c1722f81f1b5f98fd63059 Author: zomo Date: Mon Jun 21 21:31:18 2021 -0500 init diff --git a/autoexec.lua b/autoexec.lua new file mode 100644 index 0000000..e6e5f43 --- /dev/null +++ b/autoexec.lua @@ -0,0 +1,96 @@ +simulated_resolution = v2(1920, 1080) + +function coords_to_screenwriter(coord1, coord2) + + x_left = math.min(coord1.x, coord2.x) + x_right = math.max(coord1.x, coord2.x) + y_top = math.min(coord1.y, coord2.y) + y_bottom = math.max(coord1.y, coord2.y) + + width_px = x_right - x_left + height_px = y_bottom - y_top + + x_px = x_left + width_px / 2 + y_px = y_top + height_px / 2 + + x = (x_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 + y = (y_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 + width = (width_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 + height = (height_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 + + return v2(x, y), v2(width, height) + +end + +--menu.add_feature("player coords", "toggle", 0, function(f) +menu.create_thread(function() + local scale = -2 + --while f.on do + while true do + local pos, scale = coords_to_screenwriter(v2(1920, 0), v2(1728, 108)) + scriptdraw.draw_rect(pos, scale, 0xFF000000) + --scriptdraw.draw_text(scale, v2(0, 0), v2(1, 1), 1, 0XFFFFFFFF, 0) + system.wait(0) + end +--end) +end, nil) + +--[[ + +# v2 to coords +local x, y, width, height, x_px, y_px, width_px, height_px, x_left, x_right, y_top, y_bottom + +x = .5 +y = 0 +width = 1 +height = 1 + +x_px = x * simulated_resolution.x / 2 + simulated_resolution.x / 2 +y_px = y * simulated_resolution.y / 2 + simulated_resolution.y / 2 +width_px = width * simulated_resolution.x / 4 + simulated_resolution.x / 4 +height_px = height * simulated_resolution.y / 4 + simulated_resolution.y / 4 + +x_left = x_px - width_px / 2 +x_right = x_px + width_px / 2 +y_top = y_px - height_px / 2 +y_bottom = y_px + height_px / 2 + +print(x_left) -- 960 +print(x_right) -- 1920 +print(y_top) -- 270 +print(y_bottom) -- 810 + +# coords to v2 + +local coord1, coord2, x_left, x_right, y_top, y_bottom, width_px, height_px, x_px, y_px, x, y, width, height + +#x_left = 960 +#x_right = 1920 +#y_top = 270 +#y_bottom = 810 + +coord1 = v2(1920, 270) +coord2 = v2(960, 810) + +x_left = math.min(coord1.x, coord2.x) +x_right = math.max(coord1.x, coord2.x) +y_top = math.min(coord1.y, coord2.y) +y_bottom = math.max(coord1.y, coord2.y) + +width_px = x_right - x_left +height_px = y_bottom - y_top + +x_px = x_left + width_px / 2 +y_px = y_top + height_px / 2 + +x = (x_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 +y = (y_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 +width = (width_px - simulated_resolution.x / 4) / simulated_resolution.x * 4 +height = (height_px - simulated_resolution.y / 4 ) / simulated_resolution.y * 4 + +print(x) +print(y) +print(width) +print(height) + +]] \ No newline at end of file diff --git a/examples/coords + screenwriter.lua b/examples/coords + screenwriter.lua new file mode 100644 index 0000000..aa478de --- /dev/null +++ b/examples/coords + screenwriter.lua @@ -0,0 +1,115 @@ +simulated_resolution = v2(1920, 1080) + +function screenwriter_to_coords(pos, scale) + + x = pos.x + y = pos.y + width = scale.x + height = scale.y + + x_px = x * simulated_resolution.x / 2 + simulated_resolution.x / 2 + y_px = y * simulated_resolution.y / 2 + simulated_resolution.y / 2 + width_px = width * simulated_resolution.x / 2 + simulated_resolution.x / 2 + height_px = height * simulated_resolution.y / 2 + simulated_resolution.y / 2 + + x_left = x_px - width_px / 2 + x_right = x_px + width_px / 2 + y_top = y_px - height_px / 2 + y_bottom = y_px + height_px / 2 + + return v2(x_left, y_top), v2(x_right, y_bottom) + +end + +function coords_to_screenwriter(coord1, coord2) + + x_left = math.min(coord1.x, coord2.x) + x_right = math.max(coord1.x, coord2.x) + y_top = math.min(coord1.y, coord2.y) + y_bottom = math.max(coord1.y, coord2.y) + + width_px = x_right - x_left + height_px = y_bottom - y_top + + x_px = x_left + width_px / 2 + y_px = y_top + height_px / 2 + + x = (x_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 + y = (y_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 + width = (width_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 + height = (height_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 + + return v2(x, y), v2(width, height) + +end + +--[[ + +simulated_resolution = v2(1920, 1080) + +# screenwriter to coords + +local pos, scale, x, y, width, height, x_px, y_px, width_px, height_px, x_left, x_right, y_top, y_bottom + +#x = .5 +#y = 0 +#width = 1 +#height = 1 + +pos = v2(.5, 0) +scale = v2(1, 1) + +x = pos.x +y = pos.y +width = scale.x +height = scale.y + +x_px = x * simulated_resolution.x / 2 + simulated_resolution.x / 2 +y_px = y * simulated_resolution.y / 2 + simulated_resolution.y / 2 +width_px = width * simulated_resolution.x / 2 + simulated_resolution.x / 2 +height_px = height * simulated_resolution.y / 2 + simulated_resolution.y / 2 + +x_left = x_px - width_px / 2 +x_right = x_px + width_px / 2 +y_top = y_px - height_px / 2 +y_bottom = y_px + height_px / 2 + +print(x_left) -- 960 +print(x_right) -- 1920 +print(y_top) -- 270 +print(y_bottom) -- 810 + +# coords to screenwriter + +local coord1, coord2, x_left, x_right, y_top, y_bottom, width_px, height_px, x_px, y_px, x, y, width, height + +#x_left = 960 +#x_right = 1920 +#y_top = 270 +#y_bottom = 810 + +coord1 = v2(1920, 270) +coord2 = v2(960, 810) + +x_left = math.min(coord1.x, coord2.x) +x_right = math.max(coord1.x, coord2.x) +y_top = math.min(coord1.y, coord2.y) +y_bottom = math.max(coord1.y, coord2.y) + +width_px = x_right - x_left +height_px = y_bottom - y_top + +x_px = x_left + width_px / 2 +y_px = y_top + height_px / 2 + +x = (x_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 +y = (y_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 +width = (width_px - simulated_resolution.x / 2) / simulated_resolution.x * 2 +height = (height_px - simulated_resolution.y / 2) / simulated_resolution.y * 2 + +print(x) +print(y) +print(width) +print(height) + +]] \ No newline at end of file diff --git a/examples/d3d_draw.lua b/examples/d3d_draw.lua new file mode 100644 index 0000000..a9ebcd8 --- /dev/null +++ b/examples/d3d_draw.lua @@ -0,0 +1,27 @@ +local function d3d_draw(feat) + + local pos = v2() + local size = v2() + + size.x = .2 + size.y = .2 + + -- void draw_rect(v2 pos, v2 size, uint32_t color) + d3d.draw_rect(pos, size, 0xFFFF0000) + size.x = 0 + size.y = 0 + -- void draw_text(const char* pszText, v2 pos, v2 size, float scale, uint32_t color, uint32_t flags) + -- TEXTFLAG_NONE = 0, + -- TEXTFLAG_CENTER = 1 << 0, + -- TEXTFLAG_SHADOW = 1 << 1, + -- TEXTFLAG_VCENTER = 1 << 2, + -- TEXTFLAG_BOTTOM = 1 << 3, + -- TEXTFLAG_JUSTIFY_RIGHT = 1 << 4, + d3d.draw_text("test123", pos, size, 1.0, 0xFF0000FF, 5) + + if feat.on then + return HANDLER_CONTINUE + end +end + +menu.add_feature("d3d renderer", "toggle").renderer = d3d_draw \ No newline at end of file diff --git a/examples/rgbtoint.lua b/examples/rgbtoint.lua new file mode 100644 index 0000000..ab13117 --- /dev/null +++ b/examples/rgbtoint.lua @@ -0,0 +1,4 @@ +local function RGBAToInt(R, G, B, A) + A = A or 255 + return ((tonumber(R)&0x0ff)<<0x00)|((tonumber(G)&0x0ff)<<0x08)|((tonumber(B)&0x0ff)<<0x10)|((tonumber(A)&0x0ff)<<0x18) +end \ No newline at end of file