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 


Another ListView Question

 
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: Mon Apr 24, 2017 11:15 am    Post subject: Another ListView Question Reply with quote

Here is some code that worked in 6.2 and 6.3, but fails in 6.6. What would be the correct syntax? This was developed prior to a table definition and population, so please no table conversion comments. DB may want to join, since he helped me with the population originally.

Code:
function FormShow(sender)
function addLevelItem1(level, exp)
local lvitems1=listview_getItems(CheatPanel_CEListView1)
local item1=listitems_add(lvitems1)
local subitems1=listitem_getSubItems(item1)
listitem_setCaption(item1,level)
strings_add(subitems1, exp)
end

addLevelItem1(01,5)--Hero Exp
addLevelItem1(02,32)
addLevelItem1(03,93)
addLevelItem1(04,201)
addLevelItem1(05,371)
addLevelItem1(06,644)
addLevelItem1(07,948)
addLevelItem1(08,1383)
addLevelItem1(09,1933)
addLevelItem1(10,2613)
addLevelItem1(11,3587)
addLevelItem1(12,4609)
addLevelItem1(13,5808)
addLevelItem1(14,7199)
addLevelItem1(15,8796)
addLevelItem1(16,10613)
addLevelItem1(17,12664)
addLevelItem1(18,14964)
addLevelItem1(19,17527)
addLevelItem1(20,20367)
addLevelItem1(21,24160)
addLevelItem1(22,27693)
addLevelItem1(23,31554)
addLevelItem1(24,35758)
addLevelItem1(25,40320)
addLevelItem1(26,45254)
addLevelItem1(27,50575)
addLevelItem1(28,56298)
addLevelItem1(29,62437)
addLevelItem1(30,69007)
addLevelItem1(31,77065)
addLevelItem1(32,84642)
addLevelItem1(33,92700)
addLevelItem1(34,101254)
addLevelItem1(35,110319)
addLevelItem1(36,119909)
addLevelItem1(37,130039)
addLevelItem1(38,140724)
addLevelItem1(39,151979)
addLevelItem1(40,163819)
addLevelItem1(41,176258)
addLevelItem1(42,189311)
addLevelItem1(43,202993)
addLevelItem1(44,217319)
addLevelItem1(45,232304)
addLevelItem1(46,247962)
addLevelItem1(47,264308)
addLevelItem1(48,281357)
addLevelItem1(49,299124)
addLevelItem1(50,317624)
addLevelItem1(51,336871)
addLevelItem1(52,356880)
addLevelItem1(53,377666)
addLevelItem1(54,399244)
addLevelItem1(55,421629)
addLevelItem1(56,444835)
addLevelItem1(57,468877)
addLevelItem1(58,493770)
addLevelItem1(59,519529)
addLevelItem1(60,546169)
addLevelItem1(61,581466)
addLevelItem1(62,610296)
addLevelItem1(63,640063)
addLevelItem1(64,670783)
addLevelItem1(65,702470)
addLevelItem1(66,735140)
addLevelItem1(67,768807)
addLevelItem1(68,803487)
addLevelItem1(69,839194)
addLevelItem1(70,875944)
addLevelItem1(71,913751)
addLevelItem1(72,952631)
addLevelItem1(73,992598)
addLevelItem1(74,1033668)
addLevelItem1(75,1075855)
addLevelItem1(76,1119175)
addLevelItem1(77,1163642)
addLevelItem1(78,1209272)
addLevelItem1(79,1256079)
addLevelItem1(80,1304079)
addLevelItem1(81,1389358)
addLevelItem1(82,1441132)
addLevelItem1(83,1494177)
addLevelItem1(84,1548508)
addLevelItem1(85,1604140)
addLevelItem1(86,1661089)
addLevelItem1(87,1719370)
addLevelItem1(88,1778998)
addLevelItem1(89,1839989)
addLevelItem1(90,1902359)
addLevelItem1(91,1966122)
addLevelItem1(92,2031294)
addLevelItem1(93,2097891)
addLevelItem1(94,2165928)
addLevelItem1(95,2235420)
addLevelItem1(96,2306383)
addLevelItem1(97,2378832)
addLevelItem1(98,2452782)
--
function CERadioGroup1Click(sender)
indexname = radiogroup_getItemIndex(CheatPanel_CERadioGroup1)
h = radiogroup_getItems(CheatPanel_CERadioGroup1)
heroname = strings_getString(h, indexname)
addresslist = getAddressList()
  if heroname == "Hero" then
    form_show(CheatPanel_CEListView1)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Hero Exp (+h3B)")
  elseif heroname == "Barrett" then
    form_show(CheatPanel_CEListView2)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Barret Exp (+h3B)")
  elseif heroname == "Tifa" then
    form_show(CheatPanel_CEListView3)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Tifa Exp (+h3B)")
  elseif heroname == "Aeris" then
    form_show(CheatPanel_CEListView4)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Aeris Exp (+h3B)")
  elseif heroname == "Nanaki" then
    form_show(CheatPanel_CEListView5)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Nanaki Exp (+h3B)")
  elseif heroname == "Yuffie" then
    form_show(CheatPanel_CEListView6)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Yuffie Exp (+h3B)")
  elseif heroname == "Cait Sith" then
    form_show(CheatPanel_CEListView7)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Cait Sith Exp (+h3B)")
  elseif heroname == "Vincent" then
    form_show(CheatPanel_CEListView8)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Vincent Exp (+h3B)")
  elseif heroname == "Cid" then
    form_show(CheatPanel_CEListView9)
    heronamelevel = addresslist_getMemoryRecordByDescription(addresslist, "Cid Exp (+h3B)")
  else
  end
end


There are nine list views all not showing until the appropriate radio graph is selected. Shown as Open_Table.
After Hero selected Shown as Hero_Selected. The list view is shown correctly, but the data probably was not loaded
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Mon Apr 24, 2017 12:23 pm    Post subject: Reply with quote

Syntax error: there's no end to the function FormShow. That code shouldn't run in any CE version. Properly indenting your code would help you identify these errors and would help everyone read your code.
Code:
Deprecated Functions | Modern Equivalent

listview_getItems(listview)                       | listview.Items
listitems_add(listitems)                          | listitems.add()
listitem_getSubItems(listitem)                    | listitem.SubItems
listitem_setCaption(listitem, str)                | listitem.Caption = str
strings_add(strings, str)                         | strings.add(str)
radiogroup_getItemIndex(radiogroup)               | radiogroup.ItemIndex
strings_getString(strings, index)                 | strings.getString(index)
form_show(form)                                   | form.show()
addresslist_getMemoryRecordByDescription(al, str) | al.getMemoryRecordByDescription(str)

You could look at main.lua (or perhaps celua.txt in the upcoming version) to find all this information.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 24, 2017 12:49 pm    Post subject: Reply with quote

There is no error loading the code. I forgot to add it.
That end is at the bottom of the code after all 9 list views' data
end--form_show

Try that

But thanks for those differences.

EDIT:
Where is Main.lua?
Back to top
View user's profile Send private message Yahoo Messenger
Zanzer
I post too much
Reputation: 120

Joined: 09 Jun 2013
Posts: 3260

PostPosted: Mon Apr 24, 2017 3:51 pm    Post subject: Reply with quote

<CE Installation Directory>/main.lua
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 24, 2017 4:15 pm    Post subject: Reply with quote

Zanzer wrote:
<CE Installation Directory>/main.lua

Been there and don't see any lua information, download/forum, bugtracker, about etc.
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Mon Apr 24, 2017 4:25 pm    Post subject: Reply with quote

If it's not there, redownload CE 6.6. The Lua documentation for the new version of CE is available on GitHub. It contains information on the predefined variables and functions as well as information on the different classes and their members (i.e. properties and methods).
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 24, 2017 4:38 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Syntax error: there's no end to the function FormShow. That code shouldn't run in any CE version. Properly indenting your code would help you identify these errors and would help everyone read your code.
Code:
Deprecated Functions | Modern Equivalent

...
listitem_setCaption(listitem, str)                | listitem.Caption = str
...

You could look at main.lua (or perhaps celua.txt in the upcoming version) to find all this information.

This one gave me an error
Code:
listitem.Caption = "Level"


Thanks for the link. All those methods and properties will take some time to absorb.
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Mon Apr 24, 2017 4:45 pm    Post subject: Reply with quote

listitem probably isn't of type TListItem. It would be helpful if you said what the error was and where you're getting listitem from.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 24, 2017 5:28 pm    Post subject: Reply with quote

You listed that code in response earlier today, I just attempted to copy it.

My post was from another pc that still works so no error could be ascertained, however, back at pc with error. Changing to listitems resulted in the same error. You are probably correct that it may not be TListItem, whatever that may be.
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Mon Apr 24, 2017 5:37 pm    Post subject: Reply with quote

I detest people who just copy and paste others' code without even trying to learn from it, but whatever.
Code:
local item = listview1.Items.add()
item.Caption = 'Level'
item.SubItems.add('exp')

If you want more examples, use Google.

You should learn the basics of Lua before trying to make a trainer. For example, what variables are.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
bknight2602
Master Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 366

PostPosted: Mon Apr 24, 2017 6:01 pm    Post subject: Reply with quote

ParkourPenguin wrote:
I detest people who just copy and paste others' code without even trying to learn from it, but whatever.

Speculation on your part, I have learned quite a lot in the last few days and will continue to do so.
Quote:

Code:
local item = listview1.Items.add()
item.Caption = 'Level'
item.SubItems.add('exp')

If you want more examples, use Google.

Thanks for that code.

Again speculation, do you not think I scour Google for examples? You are mistaken as you have no idea what I do, but if it makes you feel good have at it.
Quote:


You should learn the basics of Lua before trying to make a trainer. For example, what variables are.

Wrong tense, they were made in previous versions, with help from people like you with old language as you should realize by now. It is incorrect if you think I don't know what a variable is(trivial example, I know). I truly am thankful to you for your suggestions and guidance but leave the attitude at the door. Thanks
Back to top
View user's profile Send private message Yahoo Messenger
ParkourPenguin
Grandmaster Cheater Supreme
Reputation: 54

Joined: 06 Jul 2014
Posts: 1814
Location: Arcadian Suburbia

PostPosted: Mon Apr 24, 2017 7:13 pm    Post subject: Reply with quote

After looking at the code you're writing, it's very difficult for me to believe that you know what you're doing.
Code:
local lvlitems1 = listview1.Items  -- lvlitems1 is declared but never used
local item1 listitem.add()         -- this is not syntactically correct, listitem was not defined, and item1 was never used
local subitems listitem.Subitems   -- ^, subitems is never used
listitem.Caption = "Level"         -- listitem was not defined
strings.add("exp")                 -- strings was never defined

In two of those statements, you forgot the assignment operator. Knowing how to declare and initialize a variable should be basic information.

In three of those statements, it seems like you copied what I wrote, pasted it somewhere in your code, and hoped that it worked. I apologize if what I wrote was too abstract, but by writing stuff like this:
Code:
listview_getItems(listview)  |  listview.Items
I expected you to understand that you should replace whatever identifier was in the parenthesis (e.g. "listview") with the identifier you were using (e.g. "listview1"). You did that for the first statement, but neglected that in the rest. Looking back, I really don't understand why you failed to do this in the others if you succeeded at first.

If these are just simple mistakes, that's an understandable reason. Every knowledgeable person was inexperienced and did stupid stuff at one point in time or another- myself included. Due to the amount of time I've seen you dedicate to Lua-related activities, I figured you should already know this information, so when I see stupid mistakes like this, my first thought is that you aren't trying to learn anything. If you truly are trying to learn, then I apologize for insinuating the contrary.

The main problem I have is that I don't like to give people the answer, because it usually doesn't do anything meaningful in the end. When code is handed out to most people, they don't learn anything about what the code is doing- they only develop the expectation that someone will give them whatever they want when they ask for it. I would rather have people figure out how to do it on their own. That way, they'll be able to rely on themselves the next time they have a problem, and may eventually go on to help others.

If you're one of the people that likes to learn through examples, I'm sure many other people will be happy to help, but I'm not going to do that anymore. You can use Google to find examples of most CE-related features. I found this post pretty quickly that shows the basic syntax of working with the items of a listview. Learn how to refine searches to find stuff faster (e.g. I almost always use site:forum.cheatengine.org when searching for CE-related stuff).

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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