Lua Documentation
  • Practical Information
  • Lua Documentation
    • API Reference
      • Classes
        • vec2
        • vec3
      • g_lua
        • register
        • unregister
        • load_lua
      • g_memory
        • get_base_address
        • scan_pattern
        • rip
        • allocate
        • free
        • write_byte
        • write_short
        • write_int
        • write_long_long
        • write_float
        • write_double
        • write_string
        • read_byte
        • read_short
        • read_int
        • read_long_long
        • read_float
        • read_double
        • read_string
      • g_logger
        • log_info
      • g_gui
        • is_open
        • open
        • close
        • toggle
        • add_toast
        • add_button
        • add_toggle
        • add_input_int
        • add_input_float
        • add_input_string
      • g_hooking
        • register_D3D_hook
        • register_wndproc_hook
        • register_scripted_game_event_hook
        • unregister_hook
      • g_math
        • sin
        • cos
        • tan
      • g_util
        • yield
        • is_session_started
        • get_selected_player
        • trigger_script_event
        • get_menu_version
        • joaat
        • play_wav_file
      • g_imgui
        • Globals
        • get_display_size
        • set_next_window_size
        • set_next_window_pos
        • get_window_size
        • get_window_pos
        • push_style_var
        • pop_style_var
        • begin_window
        • end_window
        • begin_child
        • end_child
        • same_line
        • new_line
        • separator
        • columns
        • next_column
        • set_column_offset
        • is_item_hovered
        • add_line
        • add_circle
        • add_circle_filled
        • add_rect
        • add_rect_filled
        • set_next_item_width
        • get_content_region_avail
        • add_button
        • add_checkbox
        • add_input_string
        • add_input_string_with_hint
        • add_text
        • add_triangle
        • add_triangle_filled
        • begin_main_menu_bar
        • end_main_menu_bar
        • begin_menu
        • end_menu
        • menu_item
        • begin_tab_bar
        • end_tab_bar
        • begin_tab_item
        • end_tab_item
        • open_popup
        • close_current_popup
        • is_popup_open
        • begin_popup
        • end_popup
      • g_os
        • time
        • time_ms
        • finger_print
      • NATIVES
        • POOL
        • PLAYER
        • SYSTEM
        • CAM
        • DECORATOR
        • WORLDPROBE
        • STATS
        • CLOCK
        • FIRE
        • STREAMING
        • CUTSCENE
        • WATER
        • AUDIO
        • INTERIOR
        • TASK
        • CONTROL
        • NETWORK
        • OBJECT
        • ENTITY
        • VEHICLE
        • WEAPON
        • SCRIPT
        • PED
        • MISC
        • GAMEPLAY
        • UI
        • GRAPHICS
        • MOBILE
Powered by GitBook
On this page
  1. Lua Documentation
  2. API Reference

g_imgui

All of these functions can only be executed within a D3D hook. https://github.com/ocornut/imgui

function myButtonCallback()
	g_logger.log_info("Callback called")
end

function myToggleCallback(value)
	myBool = value
end

function myD3DHook()
	if g_gui.is_open() then
		g_imgui.set_next_window_size(vec2(400, 600))
		if  g_imgui.begin_window("Test Window", ImGuiWindowFlags_NoResize) then
			g_imgui.begin_child("Test Child", vec2(), true)
			g_imgui.add_button("Test Button", vec2(), myButtonCallback)
			g_imgui.add_checkbox("Test Checkbox", myToggleCallback)
			
			if g_imgui.add_button("Test Button 2", vec2(), function() g_logger.log_info("Callback in scripting thread") end) then
                		g_logger.log_info("Pressed")
            		end 	
			
			g_imgui.end_child()
			g_imgui.end_window()	
		end
	end

	if myBool then
		g_imgui.add_circle_filled(g_imgui.get_display_size() / 2, 50.0, 105, 205, 255)
		g_imgui.add_line(vec2(), g_imgui.get_display_size(), 45, 155, 255)
	end
end

g_lua.register();

id = g_hooking.register_D3D_hook(myD3DHook);

while g_isRunning do
	g_util.yield(100)
end

g_hooking.unregister_hook(id);
g_lua.unregister();
Previousplay_wav_fileNextGlobals

Last updated 3 years ago