Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


CE Edit Box usage
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Thu Jan 31, 2013 7:28 am    Post subject: CE Edit Box usage Reply with quote

Since my foray into listviews ended so poorly, I'm trying a different approach.
What I have is two edit boxes. If a value is entered into the box, I'm assuming that the OnChange event will have that value to use somewhere else in code.
What is the proper syntax to use a value typed into the box?
Code:

function CEEdit1Change(sender)
expvalue = ????
end

With a second edit box and its respective value
Code:

function CEEdit1Change(sender)
goldvalue = ???
end

The two values then can be checked against the memory to recalculate the table, either in this code block or refer back to these values in a main cheat table code?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Thu Jan 31, 2013 3:51 pm    Post subject: Reply with quote

control_getCaption should be able to get the user input string

e.g:
expvalue = tonumber(control_getCaption(TRAINERFORM_EXPEDITBOX))

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Thu Jan 31, 2013 4:37 pm    Post subject: Reply with quote

Oh that worked, except it outputs only the first key depress. Subsequent key strokes require going back to the EditBox. I tried entering the code in OnEnter event, but that didn't work. I'm sure there is a subtle difference in the code using OnEnter.

Also are the values only "available" in the control functions or are they static across all the functions?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Thu Jan 31, 2013 4:57 pm    Post subject: Reply with quote

Did you set an OnKeyDown method as well? If so, try to remove it from the event list as it can block key presses if no return is set

Also, OnEnter is only triggered when you gain focus. (e.g tab from one control to another)
OnChange is what you need since that gets called for every key press
Else combine it with a button to press when everything is entered

all objects that inherit from Control can use the control_ functions.
Check the main.lua, each class has it's inheritance listed

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 01, 2013 8:35 am    Post subject: Reply with quote

Nothing else was selected, the control just accepts one key stroke.
On your advice I deleted the events on the two CEEdits and added two buttons. Those two worked good.
Then I added a CERadioGroup added 8 names and their radio buttons. The form looks good after re-spacing, but when the OnClick event is selected and a radio button is changed all I get is an error "access violation"
Code:

function CEButton1Click(sender)
expvalue = tonumber(control_getCaption(CheatPanel_CEEdit1))
print('Experience = '..expvalue)
--if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
--RecalculateAddresses()
--end
end

function CEButton2Click(sender)
goldvalue = tonumber(control_getCaption(CheatPanel_CEEdit2))
print('Gold = '..goldvalue)
--if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
--RecalculateAddresses()
--end
end

function CERadioGroup1Click(sender)
heroname = control_getCaption(CheatPanel_CERadioGroup1Click)
print("Hero name = ", heroname)
--if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
--RecalculateAddresses()
--end
end
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Fri Feb 01, 2013 8:39 am    Post subject: Reply with quote

Is your form named CheatPanel?
If the object is inside a panel in a form, you must still use the formname


Also,
Code:

control_getCaption(CheatPanel_CERadioGroup1Click)

You must use the name of the object, so probably CERadioGroup1

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 01, 2013 11:21 am    Post subject: Reply with quote

Stupid me, youre correct. That eliminated the access violation.
But the value recovered is just the caption for the RadioGroup, which makes sense.
Results in Hero name = Hero name (which is the caption of the RadioGroup)
How are the values of the RadioGroup accessed?

function CERadioGroup1Click(sender)
heroname = control_getCaption(CheatPanel_CERadioGroup1)
print("Hero name = ", heroname)
--if expvalue ~= nil and goldvalue ~= nil and heroname ~= nil then
--RecalculateAddresses()
--end
end
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Fri Feb 01, 2013 12:20 pm    Post subject: Reply with quote

Use radiogroup_getItemIndex to find out which of the options was selected (-1 means nothing selected, 0 + is the index in the strings object of the radiogroup)

If you know the order, just check the id, else you may have to use radiogroup_getItems() to get the stringlist object and then strings_getString(stringsobject, index) to get the specific text

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 01, 2013 3:31 pm    Post subject: Reply with quote

Please be patient:
The second part is what I believe I am trying to get using the value of the radiogroup, that is.
radiogroup_getItems()--Doesn't do anything
h = radiogroup_getItems()--Doesn't do anything
radiogroup_getItems(stringlist)--Access violation
h = radiogroup_getItems(stringlist)--Access violation
radiogroup_getItems(radiogroup_getItems(CheatPanel_CERadioGroup1(stringlist))--attempt to call global 'CheatPanel_CERadioGroup1' (a userdata value)
h = radiogroup_getItems(radiogroup_getItems(CheatPanel_CERadioGroup1(stringlist))--attempt to call global 'CheatPanel_CERadioGroup1' (a userdata value)
radiogroup_getItems(radiogroup_getItems(CheatPanel_CERadioGroup1())--attempt to call global 'CheatPanel_CERadioGroup1' (a userdata value)
h = radiogroup_getItems(radiogroup_getItems(CheatPanel_CERadioGroup1())--attempt to call global 'CheatPanel_CERadioGroup1' (a userdata value)
I even tried (stringlist, index) on all but don't have anything to work with. I just don't get what you are telling me
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Fri Feb 01, 2013 4:52 pm    Post subject: Reply with quote

radiogroup_getItems( CheatPanel_CERadioGroup1) will return a Strings class object containing the string

strings_getString is used to access the individual strings of that object

Anyhow, i do recommend just going by index alone instead of string compares. It's a lot easier

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Fri Feb 01, 2013 6:14 pm    Post subject: Reply with quote

I was going to use the strings_getString(stringsobject, index), since the index part worked for me. I'll give it a try later tonight.
Thanks

EDIT:
For those that follow or search:
1. The string object is in a hex format without 0x, which is probably why DB recommended searching for the index.
2. If the index is not set to a variable, the result is always the first index (0).
Code:

indexname = radiogroup_getItemIndex(CheatPanel_CERadioGroup1)
h = radiogroup_getItems(CheatPanel_CERadioGroup1)
heroname = strings_getString(h, indexname)

The result is the correct name desired.

EDIT AGAIN:
Using the memscan
memscan_firstScan(ms, soExactValue, vtWord, rtRounded, expvalue, "", "00000000", "7fffffff", "*X*C*W", fsmNotAligned, "", false, false, false, false);

Where expvalue = 30136 in this case(derived with the CEEditBox and Button).
When 30136 is added to the value of a normal CE search and 2 bytes selected type has writable checked and a green square in executable nothing in the copyonwrite results in 6 hits.
When the scan is run with code the result is 3 hits, none of which are identical to the 6 with the normal scan.
I have tinkered with vtBinary and setting the isNotABinaryString to true but that resulted in finding all the items in the table.
Then I tried searching for an AOB "B8 75" and found 149 hits all 6 of the normal were included. Changing *X*C*W to *W resulted in the same 149 hits.

So the question is how to search for a decimal number two bytes long, or does the search require an AOB with a little endian format?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Sun Feb 03, 2013 4:26 am    Post subject: Reply with quote

+ = checked
- = unchecked
* = square

So,
writable checked = +W
green square in executable = *X
nothing in copy on write = -C

+W*X-C

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Sun Feb 03, 2013 2:45 pm    Post subject: Reply with quote

Ah, the code page did not give an equal sign, thanks.

What I tried to do was perform two searches as follows:
Code:

function RecalculateAddresses()
print("Hero name ", heroname, "experience to search = " ,expvalue, "and gold to match = ", goldvalue)
  if heroname == "Hero" then
      goldoffset = 0x146
    elseif heroname == "Christo" then
      goldoffset = 0x128
    elseif heroname == "Nara" then
      goldoffset = 0x10A
    elseif heroname == "Mara" then
      goldoffset = 0xEC
    elseif heroname == "Brey" then
      goldoffset = 0xCE
    elseif heroname == "Taloon" then
      goldoffset = 0xB0
    elseif heroname == "Ragnar" then
      goldoffset = 0x92
    else
    goldoffset = 0x74
  end
  print(goldoffset)
  goldoffset = string.format('%x', goldoffset)
  print(goldoffset)
  goldoffset = "0x" .. goldoffset
  print(goldoffset)
errorOnLookupFailure(false);
ms = createMemScan();
ms2 = createMemScan();
--Need to search for either an AOB or an Integer
memscan_firstScan(ms, soExactValue, vtWord, rtRounded, expvalue, "", "00000000", "7fffffff", "+W*X-C", fsmNotAligned, "", false, false, false, false);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
memscan_firstScan(ms2, soExactValue, vtWord, rtRounded, goldvalue, "", "00000000", "7fffffff", "+W*X-C", fsmNotAligned, "", false, false, false, false);
memscan_waitTillDone(ms2);
fl2 = createFoundList(ms2);
foundlist_initialize(fl2);
foundlist_getCount(fl2);
print("num of search hits for experience is ", foundlist_getCount(fl));
print("num of search hits for gold is ", foundlist_getCount(fl2));
print("Gold offset from if statement", goldoffset);
  for x = 0, foundlist_getCount(fl)-1  do--Items are in the hex format (0125D60F) without 0x
    memrec1 = foundlist_getAddress(fl, x);
    print("Experience from foundlist_getAddress(fl, x)", memrec1);
    memrec2 = "0x" .. memrec1;
    goldtest = memrec2 + goldoffset;--Items are in the number format of the hex summation
    print("Search record number", x, " gold test address", goldtest);
    goldtestaddress = string.format('%x', goldtest);--Items in number format converted to hex format without 0x
    print("Gold test address", goldtestaddress)

The results of the print statement are:
cc4167--the corect address
cc4457
etc.

Code:
 
    for y = 0, foundlist_getCount(fl2)-1 do
      memrec3 = foundlist_getAddress(fl2, y);
      print("Gold from foundlist_getAddress(fl2, y)", memrec3);

The results of the print statements are:
00253B1B
00CC4167--The correct address, see above
00CC4457
etc.
Code:

      --memrec4 = "0x" .. memrec3;
      if memrec3 == goldtestaddress then
        byteoffset = memrec3;
      end;
    end;
  end;
print("Byteoffset to correct table entries", byteoffset);
print("Experience to check table entries", memrec1);
addresslist = getAddressList();
--for x = 0, addresslist_getCount(addresslist)-1 do
--memrec5 = addresslist_getMemoryRecord(addresslist, x);
--if byteoffset ~= memrec1 then
  --memoryrecord_setAddress(memrec5, string.format('%x', memoryrecord_getAddress(memrec4) + byteoffset - terratableaddress));
  --end;
--end;
end


When the line "if memrec3 == goldtestaddress then" is executed nothing matches. Considering the output that wasn't a surprise.
Now I could concate two 0's to the goldtestaddress, however, doing so would not make the code as generic as I would prefer. Also there could be occurrences where the found memory addresses don't occur at the beginning of total memory. Is there any other statement or procedure that I might be able to use to make the two addresses be identical and go forward the recalculation?
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Feb 04, 2013 6:38 am    Post subject: Reply with quote

I tried another method of getting to the calculation, similar to the previous.
Code:

function RecalculateAddresses()
print("Hero name ", heroname, "experience to search = " ,expvalue, "and gold to match = ", goldvalue)
  if heroname == "Hero" then
      goldoffset = 0x146
    elseif heroname == "Christo" then
      goldoffset = 0x128
    elseif heroname == "Nara" then
      goldoffset = 0x10A
    elseif heroname == "Mara" then
      goldoffset = 0xEC
    elseif heroname == "Brey" then
      goldoffset = 0xCE
    elseif heroname == "Taloon" then
      goldoffset = 0xB0
    elseif heroname == "Ragnar" then
      goldoffset = 0x92
    else
    goldoffset = 0x74
  end
  print(goldoffset)
  --goldoffset = string.format('%x', goldoffset)
  --print(goldoffset)
  --goldoffset = "0x" .. goldoffset
  --print(goldoffset)
errorOnLookupFailure(false);
ms = createMemScan();
ms2 = createMemScan();
--Need to search for either an AOB or an Integer
memscan_firstScan(ms, soExactValue, vtWord, rtRounded, expvalue, "", "00000000", "7fffffff", "+W*X-C", fsmNotAligned, "", false, false, false, false);
memscan_waitTillDone(ms);
fl = createFoundList(ms);
foundlist_initialize(fl);
foundlist_getCount(fl);
memscan_firstScan(ms2, soExactValue, vtWord, rtRounded, goldvalue, "", "00000000", "7fffffff", "+W*X-C", fsmNotAligned, "", false, false, false, false);
memscan_waitTillDone(ms2);
fl2 = createFoundList(ms2);
foundlist_initialize(fl2);
foundlist_getCount(fl2);
print("num of search hits for experience is ", foundlist_getCount(fl));
print("num of search hits for gold is ", foundlist_getCount(fl2));
print("Gold offset from if statement", goldoffset);
  for x = 0, foundlist_getCount(fl)-1  do--Items are in the hex format (0125D60F) without 0x
    memrec1 = foundlist_getAddress(fl, x);
    print("Experience from foundlist_getAddress(fl, x)", x, memrec1);
    --memrec2 = "0x" .. memrec1;
    memrec2 = tonumber(memrec1, 16);
    --goldtest = memrec2 + goldoffset;--Items are in the number format of the hex summation
    print("Search record number", x, " experience address in number format ", memrec2);
    --goldtestaddress = string.format('%x', goldtest);--Items in number format converted to hex format without 0x
    --print("Gold test address", goldtestaddress)
    for y = 0, foundlist_getCount(fl2)-1 do--Items are in hex format without the 0x
      memrec3 = foundlist_getAddress(fl2, y);
      print("Gold from foundlist_getAddress(fl2, y)", y, memrec3);
      memrec4 = tonumber(memrec3, 16);
      print("Search record number", y, " gold address in number format ", memrec4);
      --memrec4 = "0x" .. memrec3;
      print("mem diff ", memrec4 - memrec2, "gold offset diff should be", goldoffset);
      if memrec4 - memrec2 == goldoffset then
        experienceaddress = memrec1;--address in hex format without 0x
        print("exp address ", experienceaddress);
        goldaddress = memrec3;--address in hex format without 0x
        byteoffset = memrec3--goldaddress
        byteoffset = tonumber(byteoffset, 16);
        --byteoffset = string.format('%x', byteoffset);
        print("gold address ", goldaddress);
        print("byteoffset ", byteoffset);
        break;
      end;
    end;
    if byteoffset ~= nil then
      break;
    end;
  end;

Everything works to here with the exception of the format of byteoffset. One may look at the various attempts to use a format that was correct
Code:

print("Byteoffset address to correct table entries", memrec3);
print("byteoffset num ", byteoffset);
--print("Experience to check table entries", memrec1);
addresslist = getAddressList();
memrec5 = addresslist_getMemoryRecordByDescription(addresslist, "Gold (2 bytes)");--address in hex format without 0x
print("Gold from table", memrec5);
goldtableaddress = memoryrecord_getAddress(memrec5);--Item in hex format without 0x
goldaddress = tonumber(goldaddress, 16);
print("gold address num ", goldaddress);
--print("Gold current table address", string.format('%x', goldtableaddress), "which is ", goldtableaddress);
--goldtableaddress = string.format('%x', goldtableaddress);--Items in number format converted to hex format without 0x
--goldtableaddress = "0x" .. goldtableaddress
--print(goldtableaddress);
for x = 0, addresslist_getCount(addresslist)-1 do
memrec6 = addresslist_getMemoryRecord(addresslist, x);--Item in hex format without the 0x
print("table record ", x, memrec6);
tablerecnum = tonumber(addresslist_getMemoryRecord(addresslist, x), 16);

bad argument #1 'tonumber' (string expected, got userdate)
The reason for changing the strings to numbers was byteoffset, a string, could not be added to goldtableaddress even though it was in hex format. This gave a an error prompting the switch to numbers.

Code:

print("table record num format", tablerecnum);
--print("table address of ", x, memrec6, "mem table rec ", string.format('%x', memoryrecord_getAddress(memrec5)));
--print("Summation of items",tablerecnum + byteoffset - goldtableaddress);
  --if byteoffset ~= goldtableaddress then
    --memreccor = tablerecnum + byteoffset + goldtableaddress--Sum the items in number format
    --memoryrecord_setAddress(memrec6, string.format('%x', memreccor));--Items in number format converted to hex format without 0x
    --memoryrecord_setAddress(memrec6, string.format('%x', memoryrecord_getAddress(memrec5) + byteoffset - goldtableaddress));

The above statement has worked in all my other attempts with byteoffset and a second address both in hex notation(with 0x), but not with this bit of code.
Code:

  --end;
end;
end

Either I change getMemoryRecord to a number or find out why byteoffset could not be added when it was in the hex formation.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Mon Feb 04, 2013 8:22 am    Post subject: Reply with quote

You are mixing up variablename types and even just variablenames causing your code to be pretty hard to read


from that i've scratched together:
First script:
Code:

memrec3 = foundlist_getAddress(fl2, y);
goldaddress = memrec3;
goldaddress = tonumber(goldaddress, 16);

Ok, that might work, but the name memrec is really bad to use here

Second script:
Code:

memrec5 = addresslist_getMemoryRecordByDescription(addresslist, "Gold (2 bytes)")
goldtableaddress = memoryrecord_getAddress(memrec5);--Item in hex format without 0x
goldaddress = tonumber(goldaddress, 16);


Where did you get goldaddress from ?

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites