Giter Site home page Giter Site logo

mobilelua's Introduction

MobileLua

Update October 8, 2013

I no longer actively develop MobileLua. I will keep this repositry here, because it contains code that could be useful for future implementations of Lua on mobile devices.

Description

MobileLua is a port of Lua to MoSync, a C/C++ cross-platform development system for mobile devices. This enables Lua to be used on a wide range of mobile devices.

News (old)

MobileLua now wraps all functions and constants in the "mosync" namespace.

For example, when you previously wrote:

Screen:SetColor(255, 255, 255)

You now write:

mosync.Screen:SetColor(255, 255, 255)

The downloadable files for the LuaLive editor and client have been updated to use the new MobileLua version.

Note: The code for the old version of MobileLua that does not have the "mosync" namespace is available in branch "VersionOne".

Error handling

MoSync does not yet support exceptions or setjmp/longjmp, so Lua error handling is replaced with return in case of errors and check for error status. This is not implemented for all error conditions, so for some errors you can get incomplete error information, or in the worst case the program may hang or crash.

Example code

The following is a very simple paint application. Supports multi-touch.

-- Fill screen with background color.
mosync.Screen:SetColor(255, 255, 255)
mosync.Screen:Fill()
mosync.Screen:Update()

-- Function that paints a "brush stamp" on the screen.
function Paint(x, y, touchId)
  if touchId == 0 then 
    mosync.Screen:SetColor(0, 0, 0) 
  else
    mosync.Screen:SetColor(0, 200, 0) 
  end    
  mosync.Screen:FillRect(x - 20, y - 20, 40, 40)
  mosync.Screen:Update()
end    

-- Bind the Paint function to touch events.
mosync.EventMonitor:OnTouchDown(Paint)
mosync.EventMonitor:OnTouchDrag(Paint)

Contact

[email protected]
[email protected]

License

Unless stated otherwise, the MIT license is used for the source code.

Each source file should contain a license header.

mobilelua's People

Contributors

pkulchenko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.