External

This page documents content that I normally include in SSK2, but which has been sourced from external sources.

NOTE: To satsify the requirements of certain marketplaces hosting the SSK2 product, the external libraries/modules have been excluded from the product.

However, I think you will find this content useful, so I made it very easy to intgrate into SSK2.

Installing External Content

  1. Download the external content: CLICK HERE
  2. Extract external.zip to any folder.
  3. Copy the folder external/ into ssk2/
  4. Set useExternal to true, when initializing SSK2.

Done!


30Log (Roland Yonaba)

License: MIT

30 Lines Of Goodness is a minified framework for object-orientation in Lua.

It provides named and unnamed classes, single inheritance, metamethods and a basic support for mixins.

SSK2 external DLC includes the 'clean' version so it is legible.

30Log is loaded and ready to go. Simply read these docs to learn how to code with it.

AutoLan © M.Y. Developers

License

This is a modified version of the (now free) AutoLan by M.Y. Developers.

Subsequent to that release, I and a few other developers modified it to support IPV6. You can read more about that work HERE.

SSK2 Contains the IPV6 version of AutoLan and can be accessed under:

Globals Locker (Niklas Frykholm)

This module allows you to lock and unlock _G, the global table.

While you can modify existing globals during a lock, if you attempt to create a new global variable you will get an error message.

You can find the original version of this here: http://lua-users.org/wiki/DetectingUndefinedVariables

To Lock Globals

ssk.globals.lock( _G_ )

To Unlock Globals

ssk.globals.unlock( _G_ )

Portable Random (Community Code)

Note: This module was original found on the Corona Labs Community Code page, but it has since gone MIA. Fortunately, I have a copy in the SSK2 external DLC.

This module can be used to create a random number generating object that is guaranteed to produce the same sequence for the same seed on all devices. i.e. It is fully deterministic.

Warning: The generator ONLY produces integers in the range 0..255, so it may have limited usage.

Basic Usage


local prand = math.prand.new()

prand:seed(0xed15c001)

print( "Generated: ", prand:randInt( 0, 255 ) )
print( "Generated: ", prand:randInt( 0, 255 ) )
print( "Generated: ", prand:randInt( 0, 255 ) )

This will print (verify it yourself):

Generated:  73
Generated:  125
Generated:  25

Proxy (Corona Blog)

This is a handy little module that:

Adds the ability to detect when a property is changed on a display object.

~ Jonathan Beebe

I grabbed it from this cool blog post.

Example


local circle = display.newCircle( 100, 100, 10 )

circle.x = left
circle.y = centerY

circle = ssk.proxy.get_proxy_for( circle )

function circle:propertyUpdate( event )
    print(event.key, event.value)
end

circle:addEventListener( "propertyUpdate" )


transition.to( circle, { x = right } )

This will print x #### every time the circle is moved by transition. Cool, right?

RandomLua (LÖVE Community)

License: MIT

This is, yet another, Random Number Generator module.

It was released under the MIT License. I grabbed this from HERE.

While this module includes three different generators, I use the Mersenne Twister exclusively.

Mersenne Twister


local rng = ssk.randomlua.twister(10)

print( rng:random( 1, 1000 ) )

print( rng:random() )

print( rng:random(-100,100) )

print( rng:random(1.001, 10.005) )

RLE (Rosetta Code)

License: GPL v2

Given a string containing uppercase characters (A-Z), compress repeated 'runs' of the same character by storing the length of that run, and provide a function to reverse the compression. The output can be anything, as long as you can recreate the input with it.


local rle = ssk.rle

local testStr = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"

local compressed = rle.compress(testStr)

print( compressed ) -- Prints: 12W1B12W3B24W1B14W 

local testStr2 = rle.decompress(compressed)

print( "success? ", testStr == testStr2 )

Wait (StarCrunch)

License: MIT

Released under the MIT license by our very own Steve J. (aka StarCrunch of Xibalba Studios), this module contains a number of helpers for doing cool stuff with Coroutines.

Waiting Between Steps

local function testSeq()
    local start = system.getTimer()
    print("YO " .. tostring(start) )
    ssk.wait.ms( 500 )
    print("1 " .. tostring(system.getTimer() - start) )

    ssk.wait.ms( 500 )
    print("2 " .. tostring(system.getTimer() - start) )

    ssk.wait.ms( 500 )
    print("3 " .. tostring(system.getTimer() - start) )
end

ssk.wait.run( testSeq )

Wait In A Timer

timer.performWithDelay(20, 
    coroutine.wrap(
        function(event)
        local source = event.source -- GOTCHA: save this now!

        ssk.wait.ms( 500 )
        print("1")
        ssk.wait.ms( 500 )

        print("2")

        ssk.wait.ms( 500 )
        print("3")

        timer.cancel(source)
    end), 0)

RoamingGamer Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved