“attempt to index a nil value”-error in Lua
You’re not returning anything from your function call. Also, use local variables inside functions.
You’re not returning anything from your function call. Also, use local variables inside functions.
Game engines that use Lua Free unless noted Agen (2D Lua; Windows) Amulet (2D Lua; Window, Linux, Mac, HTML5, iOS) Cafu 3D (3D C++/Lua) Cocos2d-x (2D C++/Lua/JS; Windows, Linux, Mac, iOS, Android, BlackBerry) Codea (2D&3D Lua; iOS (Editor is iOs app); $14.99 USD) Cryengine by Crytek (3D C++/Lua; Windows, Mac) Defold (2D Lua; Windows, Linux, Mac, iOS, Android, Web, Switch) gengine (2D Lua; Windows, Linux, HTML5) Irrlicht (3D C++/.NET/Lua; Windows, Linux, Mac) Leadwerks (3D C++/C#/Delphi/BlitzMax/Lua; Windows; $199.95 … Read more
No, setting the key’s value to nil is the accepted way of removing an item in the hashmap portion of a table. What you’re doing is standard. However, I’d recommend not overriding table.remove() – for the array portion of a table, the default table.remove() functionality includes renumbering the indices, which your override would not do. If you do want … Read more
string.format in Lua follows the same patterns as Printf in c: http://www.cplusplus.com/reference/clibrary/cstdio/printf/ There are some exceptions, for those see here: http://pgl.yoyo.org/luai/i/string.format
It’s not ideal, but according to the Lua 5.2 Reference Manual: a % b == a – math.floor(a/b)*b
By adding one extra ; at the end of the string, the string now becomes “one;two;;four;”, everything you want to capture can use the pattern “([^;]*);” to match: anything not ; followed by a ;(greedy). Test: Output:
As other answers have said, the string concatenation operator in Lua is two dots. Your simple example would be written like this: However, there is a caveat to be aware of. Since strings in Lua are immutable, each concatenation creates a new string object and copies the data from the source strings to it. That … Read more
The os.clock function returns the number of seconds of CPU time for the program. So the sleep function of yours waits for n seconds, if you need to delay 2 minutes, just call: Note that there are some better solutions to implement sleep functions other than busy waiting, see Sleep Function for detail.
Step 1.Make sure you’re not using MB#4 (“backward”) in the game.If some action is assigned to MB#4 in the game, do the following: choose keyboard button you don’t currently use in the game (for example, F12) goto GHUB(KEYS tab); bind F12 to your physical MB#4 goto game options; bind the action to F12 instead of MB#4 Now when you press … Read more