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 


attempt to index a number value

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

Joined: 19 Jun 2015
Posts: 22

PostPosted: Thu Mar 31, 2016 8:19 pm    Post subject: attempt to index a number value Reply with quote

Hi there I know it's probably something stupid or simple but I can't seem to notice it right now.

Code:

function Template(P1,P2,P3,P4,P5,P6,A1,A2,A3,A4,A5,A6,M1,M2,M3,M4,M5,M6,AT1,AT2,AT3,AT4,AT5,AT6,T1,T2,T3,T4,T5,T6,MATCH,ARENA,CAGE,PIN,SUB,BO3,IRON,ROYAL,KO,LMS,FIN,FB,CX,DQ,RB,RO,EL,FCA,TIME,BELT)
  if P1 ~= "NA" then setProperty(MATCH.PAC1,"Text",P1) end
  if P2 ~= "NA" then setProperty(MATCH.PAC2,"Text",P2) end
  if P3 ~= "NA" then setProperty(MATCH.PAC3,"Text",P3) end
  if P4 ~= "NA" then setProperty(MATCH.PAC4,"Text",P4) end
  if P5 ~= "NA" then setProperty(MATCH.PAC5,"Text",P5) end
  if P6 ~= "NA" then setProperty(MATCH.PAC6,"Text",P6) end
  if A1 ~= "NA" then checkbox_setState(MATCH.ACT1,A1) end
  if A2 ~= "NA" then checkbox_setState(MATCH.ACT2,A2) end
  if A3 ~= "NA" then checkbox_setState(MATCH.ACT3,A3) end
  if A4 ~= "NA" then checkbox_setState(MATCH.ACT4,A4) end
  if A5 ~= "NA" then checkbox_setState(MATCH.ACT5,A5) end
  if A6 ~= "NA" then checkbox_setState(MATCH.ACT6,A6) end
  if M1 ~= "NA" then checkbox_setState(MATCH.MAN1,M1) end
  if M2 ~= "NA" then checkbox_setState(MATCH.MAN2,M2) end
  if M3 ~= "NA" then checkbox_setState(MATCH.MAN3,M3) end
  if M4 ~= "NA" then checkbox_setState(MATCH.MAN4,M4) end
  if M5 ~= "NA" then checkbox_setState(MATCH.MAN5,M5) end
  if M6 ~= "NA" then checkbox_setState(MATCH.MAN6,M6) end
  if AT1 ~= "NA" then setProperty(MATCH.ATT1,"ItemIndex",AT1) end
  if AT2 ~= "NA" then setProperty(MATCH.ATT2,"ItemIndex",AT2) end
  if AT3 ~= "NA" then setProperty(MATCH.ATT3,"ItemIndex",AT3) end
  if AT4 ~= "NA" then setProperty(MATCH.ATT4,"ItemIndex",AT4) end
  if AT5 ~= "NA" then setProperty(MATCH.ATT5,"ItemIndex",AT5) end
  if AT6 ~= "NA" then setProperty(MATCH.ATT6,"ItemIndex",AT6) end
  if T1 ~= "NA" then setProperty(MATCH.TEAM1,"ItemIndex",T1) end
  if T2 ~= "NA" then setProperty(MATCH.TEAM2,"ItemIndex",T2) end
  if T3 ~= "NA" then setProperty(MATCH.TEAM3,"ItemIndex",T3) end
  if T4 ~= "NA" then setProperty(MATCH.TEAM4,"ItemIndex",T4) end
  if T5 ~= "NA" then setProperty(MATCH.TEAM5,"ItemIndex",T5) end
  if T6 ~= "NA" then setProperty(MATCH.TEAM6,"ItemIndex",T6) end
  if MATCH ~= "NA" then setProperty(MATCH.MATCH,"Text",MATCH) end
  if ARENA ~= "NA" then setProperty(MATCH.RING,"Text",ARENA) end
  if CAGE ~= "NA" then setProperty(MATCH.TYPE,"ItemIndex",CAGE) end
  if PIN ~= "NA" then checkbox_setState(MATCH.PIN,PIN) end
  if SUB ~= "NA" then checkbox_setState(MATCH.SUB,SUB) end
  if BO3 ~= "NA" then checkbox_setState(MATCH.BO3,BO3) end
  if IRON ~= "NA" then checkbox_setState(MATCH.IRON,IRON) end
  if ROYAL ~= "NA" then checkbox_setState(MATCH.ROYAL,ROYAL) end
  if KO ~= "NA" then checkbox_setState(MATCH.KO,KO) end
  if LMS ~= "NA" then checkbox_setState(MATCH.LMS,LMS) end
  if FIN ~= "NA" then checkbox_setState(MATCH.FIN,FIN) end
  if FB ~= "NA" then checkbox_setState(MATCH.FB,FB) end
  if CX ~= "NA" then checkbox_setState(MATCH.CAGE,CX) end
  if DQ ~= "NA" then checkbox_setState(MATCH.DQ,DQ) end
  if RB ~= "NA" then checkbox_setState(MATCH.ROPE,RB) end
  if RO ~= "NA" then setProperty(MATCH.ROUT,"ItemIndex",RO) end
  if EL ~= "NA" then checkbox_setState(MATCH.ELIM,EL) end
  if FCA ~= "NA" then checkbox_setState(MATCH.FALLS,FCA) end
  if TIME ~= "NA" then setProperty(MATCH.TIME,"Text",TIME) end
  if BELT ~= "NA" then setProperty(MATCH.BELT,"Text",BELT) end
end
function TEMPLATEChange(sender)
 if getProperty(MATCH.TEMPLATE,"ItemIndex") == 0 then
   Template("NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 1 then
   Template("NA","NA","NA","NA","NA","NA",1,1,1,1,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,0,1,"NA","NA",4,"NA",0,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 2 then
   Template("NA","NA","NA","NA","NA","NA",1,1,1,1,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,0,1,"NA","NA",10,"NA",0,1,1,0,0,0,0,0,0,0,0,1,0,1,1,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 3 then
   Template("NA","NA","NA","NA","NA","NA",1,1,0,1,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,"NA",1,"NA","NA",15,"NA",0,1,1,0,0,0,0,0,0,0,0,1,1,3,0,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 4 then
   Template("NA","NA","NA","NA","NA","NA",1,1,0,1,0,1,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,"NA",1,"NA",1,17,"NA",0,1,1,0,0,0,0,0,0,0,0,1,1,3,0,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 5 then
   Template("NA","NA","NA","NA","NA","NA",1,1,1,1,0,1,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,0,1,"NA",1,19,"NA",0,1,1,0,0,0,0,0,0,0,0,1,1,3,0,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 6 then
   Template("NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",23,"NA",0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,"NA","NA")
 elseif getProperty(MATCH.TEMPLATE,"ItemIndex") == 7 then
   Template("NA","NA","NA","NA","NA","NA",1,1,1,0,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,2,"NA","NA","NA",32,"NA",0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,"NA","NA")
 end
end


The error I'm getting is as follows "297: attempt to index a number value (local 'MATCH')"

297 happens to be the A1 line in the template function.

I'm not 100% what is wrong. hopefully it's something someone is able to see from this snippet of code.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Mar 31, 2016 8:38 pm    Post subject: Reply with quote

You're passing the wrong value (a number) in the match argument in all but the first call.

In fact, you probably don't want to even name the argument match, judging by the rest of your code.

Template(P1,P2,P3,P4,P5,P6,A1,A2,A3,A4,A5,A6,M1,M2,M3,M4,M5,M6,AT1,AT2,AT3,AT4,AT5,AT6,T1,T2,T3,T4,T5,T6,MATCH
Back to top
View user's profile Send private message
pozzum
Newbie cheater
Reputation: 0

Joined: 19 Jun 2015
Posts: 22

PostPosted: Thu Mar 31, 2016 8:45 pm    Post subject: Reply with quote

Zanzer wrote:
You're passing the wrong value (a number) in the match argument in all but the first call.

In fact, you probably don't want to even name the argument match, judging by the rest of your code.

Template(P1,P2,P3,P4,P5,P6,A1,A2,A3,A4,A5,A6,M1,M2,M3,M4,M5,M6,AT1,AT2,AT3,AT4,AT5,AT6,T1,T2,T3,T4,T5,T6,MATCH


So instead of 4 it should be "4" then if I'm trying to have a number in that text?

Also yeah I know I should change that from match...
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Mar 31, 2016 8:49 pm    Post subject: Reply with quote

I'm assuming you have a global variable called MATCH already.
So just rename the MATCH argument in the function.
Code:
  if OTHERMATCH ~= "NA" then setProperty(MATCH.MATCH,"Text",OTHERMATCH) end
Back to top
View user's profile Send private message
pozzum
Newbie cheater
Reputation: 0

Joined: 19 Jun 2015
Posts: 22

PostPosted: Thu Mar 31, 2016 8:54 pm    Post subject: Reply with quote

Zanzer wrote:
I'm assuming you have a global variable called MATCH already.
So just rename the MATCH argument in the function.
Code:
  if OTHERMATCH ~= "NA" then setProperty(MATCH.MATCH,"Text",OTHERMATCH) end


I actually don't use a match variable anywhere but here, but it's the name of the table itself and a text box on the table.

I'm trying to inject numbers into that text box ( 4, 10, 15, 17, 19, 23, 32 should all be in the match variable)

but I'd need to make those numbers into strings so I can use that function?

so as I instead of
Code:

Template("NA","NA","NA","NA","NA","NA",1,1,1,1,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,0,1,"NA","NA",4,"NA",0,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,"NA","NA")

I'd want to run the command
Code:

Template("NA","NA","NA","NA","NA","NA",1,1,1,1,0,0,"NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA","NA",0,1,0,1,"NA","NA","4","NA",0,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,"NA","NA")


Edit: Just tested it out and it's working as expected thanks.
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