Questions tagged [lua-userdata]

A Lua type that allows arbitrary C data to be stored in Lua variables. It's used to represent new types created by an application program or a library written in C.

56 questions
0
votes
1 answer

Reuse lua_newuserdata() returned pointer

¿Is posible reuse lua_newuserdata() returned pointer? The idea is not allocate a new userdatum every time for the same object and allow equality check (example) done by lua. obj1 = c_api__foobar(); obj2 = c_api__foobar(); if obj1 == obj2 then …
kapodamy
  • 65
  • 8
0
votes
2 answers

LuaU script (Roblox), how can I make a Key get pressed with a script

An example would have been like local E = game:GetService('UserInputService').SetKeyDown(Enum.KeyCode.E) but it doesnt work ofcourse because i cant jsut make my game press E by itself with this thing, so it requieres soemthing longer and if you…
demxkero
  • 26
  • 1
  • 3
0
votes
1 answer

Attempt to call a userdata value

So i'm trying to make a part disapear when the player touch it but it says : Workspace.RedCastle.Grid.Script:1: attempt to call a userdata value Here's my code : script.Parent.Part.Touched(function(part) for i, part in…
Linkthehero2222
  • 305
  • 4
  • 16
0
votes
0 answers

lua - check if userdata is nil

I trying to use lua cjson to parse to following json : { "data" : null, "message" : "Your session has expired. Please login again.", "code" : "390112", "success" : false } it's parsed to the following map…
Eyal leshem
  • 995
  • 2
  • 10
  • 21
0
votes
1 answer

Converting Go Struct instance to Lua table

I have an instance of a Go Struct and will like to pass the instance to a Lua method using GopherLua. My Go code goes like this: dog := new(Animal) runParam := lua.P{ Fn: L.GetGlobal("run"), NRet: 1, Protect: true, } mt :=…
Sulaiman Adeeyo
  • 485
  • 6
  • 19
0
votes
3 answers

How to extend SWIG's userdata in Lua code?

I am using SWIG to bind C++ code to Lua. So far it looks good, but now I need to "cheat" and extend a single userdata from within Lua, adding custom fields and methods, etc. I can't find a way to accomplish it while working within SWIG's directives.…
Kaa
  • 677
  • 6
  • 17
0
votes
1 answer

Hand over global custom data to Lua-implemented functions

Within my Lua-application I have some own functions defined that are registered with lua_register("lua_fct_name","my_fct_name") so that they are known to the Lua script. Now I have some custom/user data that need to be accessible within…
Elmi
  • 5,899
  • 15
  • 72
  • 143
0
votes
3 answers

does Lua allow metamethods with weird number of arguments?

For example, can I declare a metamethod for __index which takes two arguments, then do something like myuserdata[somearg1, somearg2]? Not that I want to use it or that I have any idea of why it would be useful, I'm just wondering if in my library…
Lorenzo Pistone
  • 5,028
  • 3
  • 34
  • 65
-1
votes
1 answer

create lightuserdata in lua for luaglut glReadPixels

I'm using luaglut and when I try to use the glReadPixels to capture a frame, I cannot prepare the last input argument for it successfully. This is how I call the function: glReadPixels(0, 0, 250, 250, GL_RGB, GL_UNSIGNED_BYTE, img) The img is…
-2
votes
1 answer

Using C++ objects in Lua scripts

How I can use C++ objects in lua script? example class: class cMyClass { int a; void myTest(int b){}; } cMyClass MyObject; example using in lua(is what i need): MyObjectLuaName.myTest(7); MyObjectLuaName.a=12; Thanks!
Nataly
  • 15
  • 2
-4
votes
1 answer

Lua memory leak when add lua table in userdata object

When I pressed the 'btn' memory rose up from 80M to 240M. And I pressed the 'btn2' to remove the object(self.sprite) include many lua table, but the memory didn't go down. What wrong with this code? Or it is a lua bug? I used…
superyyl
  • 3
  • 3
1 2 3
4