FAQ Database Discussion Community


how to compare spanish character in Lua

lua
I have to compare the contents of a lua variable with a string having spanish characters e.g. if is equal to bisción. if myvar = "bisción" does not work when myvar contains the same value. I could not find anything relevant to this in Lua documentation except setting the locales...

Get value at index in table

lua,lua-table
Is it possible for me to cycle this table asynchronously without really checking state? I would like to be able to do something colors[count % 6] or similar where I don't need to check explicitly which state (count) I'm at. colors = { red = {max.R,0,0}, green = {0,max.G,0}, blue...

Erlang spawning large amounts of C processes

c,multithreading,lua,erlang,ffi
I've been looking into how I could embed languages (let's use Lua as an example) in Erlang. This of course isn't a new idea and there are many libraries out there that can do this. However I was wondering if it was possible to start a Genserver with state which...

C++/Lua: Implement Qt/QtLua with QWebView

c++,qt,lua,cross-platform,qwebview
I'm planning to write a cross-platform project in C++, which will run a Lua engine. I'd like to write the main program for that project including the GUI in Lua. And to make it even easier, I want to write the GUI in HTML and therefore I need an additional...

Lua - Function That Creates Detours

class,oop,pointers,lua,clone
I need to make several detours to various functions and doing it one by one is just not an option. I'm looking for a function that will take a table, ideally, and this table is class. Loop through it and for each key, value pair that is a function make...

Corona sdk not view random text

text,random,lua,corona
I'm have a problem because when I touch my button sometimes my text doe not appear and I do not understand what is wrong. Code: function randomText(event) display.remove(mmDis) local a = {"Cristiano ronaldo jest najlepszy!", "messi jest dobry!","lewandowski jest ok","diego lopez to bramkarz realu"} com = (a[math.random(1,#a)]) local mmDis =...

Lua sessions with dedicated “consoles” in multithreading environment

multithreading,lua
There are many Lua sessions (each one represented by its own lua_State) in an embedded multithreading program written in C++. Each Lua session has a dedicated "console" represented by a C++ object. This "console" is intended to provide session-specific stdin/stdout/stderr streams. What's the right way to deliver such a "console"...

Lua in-place initialized table order

c++,lua
I want to be able to do the following: MyObject:SetSize( { 10.0, 20.0 } ) But when I iterate over this on the C-side (SetSize is a C function). The order of the parameters is random. This is the C++ side processing the table: glm::vec2 State::PopVec2() { glm::vec2 v(); lua_pushnil(...

Lua 5.3 undefined references

c++,lua
I am trying to learn how to embed lua in a C program, but I am not great at reading technical documents, and I haven't found any current tutorials. This is my program: #include <iostream> #include <lua.h> #include <lualib.h> #include <lauxlib.h> void report_errors(lua_State*, int); int main(int argc, char** argv) {...

Lua os.tempname

lua,temp
The file names returned by the Lua os.tempname function are weak in two respects Unlike most other languages it is not possible to define a custom prefix for the file name The _6char suffix that is generated can, with brute force but nevertheless, be guessed I have at times used...

Call download lua script in app

c++,lua
I am trying to develop a game by using the c++ with lua, and I am using the quick-cocos2d-x engine to help me finish that. The problem is: I need user to download the lua scripts into their sdcard on their iphone/android devices, so that I can call the function...

Torch Lua: Why is my gradient descent not optimizing the error?

lua,neural-network,backpropagation,training-data,torch
I've been trying to implement a siamese neural network in Torch/Lua, as I already explained here. Now I have my first implementation, that I suppose to be good. Unfortunately, I'm facing a problem: during training back-propagation, the gradient descent does not update the error. That is, it always computes the...

How to disable omp in Torch nn package?

lua,openmp,torch
Specifically I would like nn.LogSoftMax to not use omp when the size of the input tensor is small. I have a small script to test the run time. require 'nn' my_lsm = function(t) o = torch.zeros((#t)[1]) sum = 0.0 for i = 1,(#t)[1] do o[i] = torch.exp(t[i]) sum = sum...

Convolution Neural Network in torch. Error when training the network

lua,neural-network,torch
I am trying to base my Convolution neural network upon the following tutorial: https://github.com/torch/tutorials/tree/master/2_supervised The issue is that my images are of different dimensions than those used in the tutorial. (3x200x200). Also I have only two classes. The following are the changes that I made : Changing the dataset to...

How to move and rotate an image at the same time in Corona?

lua,corona
I am trying to throw throwing stars in a game. I can move the star with bulletTransition[bulletCounter] = transition.to(bullets[bulletCounter], {x=-250, time=2000, onComplete=function(self) if(self~=nil) then display.remove(self) end end}) I know I can rotate things with transition.to( bullets[bulletCounter], { rotation = bullets[bulletCounter].rotation-360, time=2000, onComplete=spinImage } ) But how do I make the...

conditional assignment of multiple values

lua,variable-assignment
I've got a function that either can take two parameter, or calls another function to retreive these values(semi-defaults in that case). Let's say the first function looks like this: -- the actuall issue function: function foo( param_1, param_2 ) local bar_1, bar_2 = param_1, param_2 or getBar() -- make funny...

Fast way to initialize a tensor in torch7

for-loop,matrix,lua,deep-learning,torch
I need to initialize a 3D tensor with an index-dependent function in torch7, i.e. func = function(i,j,k) --i, j is the index of an element in the tensor return i*j*k --do operations within func which're dependent of i, j end then I initialize a 3D tensor A like this: for...

How to permanently add directory to Lua search path?

lua,torch
What's a simple way to permanently add a directory to the Lua search path?

Yaw, pitch, and roll rotations to six float variables

lua,calculus,angles
I need help creating a function to convert three angles (in degrees, yaw pitch and roll) to six float variables. How would I go about making a function output these floats? {0, 0, 0} = {1, 0, 0, -0, -0, 1} {45, 0, 0} = {0.70710676908493, 0.70710676908493, 0, -0, -0,...

EventListener firing for every image subscribed instead of just the one?

lua,corona
I am dynamically creating images and assigning them an event listener, when I tap the image the event for all images fire, instead of just the one I tapped. I would expect it just to fire the once so where have I gone wrong? math.randomseed(os.time()) for i = 1,20 do...

Luajit: accessing objects of type cdata from C or C++

c++,c,lua,luajit
All is in the title... Apparently it is not possible to convert cdata to userdata, and I couldn't find any function in the C api to push/retrieve cdata to/from the stack. Maybe there's a simple and recommended way to do it that I haven't noticed? Thanks for your help.

Processing special characters

string,character-encoding,lua
Let's say I receive the following string in Lua mÜ⌠⌠í∩and would like to apply it to my current processing code, which is the following function inTable(tbl, item) for key, value in pairs(tbl) do if value == item then return true end end return false end function processstring(instr) finmsg = ""...

lua check for table on stack from c api

c,lua
I could find a lot of information how to retrieve the values of the table in lua from the stack in C api, however I am experiencing a bit different problem - when my function is called without the table passed my programs crushes without any warning. Which leads me...

What's the type of the anonymous function in Lua?

lua
In Lua reference manual, it says that every value has a type which might be one of the local, global, table field types. My question is what's the type of the anonymous function in Lua? What life cycle the anonymous function has? I just show an example. local co =...

Unable to figure out lua table inheritence

lua
Hope someone can make sense of what I'm attempting to figure out, Just don't seem to understand Lua enough to achieve this. --[[ tbl.a.test("moo") returns "Table A moo appears" tbl.b.test("moo") returns "moo appears" ]] tbl = { a = { ID = "Table A" }, b = { test =...

Lua error loading module 'libpng' (Torch, MacOSX)

osx,lua,osx-yosemite,libpng,torch
How do I make libpng load properly in Lua? I am running Lua/Torch in iTorch Notebook in Mac OSX 10.10.3, where other basic functions in Lua work, such as plotting and calculations. brew install libpng Warning: libpng-1.6.17 already installed If I run: require 'nn'; require 'image'; itorch.image(image.lena()) error loading module...

storyboard.removeScene(“scene name”) is not working

android,gridview,lua,corona
I am new to corona sdk and trying to build sample in it. i want to get back to main screen automatically after some time by destroying my scene(i mean that scene destroys itself after some particular time and user get back to main screen).I know that for some this...

Write to file using Lua FFI

file,lua,ffi,luajit
I am trying to use Lua FFI using LuaJIT to append some text to a file, but I am not very knowledgable of C, so I have some trouble. This is the code: local ffi = require "ffi" ffi.cdef[[ typedef int __kernel_ssize_t; typedef __kernel_ssize_t ssize_t; ssize_t write(int fildes, const void...

Awesome desktop manager widgets

lua,widget,awesome-wm
I came upon this problem before, but only now it really renders awesome desktop manager useless. I was searching how to connect to Wifi with awesome. Found Gigamo Wifi Widget. Cool, how do I eat it? The awesome wiki entry on widgets does not really answer this question. I know...

Torch tensor equivalent command to matlab's “find”?

lua,torch
In a nutshell, I would like to know if there is a tensor command in torch that gives me the indices of elements in a tensor that satisfy a certain criteria. Here is matlab code that illustrates what I would like to be able to do in torch: my_mat =...

Luasocket + nginx error - lua entry thread aborted: runtime error: attempt to yield across C-call boundary

nginx,lua,luajit,luasocket,luarocks
When I use the following script: local smtp = require("socket.smtp") local from = "[email protected]" local rcpt = "[email protected]" local msg = { headers = { to = rcpt, subject = "Hi" }, body = "Hello" } smtp.send{from = from,rcpt = rcpt,source = smtp.message(msg)} I'm getting an error message: lua entry...

Lua in pairs with same order as it's written

loops,lua,order,lua-table
Is there any way to loop trough a table like the one below in the same order as it's written? local tbl = { ["hello"] = 1, [2] = 2, [50] = 3, ["bye"] = 4, [200] = 5 } What I mean is that when I use "in pairs"...

Trouble connecting to ESP8266 NodeMCU Server

html,http,lua,arduino,wifi
I have been having trouble connecting to my ESP-01 Wifi module running NodeMCU. I have set up a simple server, but whenever I try to connect to the IP Address via my browser, my browser times out. I know I am making connection to the device because I can see...

Redis Cluster: Find which master holds particular key/slot

lua,redis
I'm using Redis Cluster, and some keys have a special prefix {foo}, so redis puts them in one slot. I do this because i want to run some lua scripts against these keys (i can do this if i login to the master as a single instance). In my setup...

Understanding nested for/in loops with “ipairs”

lua,lua-table
Can some body help me to understand this piece of code? local dev for _, dev in ipairs(devices) do local net for _, net in ipairs(dev:get_wifinets()) do netlist[#netlist+1] = net:id() netdevs[net:id()] = dev:name() end end ...

How do I do user inputs on the same line in Lua?

input,io,lua
Here is my code: while true do opr = io.read() txt = io.read() if opr == "print" then print(txt) else print("wat") end end What I'm trying to do is make it where you type print and then whatever you want like this: print text And it'll print text but I...

Strange C syntax in Lua library

c,lua,torch
I see functions like this throughout the torch library's C code: long THTensor_(storageOffset)(const THTensor *self) { return self->storageOffset; } Is this a preprocessor thing, or something lua specific? The idea, I think has something to do with the fact that storageOffset is a method of sorts on the THTensor "class",...

How to set a custom icon of any client for the tasklist in awesomeWM v3.5.6?

lua,awesome-wm
if (c.class == "Google-chrome") then c.icon = capi.image ( "/home/art-attack/.config/awesome/icons/chrome.png" ) end I tried it but I always got an error i.e attempt to call field 'image' (a nil value) { rule = { class = "Google-chrome" }, properties = { icon = beautiful.icon_chrome } }, Then I find another...

How to Draw Circle, incrementally, to create an animated fill effect (using Corona)

lua,geometry,corona,geometry-surface
I'm having trouble even figuring out where to start with this. ANY help would be highly appreciated! Using the Corona SDK I want to draw a circle that will slowly fill as a percentage increases. The fill effect will follow the path of the circle, going anti-clockwise until the entire...

Lua - Is it possible to check if 2 functions are equal?

function,lua,byte,equals
Is it either possible to get the size of a function in bytes to see if it matches another function similar to C++ sizeof operator, or evaluate two functions some other way to see if they are both equal without actually knowing what the function/s are? Example: local function equals(func1,...

Reading Lua Table from C++

c++,lua
I have tried many alternatives for this simple thing but could not get it work. I want user to define a table from Lua in the 1st step: a={["something"]=10} -- key=something, value=10 Then, in the second step the user will call from Lua a function designed in C++: b=afunction(a) --...

Lua math.random returns erratic values

random,lua
I was wondering why I had invalid data for a script, then I tried to test math.random since it seemed to be coming from it's return values. This is what I got from the Lua console : > return math.random(0.8, 1.2); 0.8 > return math.random(0.8, 1.2); 0.8 > return math.random(0.8,...

Is there an option to make LuaJIT do bounds checking?

lua,luajit
LuaJIT knows the C types it defines, and the lengths of the arrays, but it doesn't check the bounds: ffi = require("ffi") ten_ints = ffi.typeof("int [10]") p1 = ten_ints() print(ffi.sizeof(p1)) -- 40 var_ints = ffi.typeof("int [?]") p2 = ffi.new(var_ints, 10) print(ffi.sizeof(p2)) -- 40 p1[1000000] = 1 -- segfault p2[1000000] =...

lua - table.concat with string keys

lua,lua-table
I'm having a problem with lua's table.concat, and suspect it is just my ignorance, but cannot find a verbose answer to why I'm getting this behavior. > t1 = {"foo", "bar", "nod"} > t2 = {["foo"]="one", ["bar"]="two", ["nod"]="yes"} > table.concat(t1) foobarnod > table.concat(t2) The table.concat run on t2 provides no...

Lua string.match utf - asking for spanish character - getting half portuguese

utf-8,lua,pattern-matching
Hi the following code in Lua: letters = "Vocéá" print(string.match("¡Você","["..letters.."]+")) returns: �Voc� if I replace é with regular e and get rid of á then I get "Voc". seems that á interferes with ¡, and é with ê. Could it be that they share a byte in common? I am...

How to use table listeners in corona sdk and how it works?

lua,corona
can any one explain to me table listeners ? how to use it? when and why? and explain to me the following code local object = display.newImage( "ball.png" ) object.id = "ball object" local function onObjectTouch( self, event ) if event.phase == "began" then print( "Touch event began on: "...

How to match pattern 2.0.0.XXX in lua?

lua,pattern-matching,string-matching
How can I match the pattern 2.0.0.xxx in lua? I want a pattern which can match all such patterns. Example: If a = 2.0.0.100 and b=2.0.0.200 c= 2.1.0.122 d=2.0.1.122 only a and b should match the pattern...

Strange behaviour of lua code (AwesomeWM config)

lua,awesome-wm
With this piece of code in my rc.lua (configuration file of AwesomeWM) I get what you see in image bellow: mybattmon = wibox.widget.textbox() function battery_status () local output={} local fd=io.popen("acpi", "r") local line=fd:read() while line do local battery_load = string.match(line, "(%d*)%%") local discharging if string.match(line, "Discharging")=="Discharging" then discharging="-" elseif string.match(line,...

OLE Automation date in lua

lua,ole
Ok, I really need OLE Automation date in lua. From here: public double ToOADate() Return Value Type: System.Double A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance. So in C# this: Console.Write("DateTime.Now.ToOADate() = " + DateTime.Now.ToOADate()); gives me this: DateTime.Now.ToOADate() = 42146,4748270602...

How to use xpcall with a function which has parameters?

lua
On this website there is an example on how to use xpcall on a function without parameters. But how can i use xpcall on a function like this: function add (a, b) return a + b end And it should get the return value. This is my attempt (does not...

Lua: how to check whether a process is running

process,lua
I would like to start a process from Lua and monitor whether the process is still running. [EDIT] I know starting can be achieved by os:execute, but this is blocking. I would like to find a way to start a process non-blocking and monitor whether it still runs....

Stop a playback in Freeswitch

audio,lua,playback,freeswitch
I have some code in Lua that answers a call, and after performing a series of operations bridges the call to a new leg. The operations take from a few seconds to several minutes. To keep the client I need to play a sound the issue I have is that...

How can I use i++ and ++i from C in Lua

lua
Is there a way to use i++ instead of i = i + 1 in Lua? I think it might be possible since Lua can use C functions directly. ...

How to iterate through a table in its exact order?

loops,for-loop,lua,order
If i try to output this table, they are looped through in the false order: local letters = {DIN1="hi", AIN1= "my", AIN2 ="name", DIN2="is"} for name, value in pairs(letters) do print(name,value) end Expected Output: DIN1 hi AIN1 my AIN2 name DIN2 is Output: AIN1 my DIN2 is DIN1 hi AIN2...

Lua import strings from file

string,variables,lua
I can't load my user.db into Lua. user.db contains: user1="XYZ1" user2="Xzy2" .... admin="ZXY" Some Bash and Python scripts use the same db. For Bash e.g. I used the source user.db command, but I don't have a clue for lua. Should be something similiar outside?! I tried the require function but...

Supporting “recursive objects” in lua

class,lua
I'm fairly new to lua and have the following problem with an assignment from a class: We currently extend lua to support objects and inheritance. The Syntax for that is Class{'MyClass', attribute1 = String, attribute2 = Number } Class{'MySubClass', MyClass, attribute3 = Number } This works perfectly fine. The real...

2D Line reflection on a “mirror”

math,lua,love2d
So I've been working at this on and off for a week, googling and all and I haven't found how to do this. I have a table of "rays" and a table of "lines", and I want the lines to act as mirrors and reflect a ray whenever the ray...

Sorting 2D boxes into larger boxes to fill in the most efficient and complete manner

sorting,lua,2d,love2d
Background: Hello, so I've been working on this function for a bit and I'm stumbling. Ultimately, what I'm trying to accomplish is to have an application where a user inputs larger boxes, and also inputs a list of smaller boxes. (All 2 dimensional, by the way). The program then processes...

Draw an ellipse sqrt-based function

vb.net,plot,lua,draw,ellipse
I'm trying to make a function in Lua or VB based code to draw / plot an ellipse and also a filled ellipse. I don't have much knowledge about this math and I can use some help. I googled everything there is to google about drawing ellipses with code but...

Write lua_requiref in lua5.1

module,lua,load
I would like to use the function lua_requiref, but in lua5.1. Is there a way to get the effect of lua_requiref in lua 5.1?...

lua 5.3 + luasocket 3.0rc1-2: undefined symbol: luaL_setfuncs

nginx,lua,luasocket,luarocks
I have Luasocket 3.0rc1-2 installed through luarocks with Lua 5.3 running on the server. When I run a script requiring luasocket on nginx (1.8.0) with LuaJIT (2.1), it produces an error message: lua entry thread aborted: runtime error: error loading module 'socket.core' from file '/usr/local/lib/lua/5.3/socket/core.so': /usr/local/lib/lua/5.3/socket/core.so: undefined symbol: luaL_setfuncs On...

horizontal movement in game (rotated player)

math,lua,logic,love2d
In my world I have a character wich is always rotated towards the mouse. It is very logical that when the player moves forward or backward, that the character's x coordinate equals it's x coordinate minus (or plus) the cosine of its x coordinate. And the same for its y...

Find the nearest value

lua,lua-table
I'm looking for a way to find out which value is closest to x in a table and return that. Lets assume, for a second, X is x=15, we have the table with 4 values {12, 190, 1, 18}, How do I make it so in this case the first...

Reading a table when function has many argument return an error

c++,arrays,lua,arguments,lua-table
I'm trying to read an array inside a Lua function in a library that I'm developing. When I call the function with one argument, like xyz = {3, 4, 5} setxyz(xyz) I read the array correctly, while if I add a second argument xyz = {3, 4, 5} setxyz(xyz, 3)...

Luarocks can't install a library

lua,luarocks
I want to install this library: https://luarocks.org/modules/dodo/lua-dbus I do luarocks search lua-dbus There are 0 results. sudo luarocks install lua-dbus doesn't install anything as well. The problem is only with this library, because I can search for other libraries on luarocks, for example luarocks search socket gives plenty of matches....

Recursive loop stopping after a short time

lua,computercraft
Lua in ComputerCraft 1.5 This seems to work but the recursive loops is breaking after 4 or 5 times running. Cannot seem to see why. Am i doing something incredibly wrong here? Full Code Snippet for the loop: x = 1 function loop() if x > 0 then getTarg() derp1()...

Check if value exists in Lua table

json,lua
I am running Lua on ESP8266 Wifi module with NodeMCU firmware. My application is listening on TCP port for JSON requests. When I get the request I parse it using: jsonRequest = json.decode(request) So then I can access desired value with: jsonRequest.object.state Everything works perfectly until I send an invalid...

Nginx disable or decode url encoding when writing to access log

nginx,lua,openresty
I have an open resty nginx with lua code that enhance the data and then I write this data to the access log for data analysis. The data that the lua code produce includes double quotes but nginx write it to the access log as \x22. Can I disable this...

Lua search through table

lua,corona,lua-table
I am working on a game project using Corona SDK and I am running into an issue. I am trying to use string.find() in a for loop to test to determine if a value is in a certain table and if so, add that value to another table. My problem...

Building Latex/Tex arguments in lua

lua,latex,tex
I use lua to make some complex job to prepare arguments for macros in Tex/LaTex. Part I Here is a stupid minimal example : \newcommand{\test}{\luaexec{tex.print("11,12")}}% aim to create 11,12 \def\compare#1,#2.{\ifthenelse{#1<#2}{less}{more}} \string\compare11,12. : \compare11,12.\\ %answer is less \string\test : \test\\ % answer is 11,12 \string\compare : \compare\test. % generate an error...

How can I convert a character code to a string character in Lua?

string,lua
How can I convert a character code to a string character in Lua? E.g. d = 48 -- this is what I want str_d = "0" ...

Multiline function tables in lua

lua
I cannot seem to find any other online help about creating a table which contains functions which are multiline. For example, here is a snippit of code from the lua wiki. action = { [1] = function (x) print(1) end, [2] = function (x) z = 5 end, ["nop"] =...

Arrange lua/lualatex data in a Latex/tex tabular

lua,latex,tex,tabular
I have data in lua, accessible to a LaTeX/TeX document (it is an array). I try to show this data in a LaTeX tabular form. I tried several ways to do this but all failed :( . Here is an example : \begin{tabular}{|c|c|c|}\hline A&B&C\\ \hline 2010 & 2,78 &\\ \hline...

How do I simplify to load some files in the corona?

lua,corona,corona-storyboard
I am new to corona, all the work is from a scratch of others. Let see, I have 3 images that entitled shop1price shop2price shop3price. Now I want it to be simplified as the code below local options = { { defaultFile = 'images/shop1price.png' }, { defaultFile = 'images/shop2price.png' },...

Initialization of Class using malloc()

c++,c,lua,malloc,new-operator
How should a c++ class be used when its memory has been reserved from a C malloc? I'm using a C library (lua) and I need to expose a C++ class to it, in this case in order to garbage collect these reserved space, lua does the memory reservation. A...

Return multiple values to a function, and access them separately in Lua?

lua
If I have a function that returns multiple values, how can I access those values separately? Something like table[i]. angles = function() x = function() local value = 0 return value end y = function() local value = 90 return value end z = function() local value = 180 return...

Using luac file on Nginx

nginx,lua
I have been experimenting with using Lua in Nginx - quite a neat little capability which I can use effectively. However, one of my concerns relates to IP protection so I thought I would use an online tool to compile my, fully tested, LUA script. I tried https://luac.mtasa.com/. I uploaded...

Lua microseconds sleep

lua,sleep
Ok, I need to wait (for instance) for 10 us in my lua script. Is there any way to do it? For now I use this simple (non busy-waiting) function using socket: function my_utils.sleep(sec) socket.select(nil, nil, sec) end but it seems its "sleep minimum" is milliseconds. Example 1: for x=0,2*math.pi,0.008...

get index of subtable from function args in lua

function,variables,lua,arguments
Im trying to return the value of an index of a table which is inside of another table and am doing so using the args given when a function is run so that the arg resolves to a variable name. function getsubindex(varname,index) local tbl = {} tbl.first = 99 tbl.subTbl...

lua-socket: unix domain sockets?

sockets,unix,lua
I'm using lua-socket 3.0rc1.3 (that comes with Ubuntu Trusty) and lua 5.1. I'm trying to listen on a unix domain socket, and the only example code I can find is this -- send stdin through unix socket socket = require"socket" socket.unix = require"socket.unix" c = assert(socket.unix()) assert(c:connect("/tmp/foo")) while 1 do...

Run Lua script from Python

python,lua,lupa
Suppose I have a Lua script that contains 2 functions. I would like to call each of these functions with some arguments from a Python script. I have seen tutorials on how to embed Lua code in Python and vice versa using Lunatic Python, however, my Lua functions to be...

ROBLOX Lua Error in script: '=' expected near ''

lua,roblox
Hello I am writing a scipt on ROBLOX and I have encountered a problem. function showVictoryMessage(playerName) local message = Instance.new("Message") message.Text = playerName .." has won!" message.Parent = game.Workspace wait (2) message.Destroy() end Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script:...

How to organize time_stamps with values in lua?

lua
Create something like array of values associated with time_stamps, and getting values by time_stamps. only one value with one time_stamp. How better organise it? And how to remove values after goes some time? something like this: datetime = os.date("!*t",os.time()) array[datetime]=somevalue And how to delete from that table values older than...

How I get the cdata out in c function with variable arguments using luajit?

c++,c,windows,lua,luajit
Here is the code. The aim is to print messages. In PrintC, I would like to get e...but arrives as cdata. How can I unpack that or circumvent that? extern "C" { static int PrintC ( lua_State *L ) { // does not work cdata //executor* e = ( executor*...

Lua obfuscator, how to

lua
I understand this question will appear silly but I'm clueless what to do, which makes it even more silly. I have written a lua script for a game - which works, but I've never actually run any lua with the lua programs(from the site download). I would like to obfuscate...

How to output more than one column

csv,lua
I want to process a data file like this: 2015-02-23 190 170 131 14 8 9 130 85 102.0 12 68 2015-02-24 165 128 97 14 7 6 110 75 101.7 12 64 2015-02-25 160 123 129 11 5 7 130 85 101.3 12 68 2015-02-26 151 115 128 11...

sqrt-based filled ellipse pixel drawing function

vb.net,lua,draw,pixels,ellipse
I'm trying to make a function in Lua or VB based code to draw / plot a filled ellipse. I don't have much knowledge about this math and I can use some help. I Googled everything there is to Google about drawing ellipses with code but I can't find a...

Iterating over JArray in NLua

c#,lua,json.net,nlua
I'm trying to iterate over a JArray in NLua, but can't somehow. JArray's are treaten as userdata (what is userdata?) and thus can't be iterated over. Converting the JArray to an JValue[] with a c# method doesn't work either. There are two possible solutions as far as I can see....

MAMP or Mac nginx MySQL Lua

mysql,nginx,lua,osx-server
I've recently purchased a Mac Mini with the only purpose of being a server. I'm a C programmer, learning Lua and Obj-C at the moment. I'm trying to set up a website, a kind of CV/Personal Promotion site. I've been looking at MAMP for a while however, I would like...

Lua word search

arrays,lua,match,word,lpeg
How would I go about doing a multiple pattern search in Lua? (I have Lpeg set up). For example, say I'm receiving strings in a row, I'm processing one at a time, captalizing them and calling them msg. Now I want to get msg and check if it has any...

Statically Linking Lua in Cmake

c++,lua,cmake
I have a project that uses GLFW, GLEW, GLM, and Lua. Previously I was using a Makefile on my Linux environment which linked the libraries, some static, some dynamic. Based on this boilerplate project I can compile and link GLFW, GLEW, and GLM to my project with Cmake. However I...

How to read Torch Tensor from C [closed]

c,lua,neural-network,luajit,torch
I have to train a convolutional neural network using the Torch framework and then write the same network in C. To do so, I have to read somehow the learned parameters of the net from my C program, but I can't find a way to convert or write to a...

Lua C++ Table Iteration

c++,lua
I am having a slight confusion of how lua_next really works. User defines a table: a={["a1"]=20,["a2"]=30} I want to print this table with a C++ code: inline int lua_print(lua_State* L) { wxString wxReturnStr=wxEmptyString; wxString tempString=wxEmptyString; int nargs = lua_gettop(L); for (int i=1; i <= nargs; i++) { int type =...

With multiple versions of Lua installed is it possible to specify which one luarock to install to?

lua,conflicting-libraries,luarocks
I have both Lua 5.1 and Lua 5.2 installed on Linux. When using luarocks to install a package is it possible to pass on option to luarocks that specifies which version of Lua the rock should be installed for?

Lua set default error handler

c,exception,error-handling,lua
The default lua_pcall error handler (as of Lua 5.3) does nothing, letting the exception message remain on top of the stack. We would like to change this so we get a luaL_traceback traceback in addition to the exception message on top of the stack on lua_pcall failure. Unfortunately I think...

Lua function selector

function,random,lua,selector
I have 3 functions. When the user presses the 'E' key I want it to select one of the functions (at random), I feel like it has something to do with math.random but I can't figure it out.

iterating over a table passed as an argument to a function in lua

for-loop,lua,iterator,lua-table
I am trying using the for _ in pairs() notation to iterate over a table within a function, but if I type anything, even gibberish like print('asdgfafs'), nested inside the for loop, it never gets printed. Code: record = {bid1,bid2,bid3} bid1 = {bidTime = 0.05,bidType = 'native'} bid2 = {bidTime...

Degree value to two float variables

lua,angles
I need help creating a function to convert an angle to two float variables. Here are some examples of the outputs: 0 degrees = {1, 0} ~31.0760 degrees = {~0.92823970, ~0.37198266} 45 degrees= {~0.70707070, ~0.70707070} 90 degrees = {0, 1} 135 degrees = {~-0.707070707, ~0.707070707} 180 degrees = {-1, 0}...

Close Lua State and Reopen

android,lua
I'm using Lua in android but is not very clear if I can do this: LuaState L = null; function loaddata(String data) { if ( L !=null && L.isClosed() == false) L.close(); L = LuaStateFactory.newLuaState(); L.openLibs(); L.LdoString(data); } loaddata(string_1) ; //and later loaddata(string_2); I want to clear the L and...

Computercraft Evaluate and Execute relative to ticks

lua,computercraft
For the sake of writing fast turtle programs, I am wondering how, in relation to ticks, is code executed? Is there a tick penalty for executing functions or evaluating other Lua statements in addition to the time it takes the turtle to move? In other words, does it take the...