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 


memoryrecord_getValue() problems

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

Joined: 08 Oct 2012
Posts: 577

PostPosted: Tue Apr 09, 2013 7:32 am    Post subject: memoryrecord_getValue() problems Reply with quote

Part of a code using 6.2 is:
Code:

maxhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Max HP")
maxhp = memoryrecord_getValue(maxhpaddress)
curhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Cur HP")
curhp = memoryrecord_getValue(curhpaddress)
maxmpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Max MP")
maxmp = memoryrecord_getValue(maxmpaddress)
curmpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Cur MP")
curmp = memoryrecord_getValue(curmpaddress)
magickeyaddress = addresslist_getMemoryRecordByDescription(addresslist, "Magic Keys")
magickey = memoryrecord_getValue(addresslist, magickeyaddress)
goldaddress = addresslist_getMemoryRecordByDescription(addresslist, "Gold Amount")
goldamount = memoryrecord_getValue(addresslist, goldaddress)
curgold = goldamount
commandscreenaddress = addresslist_getMemoryRecordByDescription(addresslist, "Command Screen (N-0 Y-255)")
commandscreen = memoryrecord_getValue(addresslist, commandscreenaddress)

  if curhp ~= maxhp then
    memoryrecord_setValue(curhpaddress, maxhp)
    --print("changed cur hp")
  end
  if curmp ~= maxmp then
    memoryrecord_setValue(curmpaddress, maxmp)
    --print("changed cur mp")
  end
  if magickeys ~= 6 then
    memoryrecord_setValue(magickeyaddress, 6)
  end
  if commandscreen == 255 then
    gold = curgold
  end


This part

goldamount = memoryrecord_getValue(addresslist, goldaddress)
curgold = goldamount
commandscreenaddress = addresslist_getMemoryRecordByDescription(addresslist, "Command Screen (N-0 Y-255)")
commandscreen = memoryrecord_getValue(addresslist, commandscreenaddress)

and this part

if magickeys ~= 6 then
memoryrecord_setValue(magickeyaddress, 6)
end
if commandscreen == 255 then
gold = curgold
end

were added this morning.

The first address references entered much earlier than today work fine
maxhpaddress
curhpaddress
maxmpaddress
curmpaddress

The addresses entered today don't work. I have tried the "Execute script" button and saving and re-opening the table, but they still don't work.

Any suggestions?



CETable.png
 Description:
 Filesize:  35.37 KB
 Viewed:  11461 Time(s)

CETable.png


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

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

PostPosted: Tue Apr 09, 2013 7:44 am    Post subject: Reply with quote

Code:

goldamount = memoryrecord_getValue(addresslist, goldaddress)

will cause random/unspecified behavior as addresslist is not a memoryrecord object (same for magic key)

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Tue Apr 09, 2013 7:47 am    Post subject: Reply with quote

OK, I guess the earlier entered lines didn't cause the same error, as they were identical in structure.
What is the more appropriate way to code the the memoryrecord_getValue() line?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Apr 09, 2013 8:23 am    Post subject: Reply with quote

It might work because often (not always) the parameters are counted from the last given parameter and back
Anyhow, read main.lua to see how to call memoryrecord_getValue

memoryrecord_getValue only takes 1 parameter, the memoryrecord object, and returns the value as a string. So you probably want

Code:

goldamount =memoryrecord_getValue(goldaddress)

also, I recommend using better names for variables. goldaddress is not an address. It's a memoryrecord object. (e.g goldmemrec)

Are you sure that both strings are the same? (e.g. no invisible characters)

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Tue Apr 09, 2013 8:30 am    Post subject: Reply with quote

Ok
The command returns the address of the table object, tha is why I uded the descriptor, perhaps goldmemrecaddress?

Are you sure that both strings are the same? (e.g. no invisible characters)
Normally what I do is to copy the Description from the table and copy it to the code
EDIT:
I understand the error comment, take the addresslist OUT OF THE memoryrecord_getValue() line

thanks Mother of hack
Back to top
View user's profile Send private message Yahoo Messenger
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Apr 22, 2013 3:41 pm    Post subject: Reply with quote

Another question using the same scripted lines

maxhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Max HP")
maxhp = memoryrecord_getValue(maxhpaddress)
curhpaddress = addresslist_getMemoryRecordByDescription(addresslist, "Cur HP")
curhp = memoryrecord_getValue(curhpaddress)
if curhp ~= maxhp then
memoryrecord_setValue(curhpaddress, maxhp)
end

Is there another way than with the above type coding to hold a value constant(like the check box on the table)?
Back to top
View user's profile Send private message Yahoo Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Apr 22, 2013 4:09 pm    Post subject: Reply with quote

This code should freeze the hp value to the value of Max HP (You can also do this without any kind of lua coding, check the checkbox and then change the value)
Code:

memoryrecord_freeze(maxhp) --first freeze
memoryrecord_setValue("(Max HP)") --update the freeze value with (Max HP) so each freeze will query the Max HP value

_________________
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
bknight2602
Grandmaster Cheater
Reputation: 0

Joined: 08 Oct 2012
Posts: 577

PostPosted: Mon Apr 22, 2013 4:34 pm    Post subject: Reply with quote

lol, I realize one could use the check box. I was referring to a code.

It seems that this code would freeze the value and not let it change. Would something like this work?

addresslist = getAddressList()
curmp = memory_getValue(addresslist_getMemoryRecordByDescription(addresslist, "Max MP"))
memoryrecord_freeze(curhp)
Back to top
View user's profile Send private message Yahoo Messenger
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Mon Apr 22, 2013 4:39 pm    Post subject: Reply with quote

yup
_________________
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: 458

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

PostPosted: Mon Apr 22, 2013 5:50 pm    Post subject: Reply with quote

no it won't update the health to the max hp when max hp changes

if you freeze the record first and THEN change the value to "(Max HP)" it will freeze the value to the current value of "Max HP"

If you freeze a address the "freeze value" will be set to the value it had at the time of the freeze
setting a value on a frozen record updates the value being set to the value you want it to be.
Setting the value to a special value like (Max HP) will cause the freeze to apply that effect constantly instead of once

First freeze, then change value. That's the important part of this feature

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