Create Table ----> lua

Just starting out? Need help? Post your questions and find answers here.
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Create Table ----> lua

Post by lambor734 »

Hi All ,

How can create table in lua?
I want some method by it I create.

For example :

Code: Select all

s={}
function s.lua()
 return 1
end

function s.pb()
 return 0
end

And more ...
But I'm using the library liblua5.1.lib , And how to create them in the library I do not know. :(
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

For example, how is the following function will call such methods?

Code: Select all

ProcedureC MsgBox_Lua(L.l)
  
  If lua_type(L, 1) = #LUA_TSTRING
    Protected param1.s = PeekS(luaL_checkstring(L,1))
  Else
    lua_myError(L,"Wrong type of parameter 1. String expected!")
  EndIf
 
  If lua_type(L, 2) = #LUA_TSTRING
    Protected param2.s = PeekS(luaL_checkstring(L,2))
  Else
    lua_myError(L,"Wrong type of parameter 2. String expected!")
  EndIf
 
  If lua_type(L, 3) = #LUA_TNUMBER
    Protected param3.l=luaL_checknumber(L,3)
  Else
    lua_myError(L,"Wrong type of parameter 3. Number expected!")
  EndIf
 
  lua_pushnumber(L,MessageBox_(hWndMain,param1,param2,param3))

  ProcedureReturn 1
EndProcedure

lua_register(L,"MessageBox", @MsgBox_lua())
Call

Code: Select all

lua.MessageBox("","",0);
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

Please F1 . :lol:
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Re: Create Table ----> lua

Post by Tomi »

Hi lambor734, I don't knoe an answer to your question exactly, but i know you can use Dim instead Table :D
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

Thank You my friend,
But if you can explain further.
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Re: Create Table ----> lua

Post by Tomi »

i no have expert in pb as good, sorry :oops:
maybe this topic can be help you:
http://www.purebasic.fr/english/viewtop ... ilit=Table
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

Oh no, I do not want to simulate.
I want lua internal commands, the method I created.
buddymatkona
Enthusiast
Enthusiast
Posts: 252
Joined: Mon Aug 16, 2010 4:29 am

Re: Create Table ----> lua

Post by buddymatkona »

The general use of lua is outside the scope of this forum. If you are asking how to call C-compatible functions in a library, there are examples already in the forum. Specific lua interface information can be found in .h files. All functions from the auxiliary library for example are defined in header file lauxlib.h and have a prefix luaL_.
lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

Ok, but this library is designed for Pb, and discuss it's free. :wink:
However, many of my friends like cas helped. :D
I hope everyone in this case is about to raise. 8)
User avatar
Tomi
Enthusiast
Enthusiast
Posts: 270
Joined: Wed Sep 03, 2008 9:29 am

Re: Create Table ----> lua

Post by Tomi »

lambor734
User
User
Posts: 40
Joined: Sun Dec 19, 2010 7:46 pm
Location: ovanaro

Re: Create Table ----> lua

Post by lambor734 »

Ok,thank you. :wink:
Post Reply