Page 1 of 1

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 4:40 am
by Mopzilla
I have managed to create a header/group using the assembly so I can script it.



I want this group to enable all children and set their values to 1 when it is selected.



I can do this easier by just enabling the options for the group where if it is selected then so are the children, and the children have the same value as the group.



The part I am stuck on is changing the value of the group the script is on, when it is enabled.



[ENABLE]

change value to 1



[DISABLE]

change value to 0

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 5:21 am
by happyTugs
One way using lua.[CODE=cea]{$LUA}

if syntaxcheck then return end

[ENABLE]

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 1



[DISABLE]

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 0

[/CODE]The script itself will be used as the header.

I am also assuming that the 'Setting a value to this entry sets same value to children' has been ticked.

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 5:27 am
by TimFun13
Make the header a script and use something like this:

[CODE=cea]{$lua}

if syntaxcheck then return end

for i = 0, memrec.Count - 1 do

if memrec.Active then

memrec[i].Value = '0'

else

memrec[i].Value = '1'

end

end

------------------------------ ENABLE ------------------------------

[ENABLE]

------------------------------ DISABLE ------------------------------

[DISABLE]

[/CODE]

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 12:43 pm
by Mopzilla
[QUOTE="happyTugs, post: 136902, member: 39952"]

One way using lua.[CODE=cea]{$LUA}

if syntaxcheck then return end

[ENABLE]

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 1



[DISABLE]

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 0

[/CODE]The script itself will be used as the header.

I am also assuming that the 'Setting a value to this entry sets same value to children' has been ticked.

[/QUOTE]

This is perfect, I am just curious. What do the first 2 lines do?

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 3:39 pm
by happyTugs
[CODE]{$LUA} :: lets CE know that Lua syntax is being used

if syntaxcheck then return end :: stop CE from executing lua code if it's performing a syntaxcheck

getAdressList() :: returns the cheat table 'Addresslist' UserData object

getMemoryRecordByDescription(description) :: returns a 'MemoryRecord' object based on it's description

value :: member variable of the object/class

[/CODE]

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 3:45 pm
by Mopzilla
[QUOTE="happyTugs, post: 136966, member: 39952"]

[CODE]{$LUA} :: lets CE know that Lua syntax is being used

if syntaxcheck then return end :: stop CE from executing lua code if it's performing a syntaxcheck

getAdressList() :: returns the cheat table 'Addresslist' UserData object

getMemoryRecordByDescription(description) :: returns a 'MemoryRecord' object based on it's description

value :: member variable of the object/class

[/CODE]

[/QUOTE]

Thank you, you wouldn't know how to add a script just like this one to an existing record? As far as I currently know I can only use this script if I create a new record/group, but I want to attach it to an existing record.

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 3:49 pm
by happyTugs
[QUOTE]The script itself will be used as the header. [/QUOTE]Make the script the header and supply the given name

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 3:55 pm
by Mopzilla
[QUOTE="happyTugs, post: 136968, member: 39952"]

Make the script the header and supply the given name

[/QUOTE]

Is this the only way? Is it not possible to attach a script to an existing record?

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 4:02 pm
by happyTugs
Did you even look at the example?

If the 'existing record' is a header, then no.

The header is not a script; therefore, you make a script, give it a name, put that name into the script, and use that as the header.

Is that too difficult to do?

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 4:09 pm
by Mopzilla
[QUOTE="happyTugs, post: 136973, member: 39952"]

Did you even look at the example?

If the 'existing record' is a header, then no.

The header is not a script; therefore, you make a script, give it a name, put that name into the script, and use that as the header.

Is that too difficult to do?

[/QUOTE]

I did look at the example, from what I gathered you created the header using the auto assembly so it has a script attached, and then dragged other records and put them as children.



I don't really get what you mean.

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 4:25 pm
by happyTugs
[QUOTE]Is it not possible to attach a script to an existing record? [/QUOTE]If the 'existing record' is a script, then simply append it to the script itself.

[CODE=lua][ENABLE]

{$LUA}

if not syntaxcheck then

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 1

-- if you have some more lua scripting, add them here

end

{$ASM}

// paste your assembly code in the enable section here



[DISABLE]

{$LUA}

if not syntaxcheck then

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 0

-- if you have some more lua scripting, add them here

end

{$ASM}

// paste your assembly code in the disable section here[/CODE]

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 4:34 pm
by Mopzilla
[QUOTE="happyTugs, post: 136975, member: 39952"]

If the 'existing record' is a script, then simply append it to the script itself.

[CODE=lua][ENABLE]

{$LUA}

if not syntaxcheck then

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 1

-- if you have some more lua scripting, add them here

end

{$ASM}

// paste your assembly code in the enable section here



[DISABLE]

{$LUA}

if not syntaxcheck then

getAddressList().getMemoryRecordByDescription('nameOfHeader').value = 0

-- if you have some more lua scripting, add them here

end

{$ASM}

// paste your assembly code in the disable section here[/CODE]

[/QUOTE]

The existing record is not a script. I can just create a parent and have it be a child like the thing I was posting about. It would just look nicer if the script could be attached to the existing record.

[HELP] Change Group value using Script

Posted: Tue May 26, 2020 9:58 pm
by TimFun13
Make the script then select and drag the child records you want to the script to make then children belonging to the script. Then the script will act like a group header.