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 search and jmp to the rhigt line of listbox by text?

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

Joined: 09 Mar 2012
Posts: 31

PostPosted: Sat Dec 08, 2018 5:39 pm    Post subject: how to search and jmp to the rhigt line of listbox by text? Reply with quote

i need to write some text in ceedit
and when i click the "search" button,the jmp to the line of the listbox



2018-12-09_073554.jpg
 Description:
 Filesize:  25.21 KB
 Viewed:  488 Time(s)

2018-12-09_073554.jpg


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 955

PostPosted: Sun Dec 09, 2018 2:37 pm    Post subject: Reply with quote

from celua.txt
Code:
ListBox Class: (Inheritance: WinControl->Control->Component->Object)
createListBox(owner): Creates a ListBox class object which belongs to the given owner. Owner can be any object inherited from WinControl

properties
  MultiSelect: boolean - When set to true you can select multiple items
  Items: Strings - Strings derived object containings all the items in the list <------------------
  Selected[] - Returns true if the given line is selected. Use Items.Count-1 to find out the max index
  ItemIndex: integer - Get selected index. -1 is nothing selected <------------------ presumably can set it as well
  Canvas: Canvas - The canvas object used to render on the object

methods
  clear()
  clearSelection() : Deselects all items in the list
  selectAll(): Selects all items in the list
  getItems(): Returns a strings object <------------------ alternative
  setItems(Strings): sets a strings object to the listbox
  getItemIndex()
  setItemIndex(integer) <------------------ alternative
  getCanvas()


Code:
Strings Class: (Inheritance : Object) (Mostly an abstract class)
properties
  LineBreak: String - the character(s) to count as a linebreak
  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
  beginUpdate() : Stops updates from triggering other events (prevents flashing)
  endUpdate(): call after beginUpdate


listbox.ItemIndex = listbox.Items.indexOf(ceedit.Text)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
cancandodo
Cheater
Reputation: 0

Joined: 09 Mar 2012
Posts: 31

PostPosted: Mon Dec 10, 2018 12:49 am    Post subject: Reply with quote

FreeER wrote:



listbox.ItemIndex = listbox.Items.indexOf(ceedit.Text)


it work correct!tks!!!

but this code have a problem

i must type full items'name,for e.x

type kobe→jump to the line "kobe" success
but i type "ko"or"be",→cannot jump
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 34

Joined: 09 Aug 2013
Posts: 955

PostPosted: Mon Dec 10, 2018 8:31 am    Post subject: Reply with quote

yep. For partial I suppose you could do something like
Code:

local first_match = true -- config to jump to first partial match or only unique matches
local partial = ceedit.text
local items = listbox.Items
local matches = {}
for i=0, items.Count-1 do
  if items[i]:match(partial) then
    matches[#matches+1] = i
  end
end
if #matches >0 and (first_match or #matches == 1) then
  listbox.ItemIndex = matches[1]
end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
cancandodo
Cheater
Reputation: 0

Joined: 09 Mar 2012
Posts: 31

PostPosted: Sat Feb 02, 2019 10:03 pm    Post subject: Reply with quote

FreeER wrote:
yep. For partial I suppose you could do something like
Code:

local first_match = true -- config to jump to first partial match or only unique matches
local partial = ceedit.text
local items = listbox.Items
local matches = {}
for i=0, items.Count-1 do
  if items[i]:match(partial) then
    matches[#matches+1] = i
  end
end
if #matches >0 and (first_match or #matches == 1) then
  listbox.ItemIndex = matches[1]
end


tks,but this code just jump the first result in the list,can not jump to the next line when i click the seach button


for ex

items of listbox is


kobe
o''neal
Jordan
LeBronJames
James Harden


when i type text "James" in ceedit,

then click the "jump" button

it only jump to the "LeBronJames" line

can not jump to the "James Harden" line ,

No matter how many times i click the botton
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