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

- 6.7K All Categories
- 3.8K General questions
- 88 Roadmap
- 293 Game & application design
- 259 Plugins
- 57 User experience
- 66 Marketplace
- 233 Code snippets
- 33 Building a team?
- 231 Suggestions & requests
- 320 Announce your apps made with Gideros.
- 81 Step by step tutorials
- 533 Bugs and issues
- 161 Introduce yourself
- 159 Announcements
- 68 Forum talk
- 370 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:

You can put this:

Both of these routines will produce:

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

This will produce:

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) . . |

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) . . |

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