Results 1 to 2 of 2

Thread: lua script embedding

  1. #1

    lua script embedding

    Is anyone using lua together with delphi here? How can lua access delphi variables? Thanks for your answer in advance!
    http://3das.noeska.com - create adventure games without programming

  2. #2

    lua script embedding

    meanwhile i discovered that setting (exporting) a global var to lua goes like:

    Code:
      
      //set global var A with value 10
      //this pushes the globals table of state L
      lua_pushvalue(L, LUA_GLOBALSINDEX);
      //this sets a key in the globals table of L
      lua_pushstring&#40;L, 'a'&#41;; //Be aware lua vars are case sensitive!! a<>A
      lua_pushnumber&#40;L, 100&#41;;
      lua_settable&#40;L, LUA_GLOBALSINDEX&#41;; // global noot = "mies"
      //end set
    And reading a global var from lua to delphi goes like:

    Code:
     //read global var from lua
      //this pushes the globals table of state L
      lua_pushvalue&#40;L, LUA_GLOBALSINDEX&#41;;
      lua_pushstring&#40;L, 'result'&#41;;
      lua_gettable&#40;L, LUA_GLOBALSINDEX&#41;;  // global aap
      writeln&#40;'Delphi&#58; '+floattostr&#40;lua_tonumber&#40;L, -1&#41;&#41;&#41;; //why -1?
      //end read
    This should get me going.

    But on looking on the lua maillist archive i read it should be possible to use c++ classes from within lua? Does this also go for delphi objects? How?
    http://3das.noeska.com - create adventure games without programming

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •