o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
Hi create a gg sample lua
- User
Hi create a gg sample lua
- Assistant
Hi create a gg sample lua
Certainly! Below is a simple Game Guardian (gg) Lua script example. This script demonstrates basic functionalities such as searching for a specific value in a game's memory, modifying it, and providing user feedback.
--[[
Game Guardian Sample Lua Script
Description: This script searches for a specific integer value in the game's memory,
modifies it to a new value, and provides user feedback.
--]]
-- Function to display messages to the user
function notify(message)
gg.toast(message) -- Short toast notification
gg.alert(message) -- Popup alert
end
-- Main function
function main()
-- Ensure that Game Guardian is initialized
if gg.isVisible(true) then
gg.setVisible(false) -- Hide the Game Guardian UI
end
-- Define the target value to search for and the new value to replace it with
local targetValue = 100 -- The value you want to find
local newValue = 999 -- The value you want to set
notify("Starting search for value: " .. tostring(targetValue))
-- Clear previous search results
gg.clearResults()
-- Perform the search
gg.searchNumber(targetValue, gg.TYPE_DWORD)
-- Get all the results
local results = gg.getResults(gg.getResultsCount())
if #results == 0 then
notify("Value not found!")
return
end
notify("Value found! Modifying...")
-- Modify each found address with the new value
for i, v in ipairs(results) do
results[i].value = newValue
end
-- Update the memory with new values
gg.setValues(results)
notify("Modification complete! New value set to: " .. tostring(newValue))
end
-- Run the main function
main()
Notifications:
notify function uses gg.toast to show a brief message and gg.alert for a popup alert. This helps inform the user about the script's progress.Main Function:
Visibility Handling:
Define Values:
targetValue: The integer value you want to search for in the game's memory.newValue: The integer value you want to set in place of the targetValue.Search Operation:
gg.clearResults().targetValue with gg.searchNumber. The gg.TYPE_DWORD specifies that the value type is a 32-bit integer. Adjust the type as needed (e.g., gg.TYPE_FLOAT for floating-point numbers).gg.getResults(gg.getResultsCount()).Modification:
newValue.gg.setValues(results).Install Game Guardian:
Prepare the Game:
Load the Script:
</>).SampleModifier.lua).Execute the Script:
Verify Changes:
Memory Types:
gg.TYPE_DWORD matches the data type of the value you're targeting. Incorrect types can lead to unexpected behavior or crashes.Legality and Fair Play:
Root Access:
Script Customization:
Feel free to modify and expand upon this script to suit your specific requirements. If you have any further questions or need assistance with more advanced scripting, feel free to ask!
Not yet included in a published release.