Posted: Sat Nov 19, 2022 10:02 am Post subject: Trying to 'check' certain checkboxes using script alone
I want to run a lua script after loading my table that finds certain checkboxes by name, sees if they are checked or not, and checks them if they are not already checked.
Additionally, after checking the appropriate boxes, I'd like to write certain values to the corresponding field for these checkboxes.
Is there a method to search for a checkbox by name? I see there is .State to get the state of the checkbox but how do I actually find the checkbox itself (by name) in order to change its state?
Edit: the only reason i need to find the checkbox first and not just the value itself is because the checkbox is actually a script that runs and then provides the values that need changing.
This is something along the lines of what I'd like to do (I know it's wrong):
Code:
local s = getSettings()
local box = s.getCheckboxByDescription('Player')
if box.State == 0 then
box.State = 1
end
What do you mean by checkbox? Are you talking about memory records (address list, bottom half of main window), or Is it an instance of the CheckBox class (e.g. something you created via `createCheckBox` or the custom form designer)?
Assuming you're talking about memory records, look at the Addresslist and MemoryRecord classes in celua.txt. Particularly the `getMemoryRecordByDescription` method and `Active` property of the respective class.
Code:
local memrec = assert(AddressList.getMemoryRecordByDescription'Player', 'Memrec "Player" does not exist')
if not memrec.Active then
memrec.Active = true
end
_________________
I don't know where I'm going, but I'll figure it out when I get there.
It's in the bottom half of the main window, as if you would open a cheat table and there would be boxes on the left to check which would enable/disable a certain part of the table. It's a literal checkbox you can see in the lower half of the main ui, with a name and script next to it.
I guess what I'm trying to ask is, in the same way that you would do
local x = AddressList.getMemoryRecordByDescription('some string').Value
to "find" a value in your table based on the name of it
and then be able to do operations with/on that 'x' variable
is there a way to do that with checkboxes, so that i can find the checkbox on my table with a certain name, check it/enable it using lua, and then by extension have it run the script that normally runs by the user manually 'checking' / enabling that box?
The only methods I see listed for checkbox are getState, setState, and onChange, but how do i actually FIND the box and assign it to a variable so that I can use the methods on it? (check or uncheck the box)
And I did not use createCheckbox, this is someone else's table I'm trying to save a certain 'preset' for
*EDIT: I think I get what you're saying now, anything in that bottom half window in the main UI is part of the address list and can be assigned to a variable with getMemoryRecordByDescription, and Active would be to toggle it on.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum