Skip to content

Instantly share code, notes, and snippets.

@supersaiyansubtlety
Created March 23, 2019 01:39
Show Gist options
  • Save supersaiyansubtlety/c1ad6352bf2df35d6f5c90b823d14749 to your computer and use it in GitHub Desktop.
Save supersaiyansubtlety/c1ad6352bf2df35d6f5c90b823d14749 to your computer and use it in GitHub Desktop.
Cheat Engine Radio Buttons
function RadioSelect(parent)
-----This function makes it so that for its calling script, only one of its child scripts
-----can be active at a time.
-----It does this by making it so that, for each child,
-----when that child is activated, that child deactivates all other children.
--if this script has children
if parent.Count then
--for every child
for i = 0,parent.Count-1 do
--set OnActivate for this child
parent.Child[i].OnActivate = function(this, before, currentstate)
--if before activated
if currentstate == false then
if parent.prevChild then
parent.prevChild.Active = false
end
parent.prevChild = this
end --if currentstate == false then
--allow activation
return true
end --end OnActivate
--set OnDeactivate for this child
parent.Child[i].OnDeactivate = function(this, before, currentstate)
--if before deactivated
if currentstate == false then
parent.prevChild = nil
end --if currentstate == false then
--allow deactivation
return true
end --end OnDeactivate
end --for i = 0,parent.Count-1 do
end --if parent.Count then
end --function RadioSelect(parent)
RadioSelect(memrec)
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="28">
<CheatEntries>
<CheatEntry>
<ID>1337085153</ID>
<Description>"RadioSelect"</Description>
<Options moHideChildren="1"/>
<LastState/>
<Color>808000</Color>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then return end
function RadioSelect(parent)
-----This function makes it so that for its calling script, only one of its child scripts
-----can be active at a time.
-----It does this by making it so that, for each child,
-----when that child is activated, that child deactivates all other children.
--if this script has children
if parent.Count then
--for every child
for i = 0,parent.Count-1 do
--set OnActivate for this child
parent.Child[i].OnActivate = function(this, before, currentstate)
--if before activated
if currentstate == false then
if parent.prevChild then
parent.prevChild.Active = false
end
parent.prevChild = this
end --if currentstate == false then
--allow activation
return true
end --end OnActivate
--set OnDeactivate for this child
parent.Child[i].OnDeactivate = function(this, before, currentstate)
--if before deactivated
if currentstate == false then
parent.prevChild = nil
end --if currentstate == false then
--allow deactivation
return true
end --end OnDeactivate
end --for i = 0,parent.Count-1 do
end --if parent.Count then
end --function RadioSelect(parent)
RadioSelect(memrec)
{$asm}
[DISABLE]
{$lua}
if syntaxcheck then return end
</AssemblerScript>
<CheatEntries>
<CheatEntry>
<ID>1337085154</ID>
<Description>"Child 1"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$lua}
if not syntaxcheck then
end
{$asm}
[DISABLE]
{$lua}
if not syntaxcheck then
end
</AssemblerScript>
</CheatEntry>
<CheatEntry>
<ID>1337085155</ID>
<Description>"Child 2"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$lua}
if not syntaxcheck then
end
{$asm}
[DISABLE]
{$lua}
if not syntaxcheck then
end
</AssemblerScript>
</CheatEntry>
<CheatEntry>
<ID>1337085156</ID>
<Description>"Child 3"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$lua}
if not syntaxcheck then
end
{$asm}
[DISABLE]
{$lua}
if not syntaxcheck then
end
</AssemblerScript>
</CheatEntry>
<CheatEntry>
<ID>1337085157</ID>
<Description>"Child 4"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>[ENABLE]
{$lua}
if not syntaxcheck then
end
{$asm}
[DISABLE]
{$lua}
if not syntaxcheck then
end
</AssemblerScript>
</CheatEntry>
</CheatEntries>
</CheatEntry>
</CheatEntries>
<UserdefinedSymbols/>
</CheatTable>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment