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 


How to get text of subitems

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Sep 17, 2013 11:19 am    Post subject: How to get text of subitems Reply with quote

Hey there,
How can I get the text of subitems of an listitem object? (In ListView).

Code:
function Data:PraseData(Table)
   -- few steps before..
   for i=#Table,1,-1 do -- appending from the last to the first, since there's no autoscroll in ListView
      self[2][i] = {};
      self[2][i][1] = self.ListVI.add();
      self[2][i][1].Caption = Table[i][1];
      self[2][i][2] = self[2][i][1].getSubItems();
      self[2][i][2].cul1 = self[2][i][2].add("String1"); --Not the actual string, just as a example
      self[2][i][2].cul2 = self[2][i][2].add("String2"); --Not the actual string, just as a example
   end
   -- few steps after..
end


Doing
Code:
print(Data[2][1][2].Text)
--> String1 String2


Doing
Code:
local a,b = Data[2][1][2].Text
print(a)
--> String1 String2
print(b)
--> nil


How can I obtain for example only String1?
without having to write a script to separate both strings.

_________________
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
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Sep 17, 2013 11:34 am    Post subject: This post has 1 review(s) Reply with quote

SubItems is a Strings object
Code:


Strings Class: (Inheritance : Object) (Mostly an abstract class)
properties
  Text : String - All the strings in one string
  Count: Integer - The number of strings in this list
  String[]: String - Array to access one specific string in the list
  [] = String[]

methods
  clear() : Deletes all strings in the list
  add(string) : adds a string to the list
  delete(index) : Deletes a string from the list
  getText() : Returns all the strings as one big string
  setText() : Sets the strings of the given strings object to the given text (can be multiline)
  indexOf(string): Returns the index of the specified string. Returns -1 if not found
  insert(index, string): Inserts a string at a specific spot moving the items after it

  getCount(): Returns the number is strings in the list
  remove(string); Removes the given string from the list
  loadFromFile(filename) : Load the strings from a textfile
  saveToFile(filename) : Save the strings to a textfile

  getString(index) : gets the string at the given index
  setString(index, string) : Replaces the string at the given index


the Text property returns all the strings in one line
You want to use the line specific one
either [] or String[] or getString()

not sure if I fixed [] in the release but try
Code:

print(Data[2][1][2][0])

else
Code:

print(Data[2][1][2].String[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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Tue Sep 17, 2013 1:25 pm    Post subject: Reply with quote

Thanks for reply.
This
Code:

print(Data[2][1][2].String[0])

Worked, thanks again man.

_________________
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
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