Questions tagged [lua-5.3]

A lightweight multi-paradigm programming language designed as a scripting language with extensible semantics as a primary goal.

Lua (/ˈluːə/ LOO-ə, from Portuguese: lua [ˈlu.(w)ɐ] meaning moon; explicitly not "LUA") is a lightweight multi-paradigm programming language designed as a scripting language with extensible semantics as a primary goal. Lua is cross-platform since it is written in ANSI C.

Lua has a relatively simple C API.

Wikipedia: http://en.wikipedia.org/wiki/Lua_%28programming_language%29

49 questions
1
vote
1 answer

Lua 5.3: strange behavior with table index

so I was playing around with tables a bit and found this strange behavior: folder1 = {1, 2, 3} table.insert(folder1, "test") --4 folder1[5] = "test2" print("#folder1: " .. #folder1) --yields 5 folder2 = {1, 2, 3} table.insert(folder2, "test")…
Culain
  • 11
  • 1
1
vote
1 answer

Cannot Load C dynamic library with C Program compile with liblua.a (lua5.3)

I first download lua-5.3.5 , and put the source in my working directory and compile it with make linux so I got the liblua.a and lua binary file in ./lua-5.3.5/src. And then I write a C Dynamic Library like this : #include #include…
Lynton
  • 257
  • 5
  • 12
1
vote
0 answers

Changing the _ENV of a lua_thread (using C API)

This is for a multiplayer game where NPC scripts will be loaded and cached as function chunks on a single lua_State, and then each time a player interacts with an NPC, a new lua_thread is created, a cached function is fetched from a global lua_table…
newbane2
  • 130
  • 5
1
vote
1 answer

How do Lua syntax rules differ between REPL and scripts?

I rarely use Lua so this might be a trivial question but I just noticed that with Lua 5.3.2, in the interactive REPL I can write for example: > 1 == 2 or error('numbers not equal') Which is how I'd perform error handling in Bash or Perl (or course…
Peter
  • 2,919
  • 1
  • 16
  • 35
1
vote
0 answers

Lua print performance, Windows vs Linux

Using C, having typedef struct Entity { size_t id; char *luaFun; } Entity; and calling void LuaEntityUpdate(Entity *entity, double dt) { lua_getglobal(L, entity->luaFun); lua_pushinteger(L, entity->id); lua_pushnumber(L, dt); …
wfranczyk
  • 420
  • 3
  • 12
1
vote
1 answer

Why does the doc say `__index` is looked up in the table?

From the Lua 5.3 doc: __index: The indexing access table[key]. ... The metamethod is looked up in table. It says the same thing for __newindex, but not for any other metamethod. If this were true (which it's not), it would be a major departure…
luther
  • 5,195
  • 1
  • 14
  • 24
1
vote
2 answers

Lua C function call returns nil

I wrote a simple C plugin for Lua: #include "lua.h" #include "lualib.h" #include "lauxlib.h" static int bar (lua_State *L) { double arg1 = luaL_checknumber(L, 1); double arg2 = luaL_checknumber(L, 2); lua_Number res = arg1 + arg2; …
m_vdbeek
  • 3,704
  • 7
  • 46
  • 77
1
vote
1 answer

Emulating c++ 'using namespace' via _ENV

if I have a file foo.lua: local foo = {} foo.add = function(a, b) return a+b end foo.sub = function(a, b) return a-b end foo.multiply = function(a, b) return a*b end return foo and in bar.lua I make heavy use of code from foo.lua I am bothered by…
Ace shinigami
  • 1,374
  • 2
  • 12
  • 25
1
vote
1 answer

What is "n" in the coroutine returned value?

I have the following coroutine and table that look like this: co = coroutine.create(function(...) for item in pairs(table.pack(...)) do coroutine.yield(item) end coroutine.yield('Evil') return 'NO!' end) values = {1, 2, 3, 4, 5,…
styvane
  • 59,869
  • 19
  • 150
  • 156
1
vote
0 answers

Lua test suites: coroutines test fails under vxWorks 6.9

I'm trying to integrate Lua 5.3 under vxWorks 6.9. I currently have a problem while running the test suites to check Lua integration with my sistem. I'm running the tests that are proposed on the lua.org website (http://www.lua.org/tests/). I've…
RickyBO89
  • 21
  • 4
0
votes
1 answer

Lua nested table get all elements from table if element in table is set to True

Fruits = { apple = { ordered = true, amount = 10 }} i have several different kinds of fruits in this table and i need to output everything where ordered=true to make it look like this: apple ordered: true | apple amount: 10 Made it like this for…
0
votes
0 answers

How can i make this code readable lua 5.4

Is there anyway to make this code readable. it just one of them. it really waste time when doing it by manual. this file was decompile from bytecode Full code link: https://anotepad.com/notes/k7nj9aft local L1_2, L2_2, L3_2, L4_2, L5_2, L6_2,…
0
votes
0 answers

attempt to index a nil value (global 'math'))

I am using lua to make scripts in my game, after updating the lua libs version from 5.1 to 5.3, an error appears on the game engine every time I use math.X in a function error : Lua run doFile failed.attempt to index a nil value (global…
0
votes
1 answer

How to Convert a string to lua code to read value from nested table

I have a configurable value of a table fetch function which i get as an input string. I need that string to be executed as a code and fetch a value from the nested table. I tried using load(string), its not working local function main() local t =…
Bhanu
  • 25
  • 9
0
votes
3 answers

laravel get user info by routing to '/user/{username}' Not Working

i am new to laravel and i am having trouble getting the user info by going to the route 'user/{username}'; theoretically it should work, this is my route: Route::get('/user/{username}', function($username){ $user =…
red security
  • 193
  • 3
  • 14