Jump to content

attempt to index a number value


Recommended Posts

Posted

hi, why is this happening?

this is my part of code

function onStop() 
   fileDelete("ch/ch.reg"); 
   fileDelete("ch/ch.sys"); 
   local file1,file2 = fileCreate("ch/ch.reg"),fileCreate("ch/ch.sys"); 
   local tab1,tab2 = toJSON(reg),toJSON(sys); 
   fileWrite(file1,tab1): 
   fileWrite(file2,tab2): 
   fileClose(file1); 
   fileClose(file2); 
end; 
addEventHandler("onResourceStop",resourceRoot,onStop); 

first file is properly written data to and closed but the other file is running into issues

and everything in that function is defined

so what does this error mean? how do i fix it?

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Lua won't enforce ; (semicolon) at the end of each line like other languages, and in your file you have : (regular colon) after the two write lines, at that runs upon resource stop you won't notice that the script crashes and stops running directly after the first file is written. Remove all the ; and : at the end of the lines and try it, that should work.

function be_remove() {

        printf("Too much gaming and too little sleep makes Olle wanna kill...");

        be_remove();

}

Posted

haha lmao i didn't notice that it was : instead of ; (my notepad++ font makes : and ; look almost the same so didn't see it) , thanks

and yes semicolon cant be at each of every line but it can be after function calls,ends, and variables and in tables :)

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...