Current time: 05-19-2012, 10:18 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Demo scripts
Author Message
01-02-2010, 02:16 AM (This post was last modified: 01-04-2010 07:59 AM by WillyR.)
Post: #1
Demo scripts
Hey everyone!

to help get you started with out new scripting system i have create some demo scripts for you all to use, test them out and post your own scripts here!

Code:
API.addEventListener(APIEvents.ADD_USER, addUser);
API.addEventListener(APIEvents.REMOVE_USER, removeUser);
API.addEventListener(APIEvents.USER_STATUS, userStatus);

function addUser(e)
{
    Kynto.sendChat("hey " + e.currentTarget.U);
}

function removeUser(e)
{
    Kynto.sendChat("bye " + e.currentTarget.U);
}

function userStatus(e)
{
    if(e.currentTarget.S == "online")
    {
        Kynto.sendChat("welcome back " + e.currentTarget.U);
    }
    else
    {
        Kynto.sendChat("come back soon " + e.currentTarget.U);
    }
}

function newMessage(e)
{
    if(e.currentTarget.M.substring(0, 8) == ":apihelp")
    {
        var APIHelpBox = "Kynto.createAlert(MESSAGE)\tCreates and shows a new alert.";

        Kynto.createAlert(APIHelpBox );
    }
}

A simple script to help get you started!

Happy Kynto scripting!
Find all posts by this user
Like Post Quote this message in a reply
01-02-2010, 03:47 AM
Post: #2
Demo scripts
Quote:/*
* Clone status
*/

function userStatus(obj)
{
switch(obj.S)
{
case "brb":
Kynto.sendChat(":" + obj.S);
break;
case "online:
Kynto.sendChat("back");
break;
}
}

Move user (you could have this running on a timer)
Quote:var tiles = ["0_0", "0_2", "5_2"];

function moveMe()
{
var tile = array_rand(tiles).split(/_/);
Kynto.moveUser(tile[0], tile[1]);
}

moveMe();


function array_rand(array)
{
return array[Math.floor(Math.random()*array.length)];
}

A simple bot

Quote:var messages = ["Bots are coool", "irobot", "I'm not a bot!!", "kynto rocks"];
var tiles = ["0_0", "1_4", "0_6", "6_0", "7_10"];

setInterval("run()", 3000);

function run()
{
var tile = array_rand(tiles).split(/_/);
Kynto.moveUser(tile[0], tile[1]);

var message = array_rand(messages);
Kynto.sendChat(message);
}

function array_rand(array)
{
return array[Math.floor(Math.random()*array.length)];
}

http://williamrob.in/ Imawesome
Visit this user's website Find all posts by this user
Like Post Quote this message in a reply
01-04-2010, 08:00 AM
Post: #3
Demo scripts
I've updated Matties scripts to work with the new event model. I will get around to mine later! Happybracket

http://williamrob.in/ Imawesome
Visit this user's website Find all posts by this user
Like Post Quote this message in a reply
01-04-2010, 08:09 AM
Post: #4
Demo scripts
Willy Wrote:I've updated Matties scripts to work with the new event model. I will get around to mine later! Happybracket

Nice nice. Could you add a pre-send function? Like, when you click send, and if say you return false it wont send the message. Just easier so people dont see others commands Happybracket

PHP, MySQL, xHTML, CSS, JavaScript, C#, Lingo, AS3

[Image: mfpreviewsig.png]

http://sketcher.me
Visit this user's website Find all posts by this user
Like Post Quote this message in a reply
Post Reply 


Forum Jump: