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 


Lua form not repainting?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Empyrial
How do I cheat?
Reputation: 0

Joined: 01 Apr 2015
Posts: 5

PostPosted: Thu Apr 02, 2015 9:11 pm    Post subject: Lua form not repainting? Reply with quote

First the code -
Code:
function CheckClick(sender)
  Form1.List.getItems().Clear()
  local address = Form1.Addr.Text
  local numitems = readInteger(address)
  Form1.Count.Caption = numitems
  local dec = tonumber(address,16)
  local pointer = dec - 0x04
  local hex = string.format('%x', pointer)
  Form1.AddAb.Caption = hex
  local Pointer = readInteger(hex)
  hex = string.format('%x', Pointer)
  dec = tonumber(hex,16) +0x10
  hex = string.format('%x', dec)
  Form1.PointerAddy.Text = hex
  local ListIndex = hex
  local offset = 0x04
  for i=0, 0 do
    offset = i*0x04
    dec = tonumber(ListIndex,16)+offset
    hex = string.format('%x',dec)
    showMessage("ListIndex - i="..i.." hex="..hex)
    Pointer = readInteger(hex)
    hex = string.format('%x',Pointer)
    showMessage("ListItemAddress = "..hex)
    dec = tonumber(hex,16)+0x2C
    hex = string.format('%x',dec)
    Pointer = readInteger(hex)
    hex = string.format('%x',Pointer)
    showMessage("EnemyPointer="..hex)
    getSubItems(hex)
  end
  Form1.update()

end
function getSubItems(address)
  local dec = tonumber(address,16)+0x50
  local hex = string.format('%x', dec)
  local Health = readInteger(hex)
  local Haddr = hex
  showMessage("Health="..hex.." Value="..Health)
  dec = tonumber(hex,16)+0x18
  hex = string.format('%x', dec)
  local Level = readInteger(hex)
  showMessage("Level="..hex.." Value="..Level)
  dec = tonumber(hex,16)+0xB4
  hex = string.format('%x', dec)
  local ST = readInteger(hex)
  local staddr = hex
  showMessage("Strength="..hex.." Value="..ST)
  local listi = Form1.List.Items.add()
  listi.getSubItems().add(address)
  listi.getSubItems().add(Health)
  listi.getSubItems().add(ST)
  listi.getSubItems().add(Level)
  listi.getSubItems().add(Haddr)
  listi.getSubItems().add(staddr)
  showMessage("Items: "..Form1.List.Items.getCount().." RecentAdd ="..listi.getSubItems().Text)
end

function onGo(sender)

end


Ok - I know this is ugly code - I don't care. All I need to do is have the list object update, and it currently doesn't All the show messages in there show me what I need them to show, so the data/action isn't the problem. Instead, the control on the form doesn't update. When the loop has run its course, and the update method (I've also tried repaint, and on both the list and the full form) is run, all I get is a blank space.

Is there something special I need to do to get my list object to paint? Something I need to call when a list object is added to make it show up in the listview?

Picture posted is of the form after execution. You can see all the fields filled in at the top, and nothing in the main window (where the list object is supposed to be).



CEForm.png
 Description:
 Filesize:  3.6 KB
 Viewed:  4153 Time(s)

CEForm.png


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

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

PostPosted: Fri Apr 03, 2015 3:39 am    Post subject: Reply with quote

you first need to add columns to the listview
you can do that using tbe designer or code (listview.Columns.add())

_________________
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
Empyrial
How do I cheat?
Reputation: 0

Joined: 01 Apr 2015
Posts: 5

PostPosted: Fri Apr 03, 2015 8:26 am    Post subject: Reply with quote

I was afraid of that.

The columns have been created in the editor. I think that means that I need to delete and recreate the whole object. I'll run a few tests tonight.

Am I also to understand that the show column headers variable should make it show those headers even without data in the table? That wasn't happening, obviously, so that should be an immediate red flag for me.

Thank you for the response. Good to know it wasn't my code, just something else I did wrong.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Fri Apr 03, 2015 8:29 am    Post subject: Reply with quote

Oh yes, make sure that the viewstyle property is set to vsReport
_________________
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
Empyrial
How do I cheat?
Reputation: 0

Joined: 01 Apr 2015
Posts: 5

PostPosted: Sat Apr 04, 2015 8:11 am    Post subject: Reply with quote

Thank you very much. Deleting and re-creating has fixed it. I now have a nice looking table.
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