Skip to content

imgui

These functions allow you to manage ImGUI. See Globals for all the related global variables.

Example: weapon_font_test.lua

moonlight.imgui.image

Parameters

  • number address
  • number width
  • number height

Remarks

  • You must use moonlight.visuals.load_image to get the image address.
  • See weapon_font_test.lua for an example.

moonlight.imgui.get_screen_size

Returns

  • number
  • number

moonlight.imgui.add_font

Parameters

  • string font_name_without_extension
  • number size

Returns

  • number

Remarks

  • The font must be in the resources folder.
  • The font returns an ID not an address. Just keep that in mind.
  • You can only add fonts in OnEndScene. Look at weapon_font_test.lua to see how to avoid memory leaks.
  • See weapon_font_test.lua for an example.

moonlight.imgui.draw_image

Parameters

  • number image_address
  • number x
  • number y
  • number width
  • number height

Remarks

  • You must use moonlight.visuals.load_image to get the image address.
  • This function allows you to draw an image outside of an ImGui window.
  • See healslut.lua for an example.

moonlight.imgui.menu_bar

Returns

  • boolean

Remarks

  • C++ equivalent: ImGui::BeginMenuBar
  • This function may at times return false. If it does, your menu will look strange if you continue to proceed.
  • Everything within moonlight.imgui.menu_bar should be in an if statement.
  • This function will only work if moonlight.imgui.window has the ImGuiWindowFlags_MenuBar flags attached.
  • This function can only be used after moonlight.imgui.window and before moonlight.imgui.end_window
  • See menu.lua for an example.

moonlight.imgui.menu

Parameters

  • string name

Returns

  • boolean

Remarks

  • C++ equivalent: ImGui::BeginMenu
  • This function may at times return false. If it does, your menu will look strange if you continue to proceed.
  • Everything within moonlight.imgui.menu should be in an if statement.
  • This function will only work if moonlight.imgui.window has the ImGuiWindowFlags_MenuBar flags attached.
  • This function can only be used after moonlight.imgui.window and before moonlight.imgui.end_window
  • See menu.lua for an example.

moonlight.imgui.menu_item

Parameters

  • string name
  • string description

Returns

  • boolean

Remarks

  • C++ equivalent: ImGui::MenuItem
  • The description parameter can be left blank. However it is not an optional parameter.
  • This function returns true if somebody selected the menu item.
  • This function will not work unless it is inside of moonlight.imgui.menu_bar and moonlight.imgui.menu.

moonlight.imgui.end_menu

Remarks

  • C++ equivalent: ImGui::EndMenu
  • Closes the moonlight.imgui.menu instance.
  • See menu.lua for an example.

moonlight.imgui.end_menu_bar

Remarks

  • C++ equivalent: ImGui::EndMenuBar
  • Closes the moonlight.imgui.menu_bar instance.
  • See menu.lua for an example.

moonlight.imgui.add

Parameters

  • string name
  • string FantasyVar_Name
  • string style
  • optional number/string minimum/r
  • optional number/string maximum/g
  • optional string b
  • optional string a

Remarks

  • This function will add a menu item to the database. This is so any menu framework can dynamically access menu options added by any script through moonlight.imgui.get_vars
  • The style parameter accepts any style. But under general conventions by the default menu.lua script, the following style will automatically be added to the menu framework: checkbox, key, color, button, slider, slider_float.
  • The r, g, b, a parameters (if applicable) are looking for FantasyVars.
  • See humanizer.lua and esp.lua for examples.
  • If your style is slider_float, you can add a | delimiter to format the slider for precision. Example: slider_float|%0.4f.

moonlight.imgui.get_vars

Returns

  • table[table]

string name string FantasyVar string style number min number max number r number g number b number a boolean enabled

Remarks

  • This returns a multidimensional array of all menu options added from moonlight.imgui.add.
  • See menu.lua for an example.

moonlight.imgui.style_editor

Remarks

  • C++ equivalent: ImGui::ShowStyleEditor
  • Below is an example of this being used with a SDK test menu:


moonlight.imgui.window

Parameters

  • number title
  • number x
  • number y

Remarks

  • C++ equivalent: ImGui::Begin, ImGui::SetNextWindowPos and ImGui::SetNextWindowSize

moonlight.imgui.set_next_position

Parameters

  • number x
  • number y

Remarks

  • C++ equivalent: ImGui::SetNextWindowPos

moonlight.imgui.set_next_size

Parameters

  • number width
  • number height

Remarks

  • C++ equivalent: ImGui::SetNextWindowSize

moonlight.imgui.help

Parameters

  • string text

Remarks

  • This creates a (?) which displays a text when hovered.

moonlight.imgui.end_window

Remarks

  • C++ equivalent: ImGui::End
  • Ends a window instance.

moonlight.imgui.key

Parameters

  • string title
  • string FantasyVar

Remarks

  • C++ equivalent: ImGui::Combo but with a list of keys already inserted to the combo.

moonlight.imgui.set

Parameters

  • number x
  • number y

Remarks

  • C++ equivalent: ImGui::SetCursorPos

moonlight.imgui.get

Returns

  • number
  • `number

Remarks

  • C++ equivalent: ImGui::GetCursorPos

Parameters

  • number width
  • number height

Returns

  • `boolean

Remarks

  • This creates a fantasy.cat logo that will return true if clicked on.
  • This is used in manager.lua.

moonlight.imgui.text

Parameters

  • string text
  • number r
  • number g
  • number b
  • number a

Remarks

  • C++ equivalent: ImGui::TextColored

moonlight.imgui.button

Parameters

  • string text
  • number width
  • number height

Returns

  • boolean

Remarks

  • C++ equivalent: ImGui::Button
  • This function returns true if the button is pressed (Sometimes dysfunctional).
  • You can use OnButtonPressed callback to see if a button is pressed in the case the function isn't returning true.

moonlight.imgui.same_line

Parameters

  • number offset_from_start
  • number spacing

Remarks

  • C++ equivalent: ImGui::SameLine

moonlight.imgui.listbox

Parameters

  • string title
  • string FantasyVar
  • string items
  • number height

Remarks

  • The items must be separated with a |. For example: Hello|Welcome|To|Hell
  • The height parameter will allow the listbox to be longer. Set to -1 if you don't care.

moonlight.imgui.combo

Parameters

  • string title
  • string FantasyVar
  • string items

Remarks

  • The items must be separated with a |. For example: Hello|Welcome|To|Hell

moonlight.imgui.textarea

Parameters

  • string title
  • number x
  • number y
  • number flags

Remarks

  • C++ equivalent: ImGui::InputTextMultiline

moonlight.imgui.push_font

Parameters

  • number id

Remarks

  • C++ equivalent: ImGui::PushFont
  • This function requires the font id from moonlight.imgui.add_font.

moonlight.imgui.pop_font

Remarks

  • C++ equivalent: ImGui::PopFont

moonlight.imgui.push_width

Parameters

  • number width

Remarks

  • C++ equivalent: ImGui::PushItemWidth

moonlight.imgui.pop_width

Remarks

  • C++ equivalent: ImGui::PopItemWidth

moonlight.imgui.inputtext

Parameters

  • string title
  • string FantasyVar
  • number flags

Returns

boolean

Remarks

  • C++ equivalent: ImGui::InputText
  • This function returns true if the user has submitted the inputtext.

moonlight.imgui.checkbox

Parameters

  • string title
  • string FantasyVar

Remarks

  • C++ equivalent: ImGui::Checkbox
  • This automatically changes the value of the FantasyVar to 0/1.

moonlight.imgui.slider

Parameters

  • string title
  • string FantasyVar
  • number min
  • number max

Remarks

  • C++ equivalent: ImGui::SliderInt
  • This automatically changes the value of the FantasyVar.

moonlight.imgui.sliderf

Parameters

  • string title
  • string FantasyVar
  • number min
  • number max
  • string format

Remarks

  • C++ equivalent: ImGui::SliderFloat
  • This automatically changes the value of the FantasyVar.
  • Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.

moonlight.imgui.color

Parameters

  • string title
  • number r
  • number g
  • number b
  • number a

Remarks

  • C++ equivalent: ImGui::ColorEdit4
  • This automatically changes the value of the FantasyVar.

moonlight.imgui.separator

Remarks

  • C++ equivalent: ImGui::Separator

moonlight.imgui.tabbar

Parameters

  • string title

Remarks

  • C++ equivalent: ImGui::BeginTabBar

moonlight.imgui.tabitem

Parameters

  • string title

Remarks

  • C++ equivalent: ImGui::BeginTabItem
  • This function must only be used after moonlight.imgui.tabbar

moonlight.imgui.end_tabbar

Remarks

  • C++ equivalent: ImGui::EndTabBar

moonlight.imgui.end_tabitem

Remarks

  • C++ equivalent: ImGui::EndTabItem

moonlight.imgui.style

Parameters

  • string variable
  • number color
  • ...

Remarks

  • This function changes the style of ImGUI.
  • The ... parameters accepts arguments based on the variable parameter.
  • See Globals for a list of ImGUI globals.
  • See theme.lua for an example.

moonlight.imgui.is_hovered

Returns

  • boolean

Remarks

  • C++ equivalent: ImGui::IsItemHovered
  • This function checks if an ImGUI element is hovered over.
  • This function isn't always responsive.

moonlight.imgui.editor

Parameters

  • string name
  • string content

Remarks

  • This will create an ingame script editor.
  • moonlight.imgui.textarea is a better alternative.

moonlight.imgui.set_visible

Parameters

  • boolean toggle

Remarks

  • This enables/disables a menu option.