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 


Listview : Read a row/column and use to change an address

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
pursuited357
Cheater
Reputation: 0

Joined: 23 Sep 2020
Posts: 26

PostPosted: Wed Sep 23, 2020 3:41 am    Post subject: Listview : Read a row/column and use to change an address Reply with quote

Ive been googling forever and cannot find my answer, so if this was posted, I apologize.

I have a listview made. I can click button to add my data.

Id like to be able to click or double click a row/column and then use that data to change an address.

I can read the addresses fine and change them fine with an edit button + Command Button.

I click a button, it adds my X, Y, Z Coords.

I want to read that data to write the X, Y, and/or Z Coords with the data it has in the listview.

Code:
local readxcoord=addresslist_getMemoryRecordByDescription(getAddressList(), "XCoord")
local readycoord=addresslist_getMemoryRecordByDescription(getAddressList(), "YCoord")
local readzcoord=addresslist_getMemoryRecordByDescription(getAddressList(), "ZCoord")
local yourxvalue=memoryrecord_getValue(readxcoord)
local youryvalue=memoryrecord_getValue(readycoord)
local yourzvalue=memoryrecord_getValue(readzcoord)


Code:
function CETrainer_savecoordsClick(sender)
local items = CETrainer.CEListView1.Items
local item = items.Add()
item.Caption = CETrainer.savedcoordname.Text --savedcoordname is an editbox
item.SubItems.text = yourxvalue..'\n'..youryvalue..'\n'..yourzvalue
end


So lets say (using my picture) I click or doubleclick "Test 2".
Id like to have CE read those X, Y, and Z and then write to their corresponding addresses.

Lets say I am at:
x= 123
y= 456
z= 789

and Test 2 reads:
x= 231.3480072
y= -25.39474869
z= -21.72215538

The click event will then change my X, Y, Z to "Test 2"s info..

Make sense?

In case your wondering, ive tried this for click/double click:
Code:
function CETrainer_CEListView1DblClick(sender)
showMessage('You double-clicked with selected index '..tostring(CETrainer.CEListView1.getItems()))
end


and

Code:
function CETrainer_CEListView1DblClick(sender)
--print('Selected index = '..listview_getItemIndex(CheatPanel_CEListView1))
indexname = listview_getItemIndex(CETrainer_CEListView1)
e = listview_getItems(CETrainer_CEListView1)
item = listitems_getItem(e, indexname)
showMessage(tostring(listitems_getItem(e, indexname)))
end


Thx!

Also Id like to figure out a few listview things:
1) Round my X, Y, Zs to 2 decimal places rounded up
(So "Test 2" reads "X" as "231.35")

2) Be able to save and load my Listview data
(I add a few things to the list. Save it. Close everything. Load CE and it has same listview)



listview.png
 Description:
 Filesize:  8.09 KB
 Viewed:  1496 Time(s)

listview.png


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Sep 23, 2020 3:56 am    Post subject: Reply with quote

I preferer ListView OnSelectItem which has as parameters: (sender, listitem, selected) but onclick works as well (sure you don't want dblclick?)


Code:

function myslistviewClickEvent(sender)
  local index=CETrainer.CEListView1.ItemIndex
  local newxcoord=CETrainer.CEListView1.Items[index].SubItems[0]
  local newycoord=CETrainer.CEListView1.Items[index].SubItems[1]
  local newzcoord=CETrainer.CEListView1.Items[index].SubItems[2]

  AddressList.getMemoryRecordByDescription('XCoord').Value=newxcoord
  AddressList.getMemoryRecordByDescription('YCoord').Value=newycoord
  AddressList.getMemoryRecordByDescription('ZCoord').Value=newzcoord 
end


as for the decimal stuff you can use format.
e.g:
Code:

yourxvalue=string.format('%.2f',tonumber(AddressList.getMemoryRecordByDescription('XCoord').Value))


as for saving you can use a file, or the registry/cesettings
you'll have to scan through all the lines and format it in a way you know how to load back. Then save it.
And then loading back using the way you designed it

_________________
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
pursuited357
Cheater
Reputation: 0

Joined: 23 Sep 2020
Posts: 26

PostPosted: Wed Sep 23, 2020 4:21 am    Post subject: Reply with quote

Quote:
(sure you don't want dblclick?)


Yes
I made it work for double-click.
So now the listview works the way I like.

Also I got my coords to show the way I like with your code.

As for load/save the list... I know the concept of saving to a text line by line.

I want to save it like this
Test2 : X=123 Y=345 Z=678

and when i read the file/txt to put the name as "Test2" then the X,Y,Zs minus the text of " : " and the "X:" "Y:" "Z:"

So for the above:
Code:
Test 2 reads:
x= 231.3480072
y= -25.39474869
z= -21.72215538


Save to a text like this:
Code:
Test2 : x=231.3480072 y= -25.39474869 z=-21.72215538




And thx for quick reply!
Back to top
View user's profile Send private message
pursuited357
Cheater
Reputation: 0

Joined: 23 Sep 2020
Posts: 26

PostPosted: Thu Sep 24, 2020 11:47 pm    Post subject: Reply with quote

How would I go about making a button to delete whatever I select?

Either multiple selections or just one.

Thanks again!

EDIT

Figured it out... dont know how i missed the post on it..
(me and google are just not getting along today...)

This is what allowed me to delete the selected one.
Code:
list = CETrainer.CEListView1
local i=list.Selected.Index
list.Items[list.ItemIndex].Delete(i)


SOLVED!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
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