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 


Help with a simple lua script?

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

Joined: 20 Dec 2019
Posts: 17

PostPosted: Thu Jan 11, 2024 6:04 pm    Post subject: Help with a simple lua script? Reply with quote

Hi,
I'm trying to write a simple lua script (which I cannot do so) to be able to save my table settings.

My table looks like this:
Code:
https://ibb.co/3FPxXXK


and I have a drop down list like this:
Code:
https://ibb.co/QbRFmJV


Whenever I select what I want and where I want it then I close the game/table it will reset back to everything being "Empty" instead of what I chose for each one.

I've been trying for the past 2 days to figure this out and 90% of what I find is about trainers and not tables. I copied some of the sample codes they listed, but cannot get it to work in the main.lua file of CE. I keep getting syntax errors.

Could anyone please write me a simple code so that I can see how it actually works? One that works with my table, I mean?

Here is some that I have, but doesn't seem to work inside the main.lua file.

settings=getSettings('nameofmygameortable?') // <-- Do I put my table or game name here?

if [1] ID = settings.Value['Empty'] ~= nil then
[1] = settings.Value['Coins']
[2] ID = settings.Value['Bones']
UDF1.CE[3] ID.caption = settings.Value['Iron Ore']
end
end

EDIT: Ok, so I managed to get rid of the syntax errors, but it still doesn't change my drop down list...

settings=getSettings('MyTable')
settings.Value['Empty']=0
settings.Value['Coins']=1
settings.Value['Bones']=2
settings.Value['Iron Ore']=3
settings.Value['Metal Flint']=4
settings.Value['Dwarven Stone']=5

settings=getSettings('MyTable')
ID1=tonumber(settings.Value['Coins'])
if ID1==settings.Value['Empty'] then ID1=settings.Value['Coins']
end

Both of these bottom lines work, but neither one will actually change it inside the table... why?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Fri Jan 12, 2024 11:20 am    Post subject: Reply with quote

I don't understand exactly what you want or what you are trying to change.

You can use the code below and evaluate what you need.

Don't forget to add a few things to the address list.
All registration, upload and exchange were associated with the address list.

Code:
tbl = {}
if frm1 then frm1.Destroy() frm1=nil end
frm1 = createForm()
frm1.height = 300;
frm1.width = 680;
frm1.Position="poDesktopCenter"
tbl.listview1 = createListview(frm1)
local list1 = tbl.listview1
list1.height = 240;
list1.width = 210;
list1.top = 40;
list1.left = 20;
list1.colum1 = list1.getColumns().add()
   list1.colum1.Width = 100;
   list1.colum1.Caption = 'Desc.';
   list1.colum2 = list1.getColumns().add()
   list1.colum2.Width = 90;
   list1.colum2.Caption = 'Value';

tbl.listview2 = createListview(frm1)
local list2 = tbl.listview2
list2.height = 240;
list2.width = 210;
list2.top = 40;
list2.left = 250;
list2.colum1 = list2.getColumns().add()
   list2.colum1.Width = 100;
   list2.colum1.Caption = 'Desc.';
   list2.colum2 = list2.getColumns().add()
   list2.colum2.Width = 90;
   list2.colum2.Caption = 'Value';

b1 = createButton(frm1)
b1.height = 30
b1.width = 210;
b1.Top=5 b1.Left=20
b1.Caption="Load Settings"

b2 = createButton(frm1)
b2.height = 30
b2.width = 210;
b2.Top=5 b2.Left=250
b2.Caption="Load AddressList"

tbl.CBox1 = createComboBox(frm1)
tbl.CBox1.AutoSize=false
tbl.CBox1.Left=480 tbl.CBox1.Height=30 tbl.CBox1.Top=7 tbl.CBox1.Width=180
tbl.CBox1.Font.Height=-13 tbl.CBox1.Font.Size=10 tbl.CBox1.Font.Style='fsBold'
tbl.CBox1.ReadOnly=true
tbl.CBox1.Style='csDropDownList'

tbl.Edt1 = createEdit(frm1)
tbl.Edt1.AutoSize=false
tbl.Edt1.Left=480 tbl.Edt1.Height=30
tbl.Edt1.TextHint='New Value?'
tbl.Edt1.Top=50 tbl.Edt1.Width=180
tbl.Edt1.Color=16776960 tbl.Edt1.Font.Size=10

b3 = createButton(frm1)
b3.height = 30
b3.width = 180;
b3.Top=100 b3.Left=480
b3.Caption="Change  Value"

--##############################################--
--##############################################--

settings=getSettings('MyTable')
setTbl = {'Empty','Coins','Bones','Iron Ore','Metal Flint','Dwarven Stone'}
alist = getAddressList()
local addrIndex = 0

 for k,l in pairs(setTbl) do
  tbl.CBox1.Items.Add(l)
 end

function saveValue()
local i = 0
list2.Clear()
 for k,l in pairs(setTbl) do
   settings.Value[l]=alist[i].Value

  local entry = list2.getItems().add();
   entry.Caption = alist[i].Description
   entry.getSubItems().add(alist[i].Value)
   i = tonumber(i) + 1
 end
end

function loadValue()
local i = 0
 for k,l in pairs(setTbl) do
  local entry = list1.getItems().add();
   entry.Caption = l
   entry.getSubItems().add(settings.Value[l])
   i = tonumber(i) + 1
 end
end

b1.OnClick=function()
loadValue()
end

b2.OnClick=function()
saveValue()
end

-- select list and addr lis index..

tbl.CBox1.OnChange=function()
 local index = tbl.CBox1.ItemIndex
 addrIndex = tonumber(index)
 print(addrIndex)
end

-- change addr list value

b3.OnClick=function()
 if tbl.Edt1.Text=="" then
   showMessage("Please type the new value in the box above.")
 else
  if addrIndex==0 then -- Prohibit writing to index "0"!
    showMessage("Please make a selection from the relevant drop-down list.")
  else
    alist[addrIndex].Value = tbl.Edt1.Text
  end
 end
 tbl.Edt1.Text=""
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Fri Jan 12, 2024 9:11 pm    Post subject: Reply with quote

Hi, thank you for the reply. I'll try to explain it carefully. I figured it was quiet simple, but maybe I'm wrong...

I have a table that I added a lot of drop down list items (71 to be exact) to select from. If I select my drop down list and put the item that I want on each line (71 of them) and then close my game / table it will all reset to 0:Empty instead of saving what I selected on each one.

Is there a way to save my drop down list selection so that I don't have to input them each time I play the game?

I read that you could do so in menu.lua, however I cannot figure the coding out. Most of what I find is all about trainers and not tables. Can I do this in the menu.lua or if not, how do I do this if it's possible?

Here is some of what I have in the drop down menu to select from to give you and idea:
0:Empty
1:Coins
2:Bones
3:Iron Ore
4:Metal Flint
5:Dwarven Stone
6:Ancient Tablet
7:Wood
8:Inscribed Rupture Quartz
9:Cloth
10:Plank
11:Iron Ingot
12:Fiber
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Sat Jan 13, 2024 6:06 am    Post subject: Reply with quote

Code:
function crtMySetting()
frmTbl1 = {}

if frm1 then frm1.Destroy() frm1=nil end
frm1 = createForm()
frm1.height = 240;
frm1.width = 240;
frm1.Position="poDesktopCenter" frm1.Caption="Metarial List"
frm1.PixelsPerInc = 96
frm1.ShowInTaskBar = "stAlways"
frm1.PopupMode = 0 -- or 1 (stDefault)

b1 = createButton(frm1)
b1.height = 30
b1.width = 200;
b1.Top=20 b1.Left=20
b1.Caption="Load Index"

b2 = createButton(frm1)
b2.height = 30
b2.width = 200;
b2.Top=190 b2.Left=20
b2.Caption="Save Index"

frmTbl1.CBox1 = createComboBox(frm1)
frmTbl1.CBox1.AutoSize=false
frmTbl1.CBox1.Left=20 frmTbl1.CBox1.Height=30 frmTbl1.CBox1.Top=75 frmTbl1.CBox1.Width=200
frmTbl1.CBox1.Font.Height=-13 frmTbl1.CBox1.Font.Size=10 frmTbl1.CBox1.Font.Style='fsBold'
frmTbl1.CBox1.ReadOnly=true
frmTbl1.CBox1.Style='csDropDownList'

frmTbl1.CBox2 = createComboBox(frm1)
frmTbl1.CBox2.AutoSize=false
frmTbl1.CBox2.Left=20 frmTbl1.CBox2.Height=30 frmTbl1.CBox2.Top=110 frmTbl1.CBox2.Width=200
frmTbl1.CBox2.Font.Height=-13 frmTbl1.CBox2.Font.Size=10 frmTbl1.CBox2.Font.Style='fsBold'
frmTbl1.CBox2.ReadOnly=true
frmTbl1.CBox2.Style='csDropDownList'

frmTbl1.CBox3 = createComboBox(frm1)
frmTbl1.CBox3.AutoSize=false
frmTbl1.CBox3.Left=20 frmTbl1.CBox3.Height=30 frmTbl1.CBox3.Top=145 frmTbl1.CBox3.Width=200
frmTbl1.CBox3.Font.Height=-13 frmTbl1.CBox3.Font.Size=10 frmTbl1.CBox3.Font.Style='fsBold'
frmTbl1.CBox3.ReadOnly=true
frmTbl1.CBox3.Style='csDropDownList'

--##############################################--
--##############################################--

settings=getSettings('MyTable')
setfrmTbl1 = {'Empty','Coins','Bones','Iron Ore','Metal Flint','Dwarven Stone',"Ancient Tablet","Wood","Inscribed Rupture Quartz","Cloth","Plank","Iron Ingot","Fiber"}

 for k,l in pairs(setfrmTbl1) do
   for i=1, 3 do
    frmTbl1["CBox"..i].Items.Add(l)
   end
 end

function saveIndex()
 for i=1, 3 do
   settings.Value["CBox"..i]=frmTbl1["CBox"..i].ItemIndex
 end
end

function loadIndex()
 for i=1, 3 do
   if settings.Value["CBox"..i]~=nil then
     frmTbl1["CBox"..i].ItemIndex = settings.Value["CBox"..i]
   end
 end
end

b1.OnClick=function()
loadIndex()
end

b2.OnClick=function()
saveIndex()
end

 for i=1, 3 do
   frmTbl1["CBox"..i].OnChange=function()
    saveIndex()
   end
 end
 frm1.OnClose=function()
  saveIndex()
  frm1.Hide()
 end

 loadIndex() -- When the form is activated, all registered indexes are loaded.
end

mf11 = MainForm
mMenu11=mf11.Menu.Items

if saveLoadIndex1 then saveLoadIndex1.Destroy() saveLoadIndex1=nil end
saveLoadIndex1=createMenuItem(mf11.mMenu11)
saveLoadIndex1.Caption="SelectName?"
menuItem_setShortcut(saveLoadIndex1,"Ctrl+I")

mMenu11.insert(mMenu11.Count-1, saveLoadIndex1)
saveLoadIndex1.OnClick = crtMySetting



ek1.PNG
 Description:
 Filesize:  34.17 KB
 Viewed:  7766 Time(s)

ek1.PNG



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Sun Jan 14, 2024 4:45 pm    Post subject: Reply with quote

First of all thank you for all your effort and time, I really do appreciate it!

I've used your lua codes, however I don't quiet understand them fully. I get the pop up window, but it only has 3 slots to put stuff. Is this for each address that I highlight? It's it only 3 materials select out of the 71 total?

Oh and can I add the other 68 materials to the list as well? Do I put " or ' because I noticed that you have both?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Sun Jan 14, 2024 7:29 pm    Post subject: Reply with quote

Since I wasn't sure what you wanted, I gave examples so you can pick what works for you.

I have to ask a few questions;

1) In my last code I used 3 ComboBoxes containing your entire list (The list you last gave.)
You want this in 71 pieces instead of 3?

2) You never mentioned the address list.
a) Do you record the address activation in the table, whether it is empty or full, and want it to be the same on reloading?
b) How does your dropdown list or ComboBox have to do with the address list?
c) I won't ask about the "[..] IDs" how you managed to write string/text to a 4 byte registered address.
Are "[..] IDs" required in your list? Or are you just using subregisters in the game?

3) Does the ComboBox in the table in the second picture in your first post have 71 items?

4) Do you want to add a new entry to your drop-down list or delete the existing entry and save the last list?

5) If there is a code similar to the question you asked in the code examples I gave, how would you use it or is it possible to copy and share which part it is?

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Sun Jan 14, 2024 9:01 pm    Post subject: Reply with quote

They're 71 different materials that I have addresses (pointers) for in the drop down list. I only listed a few to give you an idea of what I was doing. Can I post screenshots here or send them to you?

I'm very limited on knowledge when it comes to this as I am just now learning.. So, I didn't actually make / write or whatever needs to be done with the drop down menu, I copied it from another table and somehow it worked and I don't see any script(s) or lua coding anywhere... makes no sense to me, but it does in fact work.

Let me post some of it to you and you see.... I right mouse clicked on the table and opened in notepad++...

This said I wasn't able to post url's / screenshots or talk about such things on here yet but if somehow I can get them to you or the table itself I will, to give you a better outlook if this doesn't make sense.

Again, I posted on several forums and you're the only one to write me back and I am VERY much appreciated of your time and effort!
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Mon Jan 15, 2024 4:35 am    Post subject: Reply with quote

Ok. Thanks for your kindness.
CEF leaves no logical question unanswered or unresolved.

CE has a menu option like this; Save the table (table with .CT extension) and continue to use the saved address pointers when you open it again.

Your drop-down list contains only material names, no addresses, pointers, or new values for replacement.
What is the benefit of a list with only material names in this case?

Let's throw away the code examples I gave, what exactly do you want to save and restore?

1) I want to save and load the current address list addresses and pointers.

2) I want to transfer the addresses and pointers from the address list to the drop-down list.

3) When I select the process of my game in CE, I want my table or table to be automatically added (loaded) to the address list or drop-down list.

4) I want to edit the material names in my drop-down list and save and load the final layout.

5) All of them. Smile

7) None. Smile

Cool I want to do it step by step like this. I open my table...

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Mon Jan 15, 2024 5:25 am    Post subject: Reply with quote

Oh wow!

Ok, so I have the pointers to everything and saved. Those work.

One thing that I should mention about this game. It has a set of addresses, 1-71 (what I use to get the materials) and it works like this: Whichever material that you loot next is what gets the next address. Meaning that if I loot "Coins" first it gets assigned to the first address. If I look "Wood" first it gets signed to the first address and so on... If you create a new character then there is no way to predict which material you'll loot next... It could be different each character if that makes sense. If each material had it's own address this wouldn't be an issue, but that is why I needed the drop down menu with each material on each address.

1) I want to save and load the current address list addresses and pointers. <--- I figured this out already and have pointers saved.

2) I want to transfer the addresses and pointers from the address list to the drop-down list. <-- Not quiet sure how this would work being that I have 2 addresses. One for the name and One for the address.

3) When I select the process of my game in CE, I want my table or table to be automatically added (loaded) to the address list or drop-down list. <--- I *THINK* this is what I'm looking for here. When I select the process to start the game for the day, I want it to automatically load the drop down list that I save, if that is possible.

4) I want to edit the material names in my drop-down list and save and load the final layout. <--- I created the drop down menu names and already know this part.

I think all I need is number 3, please -- To save my drop down list and reload it each time.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Wed Jan 17, 2024 1:05 pm    Post subject: Reply with quote

Don't despair because I'm late.
I'm just not at home and can use the time I have left from work.

I will offer you two separate codes, use the one that works for you.
(I think the second code will be more attractive because if your CE-Lua knowledge is weak, you may have difficulty in editing it to your liking.
If you're not satisfied with the current state, my next code will be a little more global.
Namely; Transfer all the addresses in the address list to a form list, write the current value next to it (Label), create a box to write the new value (EditBox), and leave a button at the end to replace it with the new value.
If there is a wish, let this be my next project.)

Code 1:
You can leave the following code in a file with the ".lua" extension in the CE-->autorun folder, and when you select the game process, you can open and use the table with the .CT extension.

Code:
if prcTim1 then prcTim1.Destroy() prcTim1=nil end
prcTim1=createTimer(MainForm)
prcTim1.Interval = 1000

local checkPrc = 0

prcTim1.OnTimer=function()
proc=getProcessIDFromProcessName("notepad.exe") -- edit your game.exe
 if getOpenedProcessID()==proc then
 --print(getOpenedProcessID(),getProcessIDFromProcessName("notepad.exe"))
   if checkPrc==0 then
    shellExecute([[C:\My Cheat Tables\yourCheatTableName.CT]])
    checkPrc=1
   end
 else
 checkPrc=0
  --showMessage("Error! The game is not open!")
 end
 collectgarbage("count")
end

prcTim1.Enabled = true


Code 2:
In this case, I quoted code ideas from @DarkByte and @ParkourPenguin (I've never had much to do with address lists in my entire life).

The only changes that can be made to your drop-down list are that you can save the address list with the "Save" button and update your address list and drop-down list with the "Upload" button.
Value change is only possible in the address list.
(The next project I mentioned above will make it possible to list and change this in the form.)

Copy the code --> paste it into a blank .txt file --> select "save as" --> give it a name and write .lua at the end.
CE --> Put this lua file into the autorun folder.

Beforehand, add other materials to the table in the same way as I added a few materials.

I used the notebook process as a basis to try it out.
When you're done trying, type the name of your game "process.exe" instead of "notepad.exe" and edit it.

Code:
function crtMySetting()
frmTbl1 = {}

if frm1 then frm1.Destroy() frm1=nil end
frm1 = createForm()
frm1.height = 340;
frm1.width = 340;
frm1.Position="poDesktopCenter" frm1.Caption="Metarial List"
frm1.PixelsPerInc = 96
frm1.ShowInTaskBar = "stAlways"
frm1.PopupMode = 0 -- or 1 (stDefault)

frmTbl1.bt1 = createButton(frm1)
frmTbl1.bt1.height = 30
frmTbl1.bt1.width = 300;
frmTbl1.bt1.Top=10 frmTbl1.bt1.Left=20
frmTbl1.bt1.Caption="Load Index"

frmTbl1.bt2 = createButton(frm1)
frmTbl1.bt2.height = 30
frmTbl1.bt2.width = 300;
frmTbl1.bt2.Top=290 frmTbl1.bt2.Left=20
frmTbl1.bt2.Caption="Save Index"

frmTbl1.listview1 = createListview(frm1)
local list1 = frmTbl1.listview1
list1.height = 220;
list1.width = 300;
list1.top = 60;
list1.left = 20;
list1.colum1 = list1.getColumns().add()
   list1.colum1.Width = 150;
   list1.colum1.Caption = 'Desc.';
   list1.colum2 = list1.getColumns().add()
   list1.colum2.Width = 170;
   list1.colum2.Caption = 'Address';

--##############################################--
--##############################################--

settings=getSettings('MyTable')
setfrmTbl1 = {'Empty','Coins','Bones','Iron Ore','Metal Flint','Dwarven Stone',"Ancient Tablet","Wood","Inscribed Rupture Quartz","Cloth","Plank","Iron Ingot","Fiber"}

alist = getAddressList()
local addrstr = ""
-- save ...

function parseAddress(i)
local result = ""
local addressstring=''
    local mr=alist[i]
result=result..mr.Description.."@@@"
    address, fulladdress=memoryrecord_getAddress(mr)

   if fulladdress~=nil then
      --first build up the [ characters
      for j=1,#fulladdress-1 do
        addressstring=addressstring..'['
      end
      addressstring=addressstring..getNameFromAddress(fulladdress[1])..']+'

      for k=2,#fulladdress do
        addressstring=addressstring..string.format('%x', fulladdress[k])
        --print("addressstring: "..addressstring)
        if k~=#fulladdress then
          addressstring=addressstring..']+'
        end
      end
    addrstr = addressstring
    else
      addressstring=getNameFromAddress(address)
    end
    result=result..addressstring.."@@@"
    result=result..mr.Type.."@@@"
    result=result..mr.Color
    addressstring=""
  return result
end

local indx = 0

function checkAddr(i,mr)
local rst = ""
      l = setfrmTbl1[tonumber(indx)]
    address, fulladdress=memoryrecord_getAddress(mr)
     if fulladdress~=nil then
      indx = tonumber(indx) + 1
       rst = parseAddress(i)
        if l~=nil then
         settings.Value[l]=rst
        end
      local entry = list1.getItems().add();
      entry.Caption = l
      entry.getSubItems().add(addrstr)
     else
      rst = parseAddress(i)
        if l~=nil then
         settings.Value[l..indx]=rst
        end
     end
return rst
end

function saveValue()
list1.Clear()
indx = 1
 for i=2, alist.Count -1 do
    l = setfrmTbl1[(tonumber(indx))]
    local mr=alist[i]
    rst1 = checkAddr(i,mr)
  end
end

-- Loads ...

local subHeader = ""
local memrec = ""

function startMain1()
local mainHeader = alist.createMemoryRecord()
mainHeader.IsAddressGroupHeader = false
mainHeader.Options = '[moManualExpandCollapse]'
mainHeader.Description = "Craftng Metarials The names can change.."
mainHeader.Color = 0x00ff00
  subHeader = alist.createMemoryRecord()
  subHeader.appendToEntry(mainHeader)
  subHeader.IsAddressGroupHeader = false
  subHeader.Options = '[moManualExpandCollapse]'
  subHeader.Description = "Note you must obtain at least one of.."
  subHeader.Color = 0xffff00
end

function startGroup1(addr,desc,typ,clr)
    memrec = alist.createMemoryRecord()
    memrec.appendToEntry(subHeader)
    memrec.IsAddressGroupHeader = true
    memrec.Address = addr
    memrec.Type = tonumber(typ)
    memrec.Description = desc
    memrec.Color = clr
end

function OffCount(addr)
   local i=0
    for w in string.gmatch(addr, "%]%+%w+") do
     i = tonumber(i) + 1
    end
return i
end

function startChild1(addr,desc,typ,clr)
local i = 0
--print(2,addr,desc,typ,clr)
  local child1 = alist.createMemoryRecord()
  child1.appendToEntry(memrec)
  child1.Address = addr
    child1.OffsetCount = OffCount(addr)
    for w in string.gmatch(addr, "%]%+%w+") do
     w1 = (w):match("%]%+(.*)")
     --print(w1)
     child1.setOffset(i, "0x"..w1)
     i = tonumber(i) + 1
    end
    child1.Type = tonumber(typ)
    child1.Description = desc
    child1.Color = clr
end

function alistClear()
lst = alist[0]
 if lst~=nil then
  for i=0, alist.Count -1 do
    addrCnt = addresslist_getCount(alist)
    if addrCnt>0 then
     memoryrecord_delete(addresslist_getMemoryRecord(alist, 0))
    end
  end
 end
end

function loadValue()
alistClear()
startMain1()
list1.Clear()
 for k,l in pairs(setfrmTbl1) do
  res1 = (settings.Value[l..k])
  res2 = (settings.Value[l])
     local desc1,addr1,typ1,clr1 = string.match(res1,"(.-)@@@(.-)@@@(.-)@@@(.*)")
     local desc2,addr2,typ2,clr2 = string.match(res2,"(.-)@@@(.-)@@@(.-)@@@(.*)")

     startGroup1(addr1,desc1,typ1,clr1)
     startChild1(addr2,desc2,typ2,clr2)
     local entry = list1.getItems().add();
     entry.Caption = l
     entry.getSubItems().add(addr2)
 end
end

--#####################################################--
--#####################################################--

 for k,l in pairs(setfrmTbl1) do
     local entry = list1.getItems().add();
     entry.Caption = l
 end

frmTbl1.bt1.OnClick=function()
loadValue()
end

frmTbl1.bt2.OnClick=function()
saveValue()
end

frm1.OnClose=function()
saveValue()
frm1.Hide()
end
end

--#####################################################--
--#####################################################--
--#####################################################--

if prcTim1 then prcTim1.Destroy() prcTim1=nil end
prcTim1=createTimer(MainForm)
prcTim1.Interval = 1000

local checkPrc = 0

prcTim1.OnTimer=function()
proc=getProcessIDFromProcessName("notepad.exe") -- edit your game.exe
 if getOpenedProcessID()==proc then
 --print(getOpenedProcessID(),getProcessIDFromProcessName("notepad.exe"))
   if checkPrc==0 then
    crtMySetting()
    checkPrc=1
   end
 else
 checkPrc=0
  --showMessage("Error! The game is not open!")
 end
 collectgarbage("count")
end

prcTim1.Enabled = true


You can edit the form according to your needs.

If there is anything you want to ask or are stuck on, you can ask.
Also, as @mgr.inz.Player said, "Write an answer without quoting the entire code".
If we adopt this idea, we will take up less space in the forum lines. Wink

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Wed Jan 17, 2024 7:53 pm    Post subject: Reply with quote

Thank you very much for this!! No worries about the being late part, I understand you have a life and cannot be here 24/7 Razz I'm going to try to learn this for myself.

I have a few questions regarding both codes...

1) On the top table can I change the "C:\My Cheat Tables\yourCheatTableName.CT" to another location? Also do I put a .ct cheat table in here or a .lua or .txt? When I make it do I just put the drop down list or the entire .ct cheat table?

2) On the top table would it be like this? ("ProjectAlpha-Win64-Shipping.exe"+06A0A988) -- and do I put anything in "count" on this one? collectgarbage("count")

3) On the bottom code you have the first six with ' and the rest with " > which would I use (example a) or b)) to add the rest?
a) 'Plank', 'Iron Ingot', etc
or
b) "Fire Shards", "Goblet Scraps", etc
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Thu Jan 18, 2024 12:55 am    Post subject: Reply with quote

1) Take the path of wherever you saved your .CT table and change it in the code.
Right click on your registered .CT, select "Properties", you can get the full path in the "General" tab from the menu.
Replace the path I gave as an example in the code with it.

2) ("ProjectAlpha-Win64-Shipping.exe") this should be it.
Take whatever full name appears when you select the game process in CE and add it.
"+06A0A988" I think this is the memory you are working with in the code after the process is selected.
(The same name.exe is valid in both codes)

3) I don't understand this.
Your entire list in code,
setfrmTbl1 = {'Empty','Coins','etc.','etc.'}
list into this table.

For the second code:
Copy the code, open the current page containing the addresses, open a new tab from the lua script cheat table menu and paste the code.
Edit code: Add your entire list to the table.
Replace notepad.exe with game process.
Now run the code.
To connect the DT to the game, select your game from the process list.
You probably won't reply "yes" to the warning and have your address list deleted.
Click the "Save" button on the opened form and then click the "Load" button.

If everything went well, you will see the code on first use and know what it does.
If that's what you want, copy the last edit, put it in a .lua file, and drop it into the CE autorun folder.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Enferno33
Newbie cheater
Reputation: 0

Joined: 20 Dec 2019
Posts: 17

PostPosted: Thu Jan 18, 2024 6:09 am    Post subject: Reply with quote

Thanks again!!

The first code keeps opening a new CE.exe with the table over and over every time I select the process. I'm not even sure why this would be necessary? ..

The second code opens up a window when I launch the process. When I click save it puts addresses up with I'm assuming the offsets? .. I'm guessing that whatever line I choose to type which material will save this and then when I click load it will load the last list that I selected?

Either way, I think the second one will work if it works like this. I will play around with it more and see if it works like this.

Again, thank you very much for all of your time and effort, this is way more than I could have ever asked for and I am very grateful!!
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1480

PostPosted: Thu Jan 18, 2024 12:55 pm    Post subject: Reply with quote

Enferno33 wrote:
The first code keeps opening a new CE.exe with the table over and over every time I select the process. I'm not even sure why this would be necessary? ..


Ah.. It's my fault. I wrote the code hypothetically.
I haven't tried that.
Here is the edited and tested code below.
Note: While this code is running, CE may also react the same and ask to load your associated .CT table. Ignore it with "No", close it.

Of course, edit the folder path, name of the .CT and the game .exe process name.
Code:
if prcTim1 then prcTim1.Destroy() prcTim1=nil end
prcTim1=createTimer(MainForm)
prcTim1.Interval = 1000

local checkPrc = 0
local mytblPath1 = [[C:\Users\My Cheat Table\]] -- edit your table path
local mytableName1 = "myGameTable.CT" -- edit your table name
local myGameProc1 = "notepad.exe" -- edit your game process .exe

prcTim1.OnTimer=function()
      local mf12 = MainForm
      local sd = mf12.SaveDialog1.FileName
      local od = mf12.OpenDialog1.FileName
       if sd==mytableName1 or od==mytableName1 then
        checkPrc=1
       else
        proc=getProcessIDFromProcessName(myGameProc1) -- edit your game.exe
         if getOpenedProcessID()==proc then
         --print(getOpenedProcessID(),getProcessIDFromProcessName(myGameProc1))
           if checkPrc==0 then
            checkPrc=1
            shellExecute(mytblPath1..mytableName1)
           end
         else
           checkPrc=0
           --showMessage("Error! The game is not open!")
         end
       end
 collectgarbage("count")
end

prcTim1.Enabled = true


Enferno33 wrote:
The second code opens up a window when I launch the process. When I click save it puts addresses up with I'm assuming the offsets? .. I'm guessing that whatever line I choose to type which material will save this and then when I click load it will load the last list that I selected?

Either way, I think the second one will work if it works like this. I will play around with it more and see if it works like this.


My goal from the beginning was to give you sample codes and the reactions it triggers.
It's up to you to use the entire code or edit it and get what works for you.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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