Results 1 to 8 of 8

Thread: Lua is interesting

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Yes I must admit that LUA is quite good. I to started using LUA for the first time in Minecraft's ComputerCraft mod.
    And by using ComputerCraft mod along with RaillCraft mod I managed to make full automated raill system (automated departures based on predefined timetable, computer controllable raill crossings, each station had its own display with arrival times for incoming trains, etc.) but then the server got griefed and I lost everything.
    I wish ComputerCraft would alow Importing and Exporing LUA files in Multiplayer games.

    But if I ever decide to use a scripting language I would probably go and use DWScript instead. Why?
    Since DWScript bases on Delphi like language it means that I can quickly move part of the code from Script to native code or vice-versa by simply copying it. You can't do this with LUA. You would have to do translation from LUA to Pascal and vice-versa.
    Also based on many tests which you can find on internet DWScript has verry good performance in comparison to native Delphi code.

  2. #2
    So if you want to see a little retro like Lua interpreter, grab it on http://cmb.retrogamecoding.org/ (The zip contains binaries for Windows and Linux 32 & 64 bit). It might benecessary to instal liblua5.2 on Linux.
    Here's an example script for ChipmonkeyLua:
    Code:
    --' my favourite plasma demo
    --' ported from smallbasic to yabasic to lua with CMLua
    --' by cybermonkey
    activepage (1)
    cls()
    cols={}
      cols[0]={}
      cols[1]={}
      cols[2]={}
    
    for i=0,255 do
      cols[0][i]= math.abs(128 - 127 * math.sin(i * math.pi / 32))
      cols[1][i]= math.abs(128 - 127 * math.sin(i * math.pi/ 64))
      cols[2][i]= math.abs(128 - 127 * math.sin(i * math.pi / 128))
      end
    
    time1=gettickcount()
    for y = 1,599 do
       for x =1,799 do
          c = int((math.sin(x/35)*128+math.sin(y/28)*32 + math.sin((x+y)/16)*64))
    
         if c >255 then
          c = c - 256
         end
         if c < 0 then
          c = 256 + c
          end
    
          r = cols[0][c]
    
          if r > 255 then
        r = r - 256
          end
          if r < 0 then
        r = 256 + c
          end
          g = cols[1][c]
    
          if g >255 then
        g = g - 256
          end
          if g < 0 then
        g = 256 + c
          end
          b = cols[2][c]
          if b>255 then
        b = b - 256
          end
          if b < 0 then
        b = 256 + c
          end
    
          ink ( hrgb (r, g, b))
          pset (x, y)
    
        end
    end
    time2=gettickcount()
    ink (hrgb (0,200,200))
    locate (0,40,"")
    print ("Time needed: "..(time2-time1).." ms")
    visualpage(1)
    The result is this:
    cmlua1.jpg

    All is done in Free Pascal using (hold your breath ...): ptcgraph, ptccrt and ptcmouse units.

    It also has an interactive mode which looks like a vintage BASIC interpreter.
    cmlua3.jpg
    Best regards,
    Cybermonkey

  3. #3
    Lua IS awesome, but I've been thinking of redoing my old scripting language so I can use it easily on any platform I want

  4. #4
    Quote Originally Posted by SilverWarior View Post
    I wish ComputerCraft would alow Importing and Exporing LUA files in Multiplayer games.
    It does have shell commands for pastebin put and get. I wrote my programs with notepad++.

  5. #5
    Quote Originally Posted by User137 View Post
    It does have shell commands for pastebin put and get. I wrote my programs with notepad++.
    True but most Minecraft multiplayer servers have that blocked due to posible security risk of ComputerCraft.

  6. #6
    Found a minor bug, I use an international english layout to be able to use spanish (my primary language) accents, so " or ' chars need a space hit after to appear in any input. Unfortunately the interpreter didn't print/accept it, just the space. Setting back a US layout allows me to work fine.

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
  •