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(s) not behaving in the same manner

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

Joined: 08 Oct 2012
Posts: 366

PostPosted: Tue Mar 28, 2017 9:20 am    Post subject: ListView(s) not behaving in the same manner Reply with quote

I have copied one set of code from one table to another table, two game ROM's
In one table The list view displays correct information, the other table displays no information> Can anyone tell me where the second is in error?

First code, shortened for easier reading--this one displays the table value correctly
Code:
function FormShow(sender)

listview_clear(CheatPanel_CEListView1)

function addLevelItem(level, exp)
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,31)
addLevelItem(02,95)
addLevelItem(03,207)
...
addLevelItem(98,2637111)
end
...
function CEListView1Click(sender)
--print('Selected index = '..listview_getItemIndex(CheatPanel_CEListView1))
indexname = listview_getItemIndex(CheatPanel_CEListView1)
e = listview_getItems(CheatPanel_CEListView1)
item = listitems_getItem(e, indexname)
--print(item)
levelvalue = tonumber(listitem_getCaption(item))--this is the level selected
--print("level value", levelvalue)
subitems = listitem_getSubItems(item)
--print("subitems", subitems)
expvalue = tonumber(strings_getString(subitems, 0))
--print("The exp is", expvalue)
  if heronamelevel ~= nil then--from CheatPanel_CERadioGroup1
  memoryrecord_setValue(heronamelevel, expvalue - math.floor(expvalue/65536) * 65536)--this only would work to 16^4
  memoryrecord_setValue(heronamelevelE, math.floor(expvalue/65536))--this only would work to 16^4
  end
heronamelevel = nil
radiogroup_setItemIndex(CheatPanel_CERadioGroup1, 0)
end
end

form_show(CheatPanel)


This is the second code that does not display the values
Code:
function FormShow(sender)
listview_clear(CheatPanel_CEListView1)

function addLevelItem(level, exp)
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,31)
addLevelItem(02,95)
addLevelItem(03,207)
...
addLevelItem(98,2637111)
end
...
function CEListView1Click(sender)
--print('Selected index = '..listview_getItemIndex(CheatPanel_CEListView1))
indexname = listview_getItemIndex(CheatPanel_CEListView1)
e = listview_getItems(CheatPanel_CEListView1)
item = listitems_getItem(e, indexname)
--print(item)
levelvalue = tonumber(listitem_getCaption(item))--this is the level selected
--print("level value", levelvalue)
subitems = listitem_getSubItems(item)
--print("subitems", subitems)
expvalue = tonumber(strings_getString(subitems, 0))
--print("The exp is", expvalue)
  if heronamelevel ~= nil then--from CheatPanel_CERadioGroup1
  memoryrecord_setValue(heronamelevel, expvalue - math.floor(expvalue/65536) * 65536)--this only would work to 16^4
  memoryrecord_setValue(heronamelevelE, math.floor(expvalue/65536))--this only would work to 16^4
  end
heronamelevel = nil
radiogroup_setItemIndex(CheatPanel_CERadioGroup1, 0)
end
end

form_show(CheatPanel)


In each table there is an onClick procedure in both RadioGroup and ListView.
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 121

Joined: 09 Jun 2013
Posts: 3279

PostPosted: Tue Mar 28, 2017 5:47 pm    Post subject: Reply with quote

Second form doesn't attach to the OnShow event?
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Tue Mar 28, 2017 8:51 pm    Post subject: Reply with quote

Zanzer wrote:
Second form doesn't attach to the OnShow event?


I'm not sure what you mean, but in both tables there is an OnClick event shown for the ListView. Here are a couple of images.



NoData.png
 Description:
 Filesize:  24.62 KB
 Viewed:  3972 Time(s)

NoData.png



DataShown.png
 Description:
 Filesize:  30.86 KB
 Viewed:  3972 Time(s)

DataShown.png


Back to top
View user's profile Send private message Yahoo Messenger
Corroder
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 426

PostPosted: Tue Mar 28, 2017 10:37 pm    Post subject: Reply with quote

Try change function name for function FormShow(sender) to function FormShow2(sender)..etc ?
_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Wed Mar 29, 2017 9:34 am    Post subject: Reply with quote

Still not showing data in ListView. After
Code:
addLevelItem(98,2637111)
end

What would be to the code to debug print all of the items in addLevelItem?
I tried
for each levelitems in addLevelItem
print(levelitems .. " " .. item)
end
But that resulted in an error.

EDIT:I did a copy of the first 100 or so lines down to addLevelItem(98,2637111) and pasted them into the debug widow and hit the execute button and the ListView populated as the other on does at start up.

EDIT:I moved all the code lines referring to the add items to the end of the code, just prior to form_show(CheatPanel) and the table is populated, like the other table. I'm not sure why this is, but the issue was resolved.
Back to top
View user's profile Send private message Yahoo 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
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