1.0.2 • Published 1 year ago
funnydots.js v1.0.2
funnydots.js
To be honest, posting the client on here is just a formality, noone else is going to use this.
My stupid docs:
let client = require('funnydots.js')('myBotName'); // The only argument it takes is the username.
client.log(1, client)
{
init: false,
mouseX: 0,
mouseY: 0,
angle: 0,
upgrades: [
0, 0, 0, 0,
0, 0, 0
],
xp: 0,
selected: 1,
selectType: [
null, null, null,
null, null, null,
null, null, null
],
inFaction: false,
inventoryOpen: false,
canCraft: null,
faction: null,
factionPerms: false,
inventory: { items: {}, craft: {} },
updateData: {},
updatePlayerData: {},
account: {},
notif: null,
socket: Socket {
/* ... */
}
}
// Properties that aren't shown because I hate you (events and also name)
client.name = 'newName'; // Sets client name (only applies before start or rejoin)
client.logging(level); // Logging level (default 0 - no logging)
client.log(1, "You only see this", "when logging is more than or equal to one.") // Log something using the clients logging method. Useful for extentions that may log debug messages.
client.map // Map data.
client.map.height // Map height.
client.map.width // Map width.
client.start(); // Starts the bot, this should be called AFTER you register your methods.
client.onStart(()=>{
client.log(1, "Bot is first starting.")
})
client.onInit(()=>{
client.log(1, "Bot is first starting or rejoining.")
})
client.onLeave(()=>{
client.log(1, "Bot died.")
client.rejoin()
})
client.onUpdateGame(()=>{
client.log(1, "Game updated. PATA (Your player data):", client.updatePlayerData, "DATA (General game data):", client.updateData);
Game updated. PATA (Your player data): {
xp: 0,
lvl: 0,
player: {
x: 2073,
y: 6197
},
items: [
[
{
x: 1221.5,
y: 5706,
id: "i_wood"
}
],
[]
]
} DATA (General game data): {
"ply": [
{
"x": 3813,
"y": 5912,
"col": "#009999",
"hp": 100,
"name": "pelvisonions",
"xp": 0,
"kills": 0,
"msg": "",
"lvl": 0,
"sz": 45,
"angle": 180.75716886505853,
"select": 1,
"pick": {
"x": 0,
"y": 0,
"angle": 0
},
"weapon": {
"x": 0, // I think this is sprite offset, I dunno, doesn't matter tho.
"y": 0,
"angle": 0, // Weapon angle.
"type": "Archer", // Your class.
"color": "#9999FF"
},
"mod": [
null,
null
]
},
/* ... */
],
"proj": [
{
"x": 3875.4737172390555,
"y": 2440.374166449638,
"angle": 3.116745243413136,
"type": "proj_arrow"
}
],
"thing": [
{
"x": 2350,
"y": 913,
"sz": 25,
"hp": 100,
"sides": 5,
"color": {
"r": 239,
"g": 217,
"b": 136
},
"type": 0, // CONTROL F the client rendering code for the types https://funnydots.neilpurohit06.repl.co/rendering.js `.type`
"angle": 293,
"mod": null
},
/* ... */
]
}
})
client.onLoadChunk((mode, data)=>{
client.log(1, 'New chunk loaded.');
client.log(1, mode) // ["replace", "add", or "delete"]
})
// This is the client chunk handling code for ref.
switch(mode){
case "replace":
for(let i in data){
map[i] = {tiles: [], floor: [], biome: []};
for(let j in data[i].tiles){
map[i].tiles.push(getTile(data[i].tiles[j].type, data[i].tiles[j].x, data[i].tiles[j].y, null, data[i].tiles[j].facing));
}
for(let j in data[i].biome){
map[i].biome.push(getBiome(data[i].biome[j].type, data[i].biome[j].x, data[i].biome[j].y));
}
for(let j in data[i].floor){
map[i].floor.push(getTile(data[i].floor[j].type, data[i].floor[j].x, data[i].floor[j].y, null, data[i].floor[j].facing));
}
}
break;
case "add":
for(let i in data){
if(!(i in map)) return;
for(let j in data[i].tiles){
map[i].tiles.push(getTile(data[i].tiles[j].type, data[i].tiles[j].x, data[i].tiles[j].y, null, data[i].tiles[j].facing));
}
for(let j in data[i].biome){
map[i].biome.push(getBiome(data[i].biome[j].type, data[i].biome[j].x, data[i].biome[j].y));
}
for(let j in data[i].floor){
map[i].floor.push(getTile(data[i].floor[j].type, data[i].floor[j].x, data[i].floor[j].y, null, data[i].floor[j].facing));
}
}
break;
case "delete":
for(let i in data)
delete map[data[i]];
break;
}
client.onLoggedIn(()=>{}); // Accounts are not out to the public yet so this is obsolete.
client.onNotif((msg, color)=>{
client.log(1, msg, color) // Death messages.
});
client.onNotif2((msg, color)=>{
client.log(1, msg, color) // LOGIN TO GAIN SKINS (don't try it its a trap.)
});
client.onWeapon((choices)=>{
client.log(1, choices)
client.chooseWeapon(choices[0])
});
client.onUpgrade((a)=>{
client.log(1, a); // If you haven't hit the cap for anything, it should look like this.
{
speed: 1,
health: 2,
regen: 3,
small: 4,
dash: 5,
building: 6,
mining: 7
}
if (a.speed) {
client.upgrade(a.speed)
} else {
client.upgrade(Object.values(a)[0]) // First value;
}
});
client.onUpdateClient((key, value)=>{
client.log(1, 'client.'+key, '=', value)
})
And thats it!!!!