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 


Need a couple of quick examples

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

Joined: 26 Sep 2016
Posts: 70

PostPosted: Sun Mar 18, 2018 7:03 am    Post subject: Need a couple of quick examples Reply with quote

Basically I managed to find the save data section on FFXV for Noctus right up to Iris (haven't gone as far as vesperpool yet) and the section for inventory stock/item IDs, the list of symbols generated from them is a tad large though and I'd rather switch to using a base pointer for each character/item section and load a small amount of data based on user selection, for characters I just need a dropdown list example whereas the items I'd like a ranged number with scroll buttons like in the below rough example.

+------+/\
| 13 |
+------+\/

There would also need to be a min/max for the number (i.e min=1,max=13 for royal weapons). The example will copied and modified to fit my script that generates a memory record for all the symbols generated from a list, thanks in advance

_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 18, 2018 7:37 am    Post subject: Reply with quote

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

properties
  Items: Strings - Strings derived object containings all the items in the list
  ItemIndex: integer - Get selected index. -1 is nothing selected
  Canvas: Canvas - The canvas object used to render on the object

methods
  clear()
  getItems()
  setItems()
  getItemIndex()
  setItemIndex(integer)
  getCanvas()
  getExtraWidth() : Returns the number of pixels not part of the text of the combobox (think about borders, thumb button, etc...)


pretty simple, to get the current selection use thecombobox.Items[thecombobox.ItemIndex], you can set a "OnChange" event handler using thecombobox.OnChange = function(sender) ... end (or do it in the editor of course).

As for the number selection, I don't believe CE has anything specifically for that, though you could use an edit box and a couple buttons that change the number when clicked (tonumber may be helpful) or just a combobox if you have a relatively small range.

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

Joined: 26 Sep 2016
Posts: 70

PostPosted: Sun Mar 18, 2018 9:12 am    Post subject: Reply with quote

Will that go into a memory record value?
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Mar 18, 2018 9:35 am    Post subject: Reply with quote

It's lua code for customizing a trainer/form (you did post in "Lua Scripting"). If you don't want a trainer/form then you're limited to the dropdown selection lists CE lets you create by right clicking and choosing "Set/Change dropdown selection options" also accessible as a StringList from each memory record via the DropDownList property (not documented in CE6.7s celua.txt file).
_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Sun Mar 18, 2018 10:04 am    Post subject: Reply with quote

Didn't know about the dropdownlist prop, I'll make use of that for now, incidentally that is most likely what I meant for noctus & co, I'll come back to proper forms when I have some more hacks added, for tonight however I have gospel then more playing/hacking. And before I forget, thanks :)
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
Back to top
View user's profile Send private message
zxuiji
Advanced Cheater
Reputation: 1

Joined: 26 Sep 2016
Posts: 70

PostPosted: Tue Mar 20, 2018 4:14 am    Post subject: Reply with quote

I presume I need createStringList() but when I looked around I couldn't find any examples (let alone decent) of createStringList() and it's usage, could you show me an example involving setting both the option text and option values and what function activates upon the value changing and what data it receives.

Edit: Would this be about right?
Code:
r.NewSymbols = function(desc,x)
  x.mr.OnActivate = function(mr,b4,cur)
    if x.menu then
      local drop = mr.DropDownList
      if drop.ItemIndex > 0 then
        sym[desc].o.v = x.menu[drop.Items[drop.ItemIndex]]
      else
        sym[desc].o.v = x.menu[drop.Items[0]]
      end
    end
    r.LocSymbols(desc)
    return true
  end
  x.mr.OnDestroy = function(mr)
    r.DelSymbols(desc)
  end
  local mr = r.NewRecord('#' .. desc,false)
  mr.Address = desc
  mr.Type = x.type
  mr.appendToEntry(x.mr)
  if x.menu then
    x.mr.DropDownList = createStringList()
    local count = 0
    for d,v in next,x.menu do
      x.mr.Items[count] = d
      count = count + 1
    end
  end
  for i,d in next,x.s do
    local v = sym[d]
    v.mr = r.NewRecord(d,v.s~=nil)
    v.mr.appendToEntry(x.mr)
    if v.s then
      r.NewSymbols(d,v)
    else
      v.mr.Address = d
      v.mr.Type = v.type
      v.OnDestroy = function()
        sym[d].mr = nil
      end
      if v.type == vtCustom then
        v.mr.CustomTypeName = v.ctype
      end
      sym[d] = v
    end
  end
  sym[desc] = x
end
[/code]
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Mar 20, 2018 6:39 am    Post subject: Reply with quote

You don't need to create a stringlist, mr.DropDownList is a string list (even if it's empty). But here's a basic example: https://github.com/FreeER/CE-Examples/blob/master/DropDownList%20-%20MemoryRecord.CT

As for when the mr value changes, the only thing I know of is mr.OnGetDisplayValue

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

Joined: 26 Sep 2016
Posts: 70

PostPosted: Tue Mar 20, 2018 1:25 pm    Post subject: Reply with quote

That helped greatly, I modified a few bits of my code and I now have auto generated drop lists based on symbol data, got a different issue cropping up atm now which seems to source from this function:
Code:

r.Symbols = function(a,d,s,spaces)
  local l = {}
  local k = 0
  local nd = d + 1
  local x = sym[a[d]]
  spaces = (spaces or '')
  --print(spaces .. 'Symbols("' .. (desc or 'nil') .. '")')
  for i,v in next,s do
    k = k + 1
    a[nd] = a[d] .. i
    local nv = { desc = a[nd] }
    if type(v) == 'number' or type(v) == 'string' then
      nv.o = r.Offset(a,nd,v)
      nv.srBeg = x.srBeg
      nv.srEnd = x.srEnd
      nv.type = x.type
      nv.ctype = x.ctype
    else
      -- Force object for faster processing
      nv.o = r.Offset(a,nd,v.o or 0)
      --print( spaces .. 'nv.desc = ' .. a[nd] )
      nv.bytes = v.bytes
      nv.srBeg = (v.srBeg or x.srBeg)
      nv.srEnd = (v.srEnd or x.srEnd)
      nv.type = (v.type or x.type)
      if nv.type == vtCustom then
        nv.ctype = (v.ctype or x.ctype)
      end
      nv.menu = v.menu
      nv.s = v.s
    end
    nv.p = nv.srBeg
    l[k] = a[nd]
    sym[a[nd]] = nv
    if nv.s then
      r.Symbols(a,nd,nv.s,spaces .. ' ')
    end
  end
  x.s = l
  sym[a[d]] = x
end
which is first called like this:
Code:
r.Symbols({'s'},1,r.s)

Couldn't spot the core of the problem but this is what prints on my console in my attempt to diagnose the issue:
Code:

OnActivate() s
LocSymbol(nil) Possible Problems:
> Forgotten "." in offset name
> Forgotten "else" condition
> Forgotten " = function"
> Renamed symbol but forgot to update offset names
Deafulting to symbol "s"
Error:[string "local zFormat = string.format
..."]:494: attempt to index a string value (local 'v')
OnActivate() s
LocSymbol(nil) Possible Problems:
> Forgotten "." in offset name
> Forgotten "else" condition
> Forgotten " = function"
> Renamed symbol but forgot to update offset names
Deafulting to symbol "s"
Error:[string "local zFormat = string.format
..."]:494: attempt to index a string value (local 'v')

LocSymbol() looks like this:
Code:
r.LocSymbol = function(desc)
  local v = sym[desc]
  if v == nil then
    if desc == nil then
      print( 'LocSymbol(nil) Possible Problems:' )
    else
      print( 'LocSymbol("' .. desc .. '") Possible Problems:' )
    end
    print( '> Forgotten "." in offset name' )
    print( '> Forgotten "else" condition' )
    print( '> Forgotten " = function"' )
    print( '> Renamed symbol but forgot to update offset names' )
    print( 'Deafulting to symbol "s"' )
    v = 's'
  end
  local x = sym['s']
  local w = x
  if v.o then
    w = sym[v.o.i]
    x = r.LocSymbol(v.o.i)
  end
  if v.p == nil or x.p ~= w.p or
    v.p <= v.srBeg or
    v.p >= v.srEnd or
    (v.bytes and ceRdAOB(v.p) ~= v.bytes) then
    if v.o then
      local x = r.LocSymbol( v.o.i )
      local a = zAddr( x.p, v.o.v )
      for i = 1, v.o.p do
        a = ceRdPtr( a )
      end
      v.p = a
    elseif v.bytes then
      v.p = ceScanRegion( desc, v.bytes, v.srBeg, v.srEnd )
    else
      v.p = zHex2Num(v.srBeg)
    end
    ceSymbol(desc,v.p)
  end
  sym[desc] = v
  return v
end
If you can spot the issue please point it out to me

[b]Found the cause, shoulda set v to sym['s'] in LocSymbol() when defaulting to the s symbol, however I'm now starting to get to the bottom of a long standing issue that been wanting to fix but couldn't identify the source, makes me think of the saying "failure is the mother of success"

_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
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