It looks like you're new here. If you want to get involved, click one of these buttons!

- 6.6K All Categories
- 3.7K General questions
- 87 Roadmap
- 289 Game & application design
- 257 Plugins
- 54 User experience
- 66 Marketplace
- 228 Code snippets
- 33 Building a team?
- 228 Suggestions & requests
- 314 Announce your apps made with Gideros.
- 81 Step by step tutorials
- 515 Bugs and issues
- 160 Introduce yourself
- 155 Announcements
- 63 Forum talk
- 369 Relax cafe

SinisterSoft
Maintainer

The Gideros version of Lua has some extra operators not present in regular Lua.

Two of them are <> and >< (remember these are custom to Gideros Lua)

<> is used to compare two numbers and return the greater of them

>< is used to compare two numbers and return the lesser of them

You may not think so initially, but these are two really handy operators and can save your game both a lot of code and cpu time.

eg:

Instead of this:

Both of these routines will produce:

To limit a number going up just use the other operator:

Two of them are <> and >< (remember these are custom to Gideros Lua)

<> is used to compare two numbers and return the greater of them

>< is used to compare two numbers and return the lesser of them

You may not think so initially, but these are two really handy operators and can save your game both a lot of code and cpu time.

eg:

Instead of this:

pos=10 function gameLoop(e) x=x-1 if x<5 then x=5 end print(x) . .</pre> You can put this: pos=10 function gameLoop(e) x=(x-1)<>5 print(x) . . |

9 8 7 6 5 5 5 and so on... |

pos=10 function gameLoop(e) x=(x+1)><15 print(x) . .</pre> This will produce: 11 12 13 14 15 15 15 and so on... |

## Comments

Likes: SinisterSoft, pie

http://SinisterSoft.com

http://facebook.com/WhatRhymesWithMartians

http://SinisterSoft.com

http://facebook.com/WhatRhymesWithMartians

Likes: SinisterSoft

http://SinisterSoft.com

http://facebook.com/WhatRhymesWithMartians

a <> b

to find the lesser

a >< b

to convert from degrees to radian

^< a

to convert from radians to degrees

^> a

bitwise operators

a|b bor

a&b and

~a not

a~b xor

a<<b shift a left by b bits

a>>b shift a right by b bits

a//b integer divide use instead of floor(a/b)

macros

pi@3.142 set pi to 3.142 - isn't a variable so it acts like a constant

also the saving/loading of lua byte code is universal between different processor word sizes - eg 32 and 64 bit - unlike regular Lua.

http://SinisterSoft.com

http://facebook.com/WhatRhymesWithMartians

Likes: SinisterSoft

Likes: antix, Atavismus

http://SinisterSoft.com

http://facebook.com/WhatRhymesWithMartians