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 


Help me finish my listview please
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sat Jan 19, 2013 7:54 am    Post subject: Reply with quote

This code will add some items to the list:
Code:

function addLevelItem(level, exp)
  local lvitems=listview_getItems(UDF1_CEListView1) --change this accordingly
  local item=listitems_add(lvitems)
  local subitems=listitem_getSubItems(item)

  listitem_setCaption(item,level)
  strings_add(subitems, exp)
end

addLevelItem(1,999)
addLevelItem(2,1999)
--...
addLevelItem(20,999999)


and to get the selected item, use listview_getItemIndex
e.g:
Code:

function CEListView1Click(sender)
  print('Selected index='..listview_getItemIndex(UDF1_CEListView1))
end


Keep in mind that the selected index goes from 0, and -1 means nothing selected

_________________
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: Sat Jan 19, 2013 9:52 am    Post subject: Reply with quote

Put your code into the script as follows:
Code:

function CEListView1Click(sender)
function addLevelItem(level, exp)
  local lvitems=listview_getItems(UDF1_CEListView1)
  local item=listitems_add(lvitems)
  local subitems=listitem_getSubItems(item)
  listitem_setCaption(item,level)
  strings_add(subitems, exp)
end
addLevelItem(01,0)
addLevelItem(02,32)
addLevelItem(03,96)
...
addLevelItem(99,2637112)
  print('Selected index='..listview_getItemIndex(UDF1_CEListView1))
end

Now when I select either Level or Exp column nothing happens, when I select the blank area below the headers, I get acces violation error.
Yes the object is named CEListView1.


Also I don't understand what UDF1 means?



CETListViewError.png
 Description:
 Filesize:  18.77 KB
 Viewed:  11516 Time(s)

CETListViewError.png


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

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

PostPosted: Sat Jan 19, 2013 10:07 am    Post subject: Reply with quote

UDF1 is the name of the form and CEListView1 is the nameof the listview.
UDF1_CEListView1 accesses the listview on that form, so adjust the names accordingly (6.3 will be a lot easier in this regard)

also, don't put all that code inside the context of CEListView1Click, it should be a global function, and that code needs to be executed one time for initialization

_________________
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: Sat Jan 19, 2013 10:21 am    Post subject: Reply with quote

Quote:
UDF1 is the name of the form and CEListView1 is the name of the listview

duh lol, that prolly is the reason it didn't work as my form is named CheatTable
Ok, that part works, thanks.
Did you see my AOB post about the code not finding any search hits with the memscan that has worked reviously?

EDIT:
wow, everytime I open the CE the code is adding all 99 items, up to 395 currently. It looks like we need another function to delete all the address and then re-add just 99. I tried this and several other iterations using both listview_getCount and strings_getCount but get an access violation
Code:
function deleteLevelItem(level, exp)
local lvitems=listview_getItems(CheatPanel_CEListView1)
--local item=listitems_add(lvitems)
local subitems=listitem_getSubItems(item)
listitem_setCaption(item,level)
for x=0, listview_getCount(CheatPanel_CEListView1)-1 do
strings_clear(subitems, exp)--x, exp
end
end

Still haven't deleted any of the list.
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sun Jan 20, 2013 4:52 am    Post subject: Reply with quote

use listitems_getItem(lvitems, x) to get the specific listitem object
and then call listitem_delete(item) to remove it from the list.

Note that all subsequent entries in the list shift one back, so you can basically constantly get item nr 0 until count is 0

_________________
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 Jan 20, 2013 10:22 am    Post subject: Reply with quote

Code:
function deleteLevelItem(level, exp)
local lvitems=Listview_getItems(CheatPanel_CEListView1)
local subitems=listitem_getSubItems(item)
listitem_setCaption(item,level)
for x = 0, ListItems_getCount(lvitems) - 1 do
ListItems_getItem(lvlitem, x)
print(ListItems_getItem(lvlitem, x))
ListItem_delete(lvitem)
end
end

Tried this and did not do anything not even an error message. Tried several other attempts
ListItems_getItem(x)
ListItems_getItem(lvitem)
Still nothing, shut down CE and got this error, plus the code error in my AOB thread http://forum.cheatengine.org/viewtopic.php?t=560818&postdays=0&postorder=asc&start=15



CETCodeError1.png
 Description:
 Filesize:  6.79 KB
 Viewed:  11471 Time(s)

CETCodeError1.png


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

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

PostPosted: Sun Jan 20, 2013 10:30 am    Post subject: Reply with quote

It's case sensitive, it's not ListItems_getItem but listitems_getItem

also , it's not lvlitem but lvitems
and instead of x use the value 0

_________________
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 Jan 20, 2013 12:38 pm    Post subject: Reply with quote

Code:
function deleteLevelItem(level, exp)
--errorOnLookupFailure(false)
local lvitems = listview_getItems(CheatPanel_CEListView1)
local subitems = listitem_getSubitems(item)
listitem_setCaption(item, level)
listitems_getItem(lvitems, 0)
print(listitems_getItem(lvitems, 0))
listitem_delete(lvitems)
end

Still nothing, no print statement, no error statement and no deletions
I appreciate your time, efforts and patience, but I'm through with this project in 6.2 as the original code doesn't work and listview object is unusable.
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Tue Feb 12, 2013 9:14 pm    Post subject: Reply with quote

I had a brain storm tonight, and I'm soaked.
Anyway I was looking at the command codes last night and the light bulb went on. I tried this and it appears to have eliminated the duplicate lists, I was asking about earlier in the thread.
Code:

function FormShow(sender)
  listview_clear(CheatPanel_CEListView1)
  function addLevelItem(level, exp)
    --listview_clear(CheatPanel_CEListView1)
    local lvitems=listview_getItems(CheatPanel_CEListView1)
    local item=listitems_add(lvitems)
    local subitems=listitem_getSubItems(item)
    listitem_setCaption(item,level)
    strings_add(subitems, exp)
  end
  addLevelItem(01,0)
  addLevelItem(02,31)
  addLevelItem(03,95)
  addLevelItem(04,207)
  addLevelItem(05,399)
  ...
  addLevelItem(99,2637111)
end

Is there any problem with attaching the code to a FormShow, that is working with the list view later on, ie obtaining values from the list?

You gave me the following code earlier, but I need to be able to use the value associated with the index. I have tried all sorts of combinations like expvalue = ListItem_getSubItem(e, indexname) and expvalue = strings_getString(e, indexname), but have been unable to catch the value associated with each particular index selected(pointed at if you understand)
Code:

function CEListView1Click(sender)
  print('Selected index='..listview_getItemIndex(CheatPanel_CEListView1))
  indexname = listview_getItemIndex(CheatPanel_CEListView1)
  e = listview_getItems(CheatPanel_CEListView1)
end
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Feb 13, 2013 5:19 am    Post subject: Reply with quote

I recommend adding a boolean check to make sure the onshow code doesn't execute more than once (e.g multiple form_show commands)

As I said it's easier to just remember the value you've put there.
So when using listview_getItemIndex() you'd know that a result of 0 means 1,0 1 means 2,31 3 means 3,95

anyhow,
The code is ok, but missing the last part
You get the itemindex (indexname)
Then you get the Items object (e)

To continue, you need to get the Item (Note that Items and Item are different things)
item=listitems_getItem(e, indexname)

Then you need to get the caption (first column) and subitems (subsequent columns)
To get the caption just use listitem_getCaption(item)

To get the subitems you need to use subitems=listitem_getSubItems(item) which will return a StringList object (inherited from Strings)
To get the first item (Second column): strings_getString(subitems, 0)
To get the second item (third column): strings_getString(subitems, 1)
...

(As I said it's easier to just remember the value you've put there.
So when using listview_getItemIndex() you'd know that a result of 0 means 1,0 1 means 2,31 3 means 3,95

anyhow,
The code is ok, but missing the last part
You get the itemindex (indexname)
Then you get the Items object (e)

To continue, you need to get the Item (Note that Items and Item are different things)
item=listitems_getItem(e, indexname)

Then you need to get the caption (first column) and subitems (subsequent columns)
To get the caption just use listitem_getCaption(item)

To get the subitems you need to use subitems=listitem_getSubItems(item) which will return a StringList object (inherited from Strings)
To get the first item (Second column): strings_getString(subitems, 0)
To get the second item (third column): strings_getString(subitems, 1)
...

(Next ce version you should be able to do
Code:

lv=CheatPanel.CEListView1
secondcolumn=lv.Items[lv.ItemIndex].subItems[0]

or
Code:

secondcolumn=CheatPanel.CEListView1.Items[CheatPanel.CEListView1.ItemIndex].SubItems[0]

_________________
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: Wed Feb 13, 2013 7:09 am    Post subject: Reply with quote

At least so far only one set of data exists(the data sets numbered close to 7000 before I got the idea to clear it first then re-built the data set).
Close but no cigar--huh!
The second sets of code gives an error "attempt to index global 'CheatPanel' (a userdata value)".
Code:
lv=CheatPanel.CEListView1
secondcolumn=lv.Items[lv.ItemIndex].subItems[0]

and
Code:
secondcolumn=CheatPanel.CEListView1.Items[CheatPanel.CEListView1.ItemIndex].SubItems[0]


The first with all the steps gives no error.
Code:
function CEListView1Click(sender)
indexname = listview_getItemIndex(CheatPanel_CEListView1)
e = listview_getItems(CheatPanel_CEListView1)
item = listitems_getItem(e, indexname)
levelvalue = tonumber(listitem_getCaption(item))--this is the level selected
subitems = listitem_getSubItems(item)
expvalue = tonumber(strings_getString(subitems, 0))

nextindexname = indexname + 1
nextitem = listitems_getItem(e, nextindexname)
nextlevelvalue = tonumber(listitem_getCaption(nextitem))
nextsubitems = listitem_getSubItems(nextitem)
nextexpvalue = tonumber(strings_getString(nextsubitems, 0))
--lv=CheatPanel.CEListView1
--secondcolumn=lv.Items[lv.ItemIndex].subItems[0]
--secondcolumn=CheatPanel.CEListView1.Items[CheatPanel.CEListView1.ItemIndex].SubItems[0]
end

Back about 15 years, I was working with large data sets and Access(programming data manipulations with Access actually). I remember there was an order of execution to the forms(although I don't remember all the commands or the order); is there an order of execution to the to the events on the panel and each object?
Back to top
View user's profile Send private message Yahoo Messenger
Moonbluelegend
How do I cheat?
Reputation: 0

Joined: 09 Feb 2013
Posts: 5

PostPosted: Wed Feb 13, 2013 8:05 am    Post subject: Reply with quote

I'm not sure this is not what you want


123.jpg
 Description:
 Filesize:  22.81 KB
 Viewed:  11330 Time(s)

123.jpg



123.CETRAINER
 Description:

Download
 Filename:  123.CETRAINER
 Filesize:  1.47 KB
 Downloaded:  447 Time(s)

Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Wed Feb 13, 2013 8:13 am    Post subject: Reply with quote

bknight PM with exact what kind of trainer you want, and I'll do my best for you Wink .
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Wed Feb 13, 2013 8:42 pm    Post subject: Reply with quote

Moonbluelegend wrote:
I'm not sure this is not what you want


If you look two posts up, you'll see I have a list box that contains levels and experience-1. What I'm trying to do is to take the level and write a new value(from the list box) into the appropriate the correct locations. This particular game FF VI(III in CONUS), where all the heroes have the same level up stats. Howver, many if not all the games have different level up values, so this is only a beginning.



CheatPanel.png
 Description:
 Filesize:  12.48 KB
 Viewed:  11300 Time(s)

CheatPanel.png


Back to top
View user's profile Send private message Yahoo Messenger
Moonbluelegend
How do I cheat?
Reputation: 0

Joined: 09 Feb 2013
Posts: 5

PostPosted: Wed Feb 13, 2013 10:48 pm    Post subject: Reply with quote

Quote:

If you look two posts up, you'll see I have a list box that contains levels and experience-1. What I'm trying to do is to take the level and write a new value(from the list box) into the appropriate the correct locations. This particular game FF VI(III in CONUS), where all the heroes have the same level up stats. Howver, many if not all the games have different level up values, so this is only a beginning.


Code:


function CEButton1Click(sender)
addLevelItem("01",0)
addLevelItem("02",31)
addLevelItem("03",95)
addLevelItem("04",207)
addLevelItem("05",399)
end



item={}
subitems={}
listindex=1

function addLevelItem(level, exp)
   lvitems=listview_getItems(UDF1_CEListView1) --change this accordingly
   item[listindex]=listitems_add(lvitems)
   subitems[listindex]=listitem_getSubItems(item[listindex])
   listitem_setCaption(item[listindex],level)
   strings_add(subitems[listindex], exp)
   listindex = listindex+1
end

function CEListView1Click(sender)
local LevelValue
local subitemsValue={["ExpValue"]=""}
--LevelValue
LevelValue=listitem_getCaption(item[listview_getItemIndex(UDF1_CEListView1)+1])
--ExpValue
subitemsValue["ExpValue"]=strings_getString(subitems[listview_getItemIndex(UDF1_CEListView1)+1],0)
-- show
control_setCaption(UDF1_CEEdit1,LevelValue.." "..subitemsValue["ExpValue"])
end



123.jpg
 Description:
 Filesize:  20.02 KB
 Viewed:  11288 Time(s)

123.jpg


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
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
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