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 


Check Box Code
Goto page Previous  1, 2
 
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: Mon Aug 08, 2016 10:06 am    Post subject: Reply with quote

ParkourPenguin wrote:
Zanzer wrote:
@DarkByte: Screw backwards compatibility, remove these functions from the library! Smile
+1
The old functions make it easier for people who don't know what they're doing to get misconceptions.
The functions have been linked since I started developing all the codes
Quote:


If you set a memory record's value, you are assigning some string to that property. You are not getting that property.
Code:
memrec.Value = '5'  -- does not return anything; it's an assignment
print(memrec.Value)   -- prints out the value, because you're only getting the value (not assigning anything to it)

print(memrec.Value = '5')  -- gives you a generic syntax error because Lua expects you to know that this doesn't make any sense

The variable cNo1curspeed is nil because of that, which is causing the error later on in your script.
Sometimes it would seem that Lua should be more friendly presenting descriptive error types.
Quote:


By the way, this line of code near the end should be an obvious error:
Code:
cNo2maxstam = memoryrecord_getValue(tonumber(cNo1maxstam)*.25)


Thanks for that explanation, it might be helpful to present an alternative code.

With that said I have rewritten the code as follows:
Code:

function CECheckbox6Click(sender)
boxstate = checkbox_getState(CheatPanel_CECheckbox6)
  if boxstate == cbChecked then
    timer_setEnabled(tChocoRace, true)
    local AL = getAddressList()
    cNo1curspeedaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Cur Speed")
    cNo1maxsprintaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Sprint")
    cNo1curstamaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Cur Stamina")
    cNo1maxstamaddress = AL.getMemoryRecordByDescription("Choco 1 In Race Max Stamina")
    cNo2curspeedaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Cur Speed")
    cNo2maxspeedaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Speed")
    cNo2maxsprintaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Sprint")
    cNo2curstamaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Cur Stamina")
    cNo2maxstamaddress = AL.getMemoryRecordByDescription("Choco 2 In Race Max Stamina")
    cNo1curspeed = memoryrecord_getValue(cNo1curspeedaddress)
    cNo1maxsprint = memoryrecord_getValue(cNo1maxsprintaddress)
    cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress, cNo1maxsprint)
    cNo1curspeedset = memoryrecord_getValue(cNo1curspeedaddress)
    cNo1maxstam = memoryrecord_getValue(cNo1maxstamaddress)
    cNo1curstam = memoryrecord_setValue(cNo1curstamaddress, cNo1maxstam)
    cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,cNo1curspeedset *.25)
    cNo2maxstamset = memoryrecord_getValue(cNo1maxstamaddress)
    cNo2maxstam = memoryrecord_setValue(cNo2maxstamaddress,cNo2maxstamset *.25)
    print("Choco 1 winner is enabled")
  else
    timer_setEnabled(tChocoRace, false)
    print("Choco 1 winner is not enabled")
  end
end

I haven't tried it yet, too busy with other life demands opposed to gaming. Does anyone see any other errors?
Back to top
View user's profile Send private message Yahoo Messenger
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Mon Aug 08, 2016 10:55 am    Post subject: Reply with quote

The same one:

cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress, cNo1maxsprint)
cNo1curstam = memoryrecord_setValue(cNo1curstamaddress, cNo1maxstam)
cNo2curspeed = memoryrecord_setValue(cNo2curspeedaddress,cNo1curspeedset *.25)
cNo2maxstam = memoryrecord_setValue(cNo2maxstamaddress,cNo2maxstamset *.25)


Please. w/e your job is, it shouldn't be quality control or require attention to detail.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Aug 08, 2016 11:10 am    Post subject: Reply with quote

bknight2602 wrote:
The functions have been linked since I started developing all the codes
Irrelevant.
bknight2602 wrote:
Sometimes it would seem that Lua should be more friendly presenting descriptive error types.
Lua isn't a magic genie that knows exactly what you want to have happen.
bknight2602 wrote:
It might be helpful to present an alternative code.
I really have no idea what you were trying to do with that. It's like saying 2+2=fish or something; it makes no sense whatsoever.

Code:
cNo1curspeed = memoryrecord_setValue(cNo1curspeedaddress, cNo1maxsprint)

Are you kidding me? If you're serious and you're not just trolling everyone, I guess you just don't understand what we're saying. Look up a basic tutorial of Lua so that you can learn what a variable is, what a function is, and how to use both. If you already know that, then learn the English language so that you can determine an identifier's purpose through its equivalent English meaning.

I don't know if your code works or not because I don't care to analyze it any further. If you aren't going to listen to anyone, why ask for help in the first place?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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
Goto page Previous  1, 2
Page 2 of 2

 
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