Skip to content

Instantly share code, notes, and snippets.

@nickarthur
nickarthur / gist:7541776
Last active December 28, 2015 18:18
GLOBAL STATE SETTING AND GETTING EXAMPLE GIST FOR CLOUD PARTY CLOUDPARTY
//CLOUDPARTY GIST (smoosh together for searchability)
//////////////////////////// set global state examples ////////////////////////////////////
setGlobalState({
state_key: 'Racetrack Key',
data: { controller: getSelfEnt() } //controller announce yo sef to da worl!
});
setGlobalState({
@nickarthur
nickarthur / gist:7541892
Created November 19, 2013 08:01
ARRAY SORT CLOUDPARTY cloudparty which sorts by the time in seconds
//ARRAY SORT CLOUDPARTY cloudparty
// Sort the total and current results lists by time
arraySort(resultsTotalArray, 'sortByTime');
arraySort(resultsCurrentArray, 'sortByTime');
// Sort the total and current results lists by time
arraySort(resultsCurrentArray, 'sortByTime');
@nickarthur
nickarthur / gist:7541926
Created November 19, 2013 08:05
ARRAY TO OBJECT and OBJECT TO ARRAY conversion CLOUDPARTY cloudparty
//cloudparty array to object and object to array
/////////////////////////////////////////////////////////////////////////////////////////////
//array to object
@nickarthur
nickarthur / gist:7556808
Last active December 28, 2015 20:19
spawn a teleporter at a detected user's position relative to a game object hosting this script. cloudparty CLOUDPARTY (relative spawning of objects)
function spawnTeleport(entFieldsData) {
error('Got ' + entFieldsData.display_name + '\'s position at ' + stringify(entFieldsData.pos, {newline: false, indent: false}));
vecPosWorldToRel(entFieldsData.pos);
vecAdd(entFieldsData.pos, []);
spawn({
prefab: 'Timeout Prefab',
pos: entFieldsData.pos
});
}
@nickarthur
nickarthur / gist:7557328
Created November 20, 2013 03:42
CLOSING CLOUDPARTY HTML CONTROLLERS via script cloudparty
Closing Controllers
How do you close a controller under script control? I thought I had that figured out at one point, but I guess not.
Yeah, that one is definitely a little subtle. Look at the 'command' section under listeners on controllerHTMLCreate:
http://wiki.cloudparty.com/wiki/ControllerHTMLCreate#listeners_Element_Keys
Basically you want to create a listener that has command: 'close', and then send a message (controllerMessage) corresponding to that listener.
@nickarthur
nickarthur / gist:7567636
Last active December 28, 2015 21:49
HTML DIALOG CUSTOM CLOSE BUTTON cloudparty CLOUDPARTY
var htmlText = '<div id="body">\
<div id=btnGrp>\
<button id="btnClose">Close the Dialog</button><br>\
</div></div>';
function clickStart() {
controllerHTMLCreate({
ent: getMessageEnt(),
title: 'the winow title',
{{id:'hi',name:'ho'}},
{{id:'hi',name:'ho'}},
{{id:'hi',name:'ho'}},
{{id:'hi',name:'ho'}},
{{id:'hi',name:'ho'}};
@nickarthur
nickarthur / GAME CONTROLLER COMMUNTICION.TXT
Created November 22, 2013 16:52
GAME CONTROLLER COMMUNICATION DESIGN
Controller- Entity Communication Design
1. Placed Entities (e.g. race checkpoints) use a register.js script to register themselves into the database--with registration retry logic built in.
(Registration is into global state with key.)
2. Controller periodically queries global state for the array of keys of entites.
3. Controller direct messages a Report! command to each entity on the list.(so errors can be returned)
@nickarthur
nickarthur / DM Asset 3.js
Created November 24, 2013 04:17
Can't do this, in multi object environment. need to get the list of entities that are there already and insert yourself so you don't clobber the others.
function updatedData(globalStateData) {
error('Updated with ID: ' + getSelfEnt());
}
setGlobalState({
state_key: 'DM Key',
data: { gameObjects: { asset_c_nick: getSelfEnt() } },
callback: 'updatedData'
});
@nickarthur
nickarthur / WEBSITES for CP DEVELOPMENT.html
Created November 25, 2013 02:29
DEVELOPMENT WEBSITES AND ONLINE TOOLSUseful
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CLOUD PARTY SCRIPTING PAGES</title>
<style type="text/css">
.tbl-left {
text-align: left;
padding: 4em;
font-size: 1.2em;
font-family: helvetica, arial;