[Module API] Errors |
Shamousey « Consul » 1380827100000
| 1 | ||
If your script isn't working as intended, post it in this thread and explain what you expect to happen. This thread describes the many types of errors that Lua can return, and briefly covers how to fix them or prevent them from happening. If you've encountered an error in your code, please read over this thread to try and solve it. If you still need help, post your ENTIRE code as a reply to this thread (in [quote] tags or on an external site like PasteBin), explain what you expected to happen, and mention the error that's coming up. Some error messages contain a line number that can be used to find the line of code which caused the error. The error may not be exactly on the line given, but one of them around it. A good tip for debugging code to find out where something went wrong is to print variables and other information at various stages of the code. This can be helpful to find out if a variable isn't what you expected it to be, if certain if statements are getting ran, etcetera. This doesn't fix your code, but helps you to locate what's wrong. A common mistake when something doesn't work correctly is that it's been redefined. The last definition of a piece of data replaces the previous one, so for example here having two eventPlayerEmotes will mean that only the last one ever actually works. a dit : To fix this, just merge the contents of the two functions. a dit : The errors below all have an example of the different types of errors, and brief description. If a specific error isn't listed, please post it and it'll be covered. Init is an abbreviation of "initialisation", and means that the code failed to excecute properly as it was loaded. [•] Attempt to call nil. This error occurs when a line is attempting to use a variable that is nil. This often occurs when things haven't been created yet and are in the wrong order, or a certain function hasn't been excecuted. a dit : Another example that may cause this error is incorrect capitalisation. Lua is case sensitive, so typing a function or variable name without the correct capitalisation will try to call one of the same capitalisation. a dit : [•] Index expected, got nil. Trying to define or call an item in a table that doesn't exist will cause an error like this. a dit : [•] ')' expected (to close '(' at line [num]) If this error occurs, a closing parenthesis from function arguments is missing. a dit : [•] '' expected. While this error can pop up in several different situations, the most common is when using an elseif statement when it has no corresponding opening if. a dit : [•] Multiple points. Numbers can only have a single decimal point, trying to have multiple decimal points in a single number will return this error. a dit : [•] Unfinished (long) comment/string. The string operators must be closed whenever they are used. If the error message pertains to a "long" comment/string, use of the multi-line operator [[...]] was the cause of the error. a dit : [•] Nesting of [[...]] is deprecated. Multi-line strings can't have more multi-line strings inside. a dit : [•] Attempt to index ? (a nil value). This error occurs when an element in a table is trying to be used, but cannot be found. a dit : [•] Null This is an error caused by a bug in the Module API and cannot be solved. Occasionally scripts cannot be run in a certain room. [•] Attempt to concatenate [data] and [data]. Different data types cannot be concatenated together with the .. operator, with the exception of strings and numbers. a dit : [•] Invalid key to 'next'. This error occurs when the next() function has an invalid key it tries to move to. This is most common when trying to remove an item from a table while iterating through it, as the pairs() function uses next(). a dit : [•] Attempt to perform arithmetic on a [data] value. Different data types can't have any arithmetic performed on them unless they're numbers. a dit : [•] Attempt to compare [data] with [data]. Much like how arithmetic can't be performed on different data types, they can't be compared with comparison operators. a dit : [•] [data] expected, got [data]. When a certain data type is expected in a function but another one is given, this error will occur. a dit : [•] Lua destroyed : Runtime can't exceed 40 ms in 4 seconds ! a dit : [•] Lua destroyed: Runtime too long! a dit : Argument errors rarely stop the script from working and act as more of a warning that something isn't working properly. [•] Argument must be integer. This error occurs when an argument in a function is expecting an integer number but is receiving another data type. For example, tfm.exec.movePlayer(name,"text",200) is expecting a number in the second argument. [•] vm error: java.lang.ArrayIndexOutOfBoundsException: 256 This error can be caused by multiple things, but is more commonly when something recurs indefinitely. An example might be a function that calls itself. a dit : [•] You don't have the right to use this function. Certain functions are disabled from being used in the Tribe House, including the following. a dit : Dernière modification le 1403967480000 |
Myaumatrosik « Censeur » 1380827640000
| 0 | ||
Ohh... Help me, Sham :с http://pastebin.com/Eeip1yL6 I can't update text in new round! |
Thetroz « Citoyen » 1380827760000
| 0 | ||
...And [•] index expected, got nil? |
Shamousey « Consul » 1380828660000
| 1 | ||
Myaumatrosik a dit : In your script here, you can't use tfm.exec.chatMessage() as it's been disabled in the tribe house. You're also trying to update a text area with the ID of 0, but the only one you have is ID 1. Thetroz a dit : I've obviously missed a few errors that I hope I'll get to cover if people report them, but I've added that in. |
Hophipmice « Citoyen » 1380883320000
| 0 | ||
[Delete please] |
Tailtong « Citoyen » 1380883680000
| 0 | ||
Hophipmice a dit : Gedit says your code has 36 lines, not 125. Give me the rest of your code, don't worry, i won't copy. |
Hophipmice « Citoyen » 1380883800000
| 0 | ||
Tailtong a dit : Fixed :) |
Tailtong « Citoyen » 1380883800000
| 0 | ||
Hophipmice a dit : Okay. |
Bengalstar « Citoyen » 1380932460000
| 0 | ||
what about this error ? [•] Init Error : [string "transformice.lua"]:18: 'then' expected |
Abdeltif « Citoyen » 1380976620000
| 0 | ||
Good job sham ! I have some errors to paste here :D wait that i edit this post |
Hophipmice « Citoyen » 1380976620000
| 0 | ||
I did a dit : But it wont work ): a dit : |
Abdeltif « Citoyen » 1380977640000
| 0 | ||
a dit : [•] Init Error : transformice.lua:31: bad argument: table expected, got nil |
Epicshawty « Citoyen » 1381177680000
| 0 | ||
Abdeltif a dit : here a dit : you can change mousepeeps to anything, just a example :P |
Leafileaf « Citoyen » 1381216380000
| 0 | ||
Sha you mixed up some of the errors. The code for attempt to index nil and index expected, got nil. These two should be switched >_< Attempt to call nil: that code won't return that error. Your code prints nil. To get the attempt to call nil error, use "randomUndeclaredFunction()" |
0 | ||
a dit : [•] Error transformice.lua; 133 |
Shamousey « Consul » 1381280100000
| 0 | ||
Tinittee a dit : This is working fine for me... |
Safwanrockz « Censeur » 1381355520000
| 0 | ||
Really helpful thread, good job shamo. |
Shamousey « Consul » 1381374540000
| 1 | ||
So I made an "inspirational poster" last week for those that come with the same issue. |
Abdeltif « Citoyen » 1381562700000
| 0 | ||
a dit : Error : [•] Init Error : [string "transformice.lua"]:1: or '...' expected |
Ordboka « Citoyen » 1381563720000
| 0 | ||
Abdeltif a dit : You can't have those numbers up there. You should have variables where you can store the information that you get when you run the function. Lua a dit : Try this |