Skip to content

Instantly share code, notes, and snippets.

View madclaws's full-sized avatar
🏊‍♂️

Anandu Pavanan madclaws

🏊‍♂️
View GitHub Profile
@madclaws
madclaws / BackoffTimer.ts
Created August 18, 2020 13:36
A class implementing backoff timer
/*
A Timer to deal with exponential backoff problems
(inspired from phoenixjs library , much 💓)
*/
export class BackoffTimer {
private timer: any; // setTimeout Id.
private callbackFunction: typeof Function;
private currentTries: number = 0;
private maxTries: number = 0;
@madclaws
madclaws / settings.json
Created January 4, 2020 18:55
neutron-star
{
"editor.insertSpaces": false,
"editor.tabSize": 2,
"workbench.colorCustomizations": {
"activityBar.background": "#0f0039",
"activityBar.foreground": "#d9ff02",
"statusBar.background": "#0f0039",
"statusBar.foreground": "#d9ff02",
"titleBar.activeBackground": "#0f0039",
"titleBar.activeForeground": "#d9ff02",
@madclaws
madclaws / loadAssets.ts
Created November 19, 2018 06:33
assetLoader
private loadAssets(){
console.log("loading assets");
this._assetManager=new AssetsManager(this._Scene);
let meshTask=this._assetManager.addMeshTask("gemTask","Skull","Assets/","Skull.obj");
meshTask.onSuccess=(task:MeshAssetTask)=>{
console.log("load success");
console.log(task);
task.loadedMeshes[0].position=Vector3.Zero();
}
meshTask.onError=(task,message,exception)=>{
@madclaws
madclaws / loader.ts
Created November 16, 2018 11:34
obj model loading issue
private loadAssets(){
console.log("loading assets");
this._assetManager=new AssetsManager(this._Scene);
let meshTask=this._assetManager.addMeshTask("gemTask","gem","../Assets/","diamond.obj");
meshTask.onSuccess=(task:MeshAssetTask)=>{
console.log("load success");
task.loadedMeshes[0].position=Vector3.Zero();
}
meshTask.onError=(task,message,exception)=>{
console.log(message,exception);
@madclaws
madclaws / foo.lua
Created April 26, 2018 09:10
error
local function onRequestDice(context,payload)
local id,jsonData,isAllowed,diceVal
jsonData=RecordsInst.nk.json_decode(payload)
id=jsonData.id
-- if not checkTurn(id) then
-- return RecordsInst.nk.json_encode({["dice"]=0})
-- else
diceVal=math.random(6)
-- return RecordsInst.nk.json_encode({["dice"]=diceVal})
return manageNextTurn(_diceval)
@madclaws
madclaws / connect.lua
Last active April 24, 2018 11:19
session restore and connect
private restoreSessionAndConnect(){
let sessionString:string=null;
if(typeof(Storage)!==undefined){
sessionString=localStorage.getItem('nakamaToken');
}
if(!sessionString || sessionString===""){
return;
}
let session;
session=nakamajs.Session.restore(sessionString);
@madclaws
madclaws / store.lua
Created April 23, 2018 13:57
storing playerdata
function helper.writePlayerData(_playerID,_color)
-- local curCount
local curCount=fetchCount()
print(curCount.current)
print(_playerID .. " : " .. _color)
local new_record={
{Bucket=_bucket,Collection="GamePlay",Record="playerData",Value={id=curCount.current,color=_color}}
}
if curCount.current<1 then
nk.storage_write(new_record)
@madclaws
madclaws / data.json
Last active April 26, 2018 05:58
storing json from server
{
"playerdata":[
{
"id":0,
"color":2,
"active":true
},
{
"id":1,
"color":3,
@madclaws
madclaws / Records.lua
Last active April 23, 2018 08:10
lua module for writing records.
local nk=require("nakama")
--writing record of total players
function writeTotalPlayers(total_player)
local new_record={
{Bucket="LL",Collection="GamePlay",Record="Common",Value={total=total_player}}
}
nk.storage_write(new_record)
end