Tampilkan postingan dengan label lua. Tampilkan semua postingan
Tampilkan postingan dengan label lua. Tampilkan semua postingan

Taking Random Values in Corona

Posted by Unknown Rabu, 06 November 2013 0 komentar
Syntax for taking random numbers or values in corona has been given below.
Download the code and try it...

Syntax
        math.random() 
        math.random( m ) 
        math.random( m, n )

math.random() ---> a number between 0 and 1
math.random(m) ---> an integer between 1 and n (inclusive)
math.random(m,n) ---> an integer between m and n (inclusive)
 

math.random() ---> a number between 0 and 1
math.random(20) ---> an integer between 1 and 20 (inclusive)
math.random(20, 40) ---> an integer between 20 and 40 (inclusive)


Baca Selengkapnya ....

Using For Loops inCorona

Posted by Unknown Selasa, 05 November 2013 0 komentar
Using For Loops in corona is very eazy.Copy and try the code below..
 
for i=1,20 do
print(i)
end

Baca Selengkapnya ....

String Functions In Corona

Posted by Unknown Sabtu, 02 November 2013 0 komentar
Here is a list of string function which are very useful...

string.byte() Returns the internal numerical codes of the characters in a string.
string.char()Returns a string in which each character has the internal numerical code equal to its corresponding argument.
string.find() Looks for the first match of a pattern in a string. If found, it returns the indices where the occurrence starts and ends; otherwise, returns nil.
string.format()Returns a formatted string following the description given in its arguments.
string.gmatch()Returns a pattern-finding iterator.
string.gsub()Replaces all occurrences of a pattern in a string.
string.len()Returns the length of a string (number of characters).
string.lower()Changes uppercase characters in a string to lowercase.
string.match()Extracts substrings by matching patterns in a string.
string.rep()Replicates a string by returning a string that is the concatenation of n copies of a specified string.
string.reverse()Reverses a string.
string.sub()Returns a substring (a specified portion of an existing string).
string.upper()Changes lowercase characters in a string to uppercase.

Baca Selengkapnya ....

Read A Text File in Corona

Posted by Unknown Minggu, 27 Oktober 2013 0 komentar
Reading a text file in corona is very eazy.First get the file path and using the file path read the content in the file. Check the code below.
  display.setStatusBar( display.HiddenStatusBar )
-- read the file path
local filePath = system.pathForFile( "myFile.txt", system.ResourceDirectory )

local file = io.open( filePath, "r" )
if file then
-- read all contents of file into a string
local contents = file:read( "*a" )

print( "The file path is" .. filePath )
print( contents )

io.close( file )

end


Copy and download the code and try your self.

Baca Selengkapnya ....

Tables In Corona

Posted by Unknown Jumat, 13 September 2013 0 komentar
The table constructor is written using braces
(curly brackets) as in { }

t = {}   -->create a table

k = "x"
t[k] = "tabvalue" --new table entry,
-->with key="x" and value=2.4

print( t[k] ) --> 2.4
print( t["x"] ) --> 2.4
print( t.x ) --> 2.4

t[2] = "tabval2" --new table entry,
-->with key=2 and value="tabval2"
t[3]= 2.4
print( t[2] ) --> "tabval2"
print( t[3] )

Baca Selengkapnya ....

Function in Corona

Posted by Unknown Kamis, 22 Agustus 2013 0 komentar
Using functions are very eazy in Lua.We can provide arguments as input (within the parentheses), the function performs some tasks, and the results can be returned.
Some ways to define functions are:
      
local function f ()
--body
end

local f = function()
--body
end

function f ()
--body
end

f = function ()
--body
end

Baca Selengkapnya ....

Types and Values In Corona

Posted by Unknown 0 komentar
Lua is a dynamically typed language. This means that variables do not have types; only values do. There are no type definitions in the language. All values carry their own type.
All values in Lua are first-class values. This means that all values can be stored in variables, passed as arguments to other functions, and returned as results.
nil — it usually represents the absence of a useful value.
boolean
 — represents two conditions 'false' or 'true'
number
 — represents real (double-precision floating-point) numbers.
string
 — represents arrays of characters. Lua is 8-bit clean: strings can contain any 8-bit character,   including embedded zeros.
function 
click here to get more details
table
 — the sole data structuring mechanism in Lua.

Baca Selengkapnya ....

Conventions In Corona

Posted by Unknown 0 komentar
Names or Identifiers in Lua can be any string of letters, digits, and underscores, not beginning with a digit. The following keywords are reserved and cannot be used as names:
          and     break        do          else     elseif      end        false
          for      function      if             in         local       nil          not
          or       repeat        return     then     true        until        while

The following strings denote other tokens: 

            +        -         *          /         %         ^        #
           ==      ~=       <=      >=       <          >       =
           (           )        {           }         [           ]
            ;           :        ,           .         ..          ...

Lua is a case-sensitive language.
Global variables:
Identifiers starting with an underscore followed by uppercase letters (such as _Global) are reserved for internal global variables used by Lua. 

Comments:

A comment starts with a double hyphen (--) anywhere outside a string. 
You can comment out a full block of code by surrounding it with   --[[..........]].
To uncomment the same block, simply add another hyphen to the first enclosure, as in
 ---[[.
      
--single line commented out
--[[ entire block commented out
print( 10 )
print( 15 )
]] 
A numerical constant can be written with an optional decimal part and an optional  decimal exponent. Lua also accepts integer hexadecimal constants, by prefixing them  with 0x. Examples of valid numerical constants are:
 3    3.0    3.1416    314.16e-2    0.31416E1    0xff    0x56 5    3.0    5.14    2314.16e-2    0.3456E1    0xff    0x56

Baca Selengkapnya ....

What is Corona?

Posted by Unknown Selasa, 20 Agustus 2013 0 komentar
Corona is cross platform game engine that supports Android and iOS. It’s developed by a company named Ansca, and you can use a free trial to try out Corona and develop your game. When you are ready to publish you are required to buy a license, prices range from $199 to $349.

You program in Corona with a programming called Lua, which is a lightweight and easy to use scripting language. There is no IDE for Corona (such as Xcode), instead you often program with a normal text editor. Corona comes with a simulator you can use to test your game as you’re coding it.

Corona has built-in APIs for the normal game programming aspects (sprites, sounds, etc.) as well as various APIs from the Apple including Game Center Leaderboards (new), In App Purchase, and TableViews (new).


Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.