Sim_pro
Mouse
If your script doesn't work as intended, write it down and explain what you expect.
This topic identifies the various errors that Lua can give and explains how to correct these errors or prevent them from happening.
If you've encountered an error in your code, please read this topic thoroughly to resolve this error. If you still need help, write your ALL code (with a tag or a third site, such as Paste Moepl) in the comments, explain what you expect and what the error is.
Some error messages contain a line number that can be used to find the line code that caused the error. The error may not be exactly on that line but it is around that line.
To find out where something went wrong, the code can be given as a proposal to debug variables and other information in various parts of the code. This is to find out whether you want to have a variable, or whether a given statement is running and so on. may be useful in finding situations. This doesn't fix your code, but it will help you to see what's wrong.
A common mistake is that it has been redefined when something does not work properly. The last definition of a piece of data can replace the previous one, and you will see that only two of the eventPlayerEmotes functions will work, for example.
Combine the contents of both functions to fix this.
The following errors show examples of various errors and contain brief explanations. If a specific error is not listed, you can write it here to include that error.
Startup Errors
These errors are errors that do not work correctly after the code is installed.
1 - Attempt to call a nil.
This error occurs when a line tries to use a variable that is nil. This is usually the case when something is not yet created and is in the wrong order or when a particular function is not executed.
Another example that could cause this error is the incorrect capitalization. Lua is case-sensitive, so writing a variable or function that does not have the correct capitalization tries to call one of the same capitalization.
2 - Index expected, got nil.
Trying to call or identify an item in a table that does not exist causes such an error.
3 - ')' expected (to close '(' at line [num])
If this error occurs, the function arguments are missing brackets.
4 - " Expected
Although this error can occur in more than one case, the most common case is the use of the elseif statement, even if there is no compatible opening.
5 - Multiple Points
Numbers can have only one decimal point. Using more than one decimal point on a single page results in this error.
6 - Unfinished (long) comment/string.
String operators should be closed when the plot is used. If the error message belongs to a "long" comment / string, the use of multi-line operator [[...]] is the cause of the error.
7 - Nesting of [[...]] is deprecated.
Multi-line strings cannot contain more multi-line strings inside them.
8 - Attempt to index ? (a nil value).
This error occurs when the element element in a table tries to use it but it does not exist.
9 - Null
This module is an error on the API and cannot be decoded. Scripts sometimes cannot be run in certain rooms.
Runtime Errors
1 - Attempt to concatenate [data] and [data].
Different types of data except for Strings and numbers .. it can not sort the operator.
2 - Invalid key to 'next'.
The Next() function occurs when it contains an invalid key that it tries to move.Since the pairs() function uses next(), trying to delete an item from a table is the most common occurrence of this error.
3 - Attempt to perform arithmetic on a [data] value.
If different data types are not numbers, they do not contain arithmetic on them.
4 - Attempt to compare [data] with [data].
Arithmetic is not performed in different data types, but cannot be compared with comparison operators.
5 - [data] expected, got [data].
This error will occur if a certain type of error is expected in a function, but another one is given.
6 - Lua destroyed : Runtime can't exceed 40 ms in 4 seconds !
7 - Lua destroyed: Runtime too long!
Argument Errors
Argument errors rarely interfere with script execution, and serve as a warning that something is not working properly.
1 - Argument must be integer.
This error occurs when an argument in a function waits an exact number, but receives another data type. For example, fm.exec.movePlayer (name, "text", 200) expects a number in the second argument.
Various Errors
1 - vm error: java.lang.ArrayIndexOutOfBoundsException: 256
This error can occur by more than one thing, but more often occurs when something is repeated infinitely. An example of this is a function that calls itself.
2 - You don't have the right to use this function.
Some functions cannot be used in the tribal house. These functions:
This topic identifies the various errors that Lua can give and explains how to correct these errors or prevent them from happening.
If you've encountered an error in your code, please read this topic thoroughly to resolve this error. If you still need help, write your ALL code (with a tag or a third site, such as Paste Moepl) in the comments, explain what you expect and what the error is.
Some error messages contain a line number that can be used to find the line code that caused the error. The error may not be exactly on that line but it is around that line.
To find out where something went wrong, the code can be given as a proposal to debug variables and other information in various parts of the code. This is to find out whether you want to have a variable, or whether a given statement is running and so on. may be useful in finding situations. This doesn't fix your code, but it will help you to see what's wrong.
A common mistake is that it has been redefined when something does not work properly. The last definition of a piece of data can replace the previous one, and you will see that only two of the eventPlayerEmotes functions will work, for example.
Code:
function eventEmotePlayed(name, emote)
tfm.exec.giveCheese(name, emote)
end
function eventEmotePlayed(name,emote)
print("This redefined the parent so only this will work.")
end
Code:
function eventEmotePlayed(name)
tfm.exec.giveCheese(name)
print("This no longer works!")
end
Startup Errors
These errors are errors that do not work correctly after the code is installed.
1 - Attempt to call a nil.
This error occurs when a line tries to use a variable that is nil. This is usually the case when something is not yet created and is in the wrong order or when a particular function is not executed.
Code:
print(test)
test="Hello."
Code:
Print("Test.")
Trying to call or identify an item in a table that does not exist causes such an error.
Code:
tbl[1] = "This crashes because tbl is not available."
If this error occurs, the function arguments are missing brackets.
Code:
print("Hi
Although this error can occur in more than one case, the most common case is the use of the elseif statement, even if there is no compatible opening.
Code:
elseif 1>2 then
print("No opening statement.")
end
Numbers can have only one decimal point. Using more than one decimal point on a single page results in this error.
Code:
- One decimal point, no problem.
20:43
- More than one decimal point, wrong.
20.43.9.1
String operators should be closed when the plot is used. If the error message belongs to a "long" comment / string, the use of multi-line operator [[...]] is the cause of the error.
Code:
text="This is the definition of an unfinished variable.
--[[This is an example of a comment that has never been closed.
Multi-line strings cannot contain more multi-line strings inside them.
Code:
--[[ AAA. [[ BBB. ]] CCC.]]
This error occurs when the element element in a table tries to use it but it does not exist.
Code:
tbl={}
print(tbl[1])
This module is an error on the API and cannot be decoded. Scripts sometimes cannot be run in certain rooms.
Runtime Errors
1 - Attempt to concatenate [data] and [data].
Different types of data except for Strings and numbers .. it can not sort the operator.
Code:
--EE
"Text "..34
--BB
{"this","is","a","table"}.."string"
nil..{"table"}
nil.."string"
function().."string"
The Next() function occurs when it contains an invalid key that it tries to move.Since the pairs() function uses next(), trying to delete an item from a table is the most common occurrence of this error.
Code:
tbl={Something=true,somethingelse=true}
for k,v in pairs(tbl) do
tbl[k]=nil
end
If different data types are not numbers, they do not contain arithmetic on them.
Code:
{"table"}+4
Arithmetic is not performed in different data types, but cannot be compared with comparison operators.
Code:
if {"table"} > 4 then
print("This gives error.")
end
This error will occur if a certain type of error is expected in a function, but another one is given.
Code:
for key,value in pairs("string") do
print("The above for loop is waiting for a table.")
end
Code:
function eventLoop()
for i=1,1000000 do
--This causes an error.
end
end
Code:
for i=1,10000000000 do
--This causes an error.
end
Argument errors rarely interfere with script execution, and serve as a warning that something is not working properly.
1 - Argument must be integer.
This error occurs when an argument in a function waits an exact number, but receives another data type. For example, fm.exec.movePlayer (name, "text", 200) expects a number in the second argument.
Various Errors
1 - vm error: java.lang.ArrayIndexOutOfBoundsException: 256
This error can occur by more than one thing, but more often occurs when something is repeated infinitely. An example of this is a function that calls itself.
Code:
function a()
a()
end
a()
Some functions cannot be used in the tribal house. These functions:
Code:
tfm.exec.chatMessage()
system.newTimer()
system.removeTimer()
system.saveFile()
system.loadFile()