[Client] Interface Controller (LuaScript)

Category: LuaScript | Subcategory: Main Interface Controller


InterfaceController Functions in Lua

InterfaceController is a set of functions used to manage user interaction with the client interface. It detects inputs like key presses and mouse clicks while handling client-server communication through the protocol. Additionally, it dynamically updates interface elements, enabling smooth interaction between the client and the server via Lua scripts.

Main InterfaceController Functions:

InterfaceController.MainProc()

  • Purpose: Renders the main client interface.
  • Usage: This is the primary function for rendering the interface during each client cycle.

InterfaceController.BeforeMainProc()

  • Purpose: Renders the interface before the main interface (e.g., shortcuts like "C", "V", etc.).
  • Usage: Useful for processing or displaying elements before the default interface loads.

InterfaceController.ClientProtocol(Packet, PacketName)

  • Purpose: Receives packets from the server, managing client-server communication.
  • Usage: This function is used to handle communication between the client and the server, processing the data received through the protocol.

InterfaceController.MainProcWorldKey()

  • Purpose: Detects when a key is pressed on the keyboard.
  • Usage: Essential for managing keyboard inputs and executing related actions.

InterfaceController.ScrollMouse(value)

  • Purpose: Detects the mouse scroll value (if > 0, scroll up; if < 0, scroll down).
  • Usage: Manages the behavior of mouse scrolling within the interface.

InterfaceController.InterfaceClickRightEvent()

  • Purpose: Detects a right mouse click.
  • Usage: Ideal for handling context menus or custom actions triggered by a right-click.

InterfaceController.InterfaceClickEvent()

  • Purpose: Detects a left mouse click.
  • Usage: Used to select or activate elements within the interface.

InterfaceController.UpdateProc()

  • Purpose: Updates the interface and processes input events like mouse clicks and scrolling.
  • Usage: Continuously runs to keep the interface interactive and responsive.

InterfaceController.UpdateMouse()

  • Purpose: Specifically detects mouse-related events within the interface.
  • Usage: Used to track the mouse position and other interactions.

InterfaceController.UpdateKey()

  • Purpose: Specifically detects key presses on the keyboard.
  • Usage: Monitors and processes keyboard inputs.

InterfaceController.PlayerDraw()

  • Purpose: Renders player-related elements like a health bar.
  • Usage: Displays player-specific information, such as health or level, within the interface.

InterfaceController.FinalBoot()

  • Purpose: Loads images and other resources during the boot process.
  • Usage: Called at the start of the client to ensure resources are loaded.

InterfaceController.LoadImages()

  • Purpose: Called when images are loaded in the main client program.
  • Usage: Ensures graphic resources are ready for use within the interface.

Conclusion

These InterfaceController functions provide an integrated way to manage user interface interactions within the client. By handling keyboard events, mouse actions, and client-server communication via Lua scripts, they enable dynamic and responsive interfaces that allow smooth interaction between the client and the server.

 

EXAMPLE: I want to print "Hello World" on the screen: (Test.lua)

 

function InterfaceProc()
      SetFontType(1)
      SetTextBg(0, 0, 0, 200)
      SetTextColor(255, 255, 255, 255)
     RenderText2(250, 275, "Hello World", ALIGN_LEFT)
end

InterfaceController.MainProc(InterfaceProc)

Return