Skip to content

Instantly share code, notes, and snippets.

@error454
error454 / blog-trad-keyboard.lua
Created October 3, 2012 05:51
BLOG: Traditional Keyboard Before
--------------------------------------------------------------------------------
function UserAI.onKeyboardKeyDown ( kKeyCode )
--------------------------------------------------------------------------------
local sState = application.getCurrentUserAIState("UserAI")
if( sState == "Menu" )
then
if( kKeyCode == input.kKeyUp )
then
this.changeSelection()
@error454
error454 / blog-stat-keyboard.lua
Created October 3, 2012 05:53
BLOG: Stateful Keyboard
--------------------------------------------------------------------------------
function UserAI.Menu_onLoop ( )
--------------------------------------------------------------------------------
local up = this.getKey( 0, "up", true )
local enter = this.getKey( 0, "enter", true )
if( up )
then
this.changeSelection()
@error454
error454 / gist:3850656
Created October 8, 2012 04:01
on{X} Disable/Enable WiFI when leaving/entering home
var home = {
name : "home",
latitude : "0",
longitude : "0",
location : "Home"
};
function createRegion(location, enterFunction, exitFunction){
var region = device.regions.createRegion({
latitude: parseFloat(location.latitude, 10),
@error454
error454 / droneControl_Function_allocateDrone.lua
Last active December 10, 2015 20:28
Example of object pool in shiva. Two tables are created, 1 to store the objects, 1 to store boolean values representing whether the object is in-use. Each object that is part of the pool stores his own table index.
--------------------------------------------------------------------------------
function droneControl.allocateDrone ( )
--------------------------------------------------------------------------------
for i = 0, this.nDronePoolSize ( ) - 1
do
--if the entry is false the pool item is free
if( table.getAt ( this.tDroneFree ( ), i ) == false)
then
--allocate the entry
@error454
error454 / zergrush.js
Created February 26, 2013 21:31
Scans for and destroys all zerglings in half second intervals. Meant to be used as a greasemonkey script in chrome but you could just paste the code into a console while playing the game.
// ==UserScript==
// @name Zerg Defense
// @namespace http://mobilecoder.wordpress.com
// @version 1.0
// @description The Zerg Rush is coming, prepare yourself!
// @match https://www.google.com/search?q=zerg+rush*
// ==/UserScript==
var doMouseEvent = function(element, args) {
var event = document.createEvent("MouseEvents");
@error454
error454 / findLastIndexOf.lua
Last active December 14, 2015 12:29
Find the last index of the specified pattern in a string. For ShiVa 3D game engine.
--------------------------------------------------------------------------------
function YourAI.findLastIndexOf ( sString, sPattern, nIndex )
--------------------------------------------------------------------------------
local firstIndex = string.findFirst ( sString, sPattern, nIndex )
if(firstIndex == -1)
then
return nIndex - 1
else
return this.findLastIndexOf ( sString, sPattern, firstIndex + 1 )
@error454
error454 / valueCycle.lua
Last active December 15, 2015 10:39
Simple value cycling with wrapping
--------------------------------------------------------------------------------
-- Function......... : cycleValue
-- Author........... : Zachary Burke
-- Description...... : Increases or decreases a variable, handles wrapping the
-- value as well.
--
-- Examples:
-- Say you have a variable nCounter where the max value is 5 and the minimum is 0
--
-- Increment
@error454
error454 / googleAnalyticsCoinAlert.js
Last active January 13, 2018 16:46
Greasemonkey script that plays a sound every time you get a new active user in google analytics realtime view.
// ==UserScript==
// @name Google Analytics Realtime Alerts
// @namespace http://mobilecoder.wordpress.com
// @version 1.0
// @description Plays a sound when you get a new user, you can change the sound by hosting your own file on dropbox or other web location
// @match https://www.google.com/analytics/web/?hl=en#realtime*
// ==/UserScript==
// Your custom sound goes here
mCoinSound = new Audio("https://dl.dropbox.com/u/7079101/coin.mp3");
@error454
error454 / TheDemo.as
Last active December 16, 2015 18:09
Kongregate API Integration with Shiva 3D
//-----------------------------------------------------------------------------
// Basic Instructions for getting Kongregate into your export
// In your shiva project, anytime you want to send something to Kongregate stats API you will
// call:
// system.callClientFunction ( "onEngineEvent", sStatisticType, sStatisticName, nValue )
// where sStatisticType is a Kongregate statistic type like "add", "max", "replace"
// sStatisticName is the name of the statistic you've defined on Kongregate
// nValue is the value to send
// Example: system.callClientFunction ( "onEngineEvent", "add", "deaths", 1 )
@error454
error454 / ouya.rb
Last active December 19, 2015 05:39
Dashing widget for OUYA downloads/purchase scraping.
#!/usr/bin/env ruby
require 'csv'
require 'mechanize'
# OUYA dev stats scraper
#
# This job will download the downloads and purchases csv files from
# the OUYA dev portal and, based on the purchase identifier and
# game title, will send download, sales and conversion ratio to
# the dashboard.