Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
So, Javascript PlayerIO is out
This means a few things can now happen:
UnitEE can now be web-based as well, as I believe that the javascript library can be used with WebGL, which means there can still be a browser version of EE
We can now easily make web-based bots, without needing to use flash, all you need to do is have a <script> tag in a website for the library, and another for the actual bot
Code to connect with JavaScript:
global = {
client: null,
connection: null,
players: {}
}
function Start() {
var email = prompt("Email: ");
var password = prompt("Password: ");
var worldID = prompt("World ID: ");
PlayerIO.authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "simpleUsers", { email: email, password: password }, {}, function(client) {
global.client = client;
Log("Authenticated");
global.client.bigDB.load("config", "config", function(config) {
Log("Loaded config");
global.client.multiplayer.createJoinRoom(worldID, "Everybodyedits" + config.version, true, null, null, function(connection) {
global.connection = connection;
Log("Connected");
global.connection.addMessageCallback("*", OnMessage);
global.connection.send("init");
}, CallbackError);
}, CallbackError);
}, CallbackError);
}
function Log(text) {
console.log(text);
}
function CallbackError(error) {
Log("Error: " + error.code + ": " + error.message);
}
function OnMessage(message) {
switch(message.type) {
case "init":
Log("init recieved");
global.connection.send("init2");
break;
case "init2":
Log("init2 recieved");
break;
case "add":
global.players[message.getInt(0)] = message.getString(1);
break;
case "left":
delete players[message.getInt(0)];
break;
case "say":
Log(global.players[message.getInt(0)] + ": " + message.getString(1));
break;
}
}
Start();
Offline
You connect using the good old playerIO.Authenticate method.
Offline
Ive managed to log in (with the code in the OP), but havent managed to join a world yet, as the default 'public' connectionID doesnt have permission
Does anyone know what connectionID we should use?
Edit: Ive done some googling, and it seems that QuickConnect doesnt even use a connectionID internally, so we might not be able to join at all?
Offline
Ive managed to log in (with the code in the OP), but havent managed to join a world yet, as the default 'public' connectionID doesnt have permission
Does anyone know what connectionID we should use?
it's been forever for me. "private" requires some sort of secret key doesn't it? Then idk
edit: what HG seems legit
also does this do anything, perhaps ? https://playerio.com/documentation/refe … ickConnect
I mean, it's only registration, but surely we could find a way that doesn't constantly register
edit2: could remove the "register: true" flag
Offline
it's been forever for me. "private" requires some sort of secret key doesn't it? Then idk
just tested it, and it returns this:
Error: UnknownConnection: The connection requested is not known by the server
That is also what happened when I typed in something random, so im guessing that there isnt a way to connect with ID 'private'
Offline
Try "simpleUsers"
Offline
Try "simpleUsers"
That worked
Thanks
I tried SimpleUser, but not simpleUsers
Edit: Well... it worked once, but now it doesnt seem to do anything...
It doesnt call the connected, or error functions...
Edit 2: Well... It now seems to only work once per world...
Edit 3: Not sure why it stopped working, I closed and reloaded my browser and now it works again
Offline
Hey guys, incase you run into the error where you're trying to detect blocks but javascript is picky about UInt vs Int so you have to do message.getUInt() instead of message.getInt() but then yo urealize uints are a mess -
var objects = message._internal_("get-objects", null);
// objects[3] is the id of the block in case "b"
works in both versions of the JS
Offline
Hey guys, incase you run into the error where you're trying to detect blocks but javascript is picky about UInt vs Int so you have to do message.getUInt() instead of message.getInt() but then yo urealize uints are a mess -
var objects = message._internal_("get-objects", null); // objects[3] is the id of the block in case "b"
works in both versions of the JS
Or you can simply convert the uint to int with the << operator.
// MyInteger is the uint you want to convert to int
MyInteger <<< 0
Offline
Hey guys, incase you run into the error where you're trying to detect blocks but javascript is picky about UInt vs Int so you have to do message.getUInt() instead of message.getInt() but then yo urealize uints are a mess -
var objects = message._internal_("get-objects", null); // objects[3] is the id of the block in case "b"
works in both versions of the JS
Yep, Ive done that too
Are you having problems connecting sometimes? For some reason sometimes createJoinRoom doesnt seem to do anything...
Or you can simply convert the uint to int with the << operator.
// MyInteger is the uint you want to convert to int
MyInteger <<< 0
The problem is that the playerIO library just refuses to return the value if you dont use the correct .getSomething method, its nothing to do with js... Im not sure why they've done that, I dont think any other versions do
Offline
Are you having problems connecting sometimes? For some reason sometimes createJoinRoom doesnt seem to do anything...
yea it's really weird
im using latest firefox, i just open a new tab and paste in the same URL and it works again.
Or you can simply convert the uint to int with the << operator.
// MyInteger is the uint you want to convert to int
MyInteger <<< 0
question : you say "with the << operator"
however in the code you have "MyInteger <<< 0"
which one?
also it should be MyUnsignedInteger for clarification between int and uint
but thanks for that!
Offline
ninjasupeatsninja wrote:Hey guys, incase you run into the error where you're trying to detect blocks but javascript is picky about UInt vs Int so you have to do message.getUInt() instead of message.getInt() but then yo urealize uints are a mess -
var objects = message._internal_("get-objects", null); // objects[3] is the id of the block in case "b"
works in both versions of the JS
Yep, Ive done that too
Are you having problems connecting sometimes? For some reason sometimes createJoinRoom doesnt seem to do anything...
HG wrote:Or you can simply convert the uint to int with the << operator.
// MyInteger is the uint you want to convert to int
MyInteger <<< 0The problem is that the playerIO library just refuses to return the value if you dont use the correct .getSomething method, its nothing to do with js... Im not sure why they've done that, I dont think any other versions do
My suggestion was that you could get the uint from the message, then convert it to int to save it on your int blocks array.
question : you say "with the << operator"
however in the code you have "MyInteger <<< 0"
<<< is an extended overload for <<, just like all other integer arithmetic operators have one (+ and +=, - and -=)
Offline
<<< is an extended operator, just like all other integer arithmetic operators (+ and +=, - and -=)
so <<< and not <<, correct?
Offline
My suggestion was that you could get the uint from the message, then convert it to int to save it on your int blocks array.
Javascript doesnt really care about types, I dont think there is even a difference between the ints and uints internally within playerIO
The original 'picky about UInt vs Int'ness is from PlayerIO requiring you to use the correct getThing method instead of just being able to use all the number ones interchangably (like you can do in the C# version):
function get(index, type) {
if (index > objects.length) {
throw _pio.error("this message (" + self.type + ") only has " + objects.length + " entries");
} else {
if (types[index] == type) {
return objects[index];
} else {
throw _pio.error("Value at index:" + index + " is a " + getTypeString(types[index]) + " and not a " + getTypeString(type) + " as requested. The value is: " + objects[index]);
}
}
}
It doesnt matter what the actual type of the object is, if you call getLong then if the type isnt a long, it throws an error
Offline
HG wrote:<<< is an extended operator, just like all other integer arithmetic operators (+ and +=, - and -=)
so <<< and not <<, correct?
It's the same, as in...
i <<< 4
...would equal to...
i = i << 4
<<< is not an operator, it's an overload. I mentioned the operator.
HG wrote:My suggestion was that you could get the uint from the message, then convert it to int to save it on your int blocks array.
Javascript doesnt really care about types, I dont think there is even a difference between the ints and uints internally within playerIO
The original 'picky about UInt vs Int'ness is from PlayerIO requiring you to use the correct getThing method instead of just being able to use all the number ones interchangably (like you can do in the C# version):function get(index, type) { if (index > objects.length) { throw _pio.error("this message (" + self.type + ") only has " + objects.length + " entries"); } else { if (types[index] == type) { return objects[index]; } else { throw _pio.error("Value at index:" + index + " is a " + getTypeString(types[index]) + " and not a " + getTypeString(type) + " as requested. The value is: " + objects[index]); } } }
It doesnt matter what the actual type of the object is, if you call getLong then if the type isnt a long, it throws an error
Then request to get the proper type and convert it locally. That's what the protocol is for.
The real mess is on the server, for messing with int/uint for blocks.
Offline
It appears when i use ".joinRoom" method instead of "createJoinRoom", i'm able to refresh the page and join the world.
Here's some code that will determine between using joinRoom and createJoinRoom so that nobody ever runs into this problem again.
global = {
client: null,
connection: null,
players: {}
}
function Start() {
var email = prompt("Email: ");
var password = prompt("Password: ");
var worldID = prompt("World ID: ");
PlayerIO.authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "simpleUsers", { email: email, password: password }, {}, function(client) {
global.client = client;
Log("Authenticated");
global.client.bigDB.load("config", "config", function(config) {
Log("Loaded config");
Log("Determining joinRoom or createJoinRoom");
var rooms = global.client.multiplayer.listRooms("Everybodyedits" + config.version, null, 0, 0, function(roominfo) {
var methodOfJoining = false; //createjoinroom
for(var i = 0; i < roominfo.length; i++) {
if(roominfo[i].id == worldID) {
methodOfJoining = true; //joinroom
}
}
if(methodOfJoining) {
global.client.multiplayer.joinRoom(worldID, null, function(connection) {
global.connection = connection;
Log("Connected");
global.connection.addMessageCallback("*", OnMessage);
global.connection.send("init");
}, CallbackError);
} else {
global.client.multiplayer.createJoinRoom(worldID, "Everybodyedits" + config.version, true, null, null, function(connection) {
global.connection = connection;
Log("Connected");
global.connection.addMessageCallback("*", OnMessage);
global.connection.send("init");
}, CallbackError);
}
}, CallbackError);
}, CallbackError);
}, CallbackError);
}
function Log(text) {
console.log(text);
}
function CallbackError(error) {
Log("Error: " + error.code + ": " + error.message);
}
function OnMessage(message) {
switch(message.type) {
case "init":
Log("init recieved");
global.connection.send("init2");
break;
case "init2":
Log("init2 recieved");
break;
case "b":
var objects = message._internal_("get-objects", null);
var id = objects[3];
var x = objects[1];
var y = objects[2];
if(id == 14) {
global.connection.send("b", 0, x, y, 9);
}
if(id == 9) {
global.connection.send("b", 0, x, y, 0);
}
break;
case "add":
global.players[message.getInt(0)] = message.getString(1);
break;
case "left":
delete players[message.getInt(0)];
break;
case "say":
Log(global.players[message.getInt(0)] + ": " + message.getString(1));
break;
}
}
Start();
This should fix your having to close/open your browser/tab
Offline
hey guys, what does this change mean for EE? I mean, assuming botters choose to go this route. Do we even have botters?
A) What does this say about security of EE-related tools?
-- Web-available resources can be much more dynamic, but is there a risk in that? Should a read-only repository be considered, given that various users choose to do scans/decompilation to expose faulty security/phishing tools?
B) What does this say about capabilities of EE-related tools?
-- What advantages do we gain by being able to push things to a web instead of a downloadable? Not as windows-dependent, I imagine. Anything browser-oriented that's valuable?
C) I'm out of questions. Do we have people anymore who would flock to this sort of thing?
D) Oh wait, how much more common would "plagiarism" be given that everything's out there?
Food for thought, debate any and all with me? lol
Offline
A) JavaScript is only supposed to run in browsers, this means that (as far as I know) there is no way to actually edit files on someone's computer without using external browser plugins. There is no guarantee though that the bot won't just send your email and password to some server somewhere, but there wasn't with downloadable bots either.
B) The main advantage is, as you say, that we can run bots on any OS, and that it's a bit easier for users who don't want to download a bot (being online also means you don't need to worry about updates). There is also the fact that JS is a scripting language, so it makes adding 'plugins' a lot easier (I have a few ideas for using this)
C) Personally, I've been looking at trying to make a browser based bot for a while now, and now that PlayerIO js is out, that is much easier. There is also HG and ninjasupeatsninja who also seem interested in making js bots
Edit: And it seems lrussel and Emalton are also making bots
D) With JavaScript there is basically no way to protect your source code, apart from minification, which makes it harder to understand how it works (and makes the file size smaller), but this might not be a bad thing, it could be basically the same as forcing every bot to be open source
Offline
While testing my bot, the couldnt connect thing happened again (while using ninja's code, so I think its probably a playerIO problem), but this time Im getting this error:
The connection to ws://108.178.28.114/ was interrupted while the page was loading.
Just wondering if anyone else has also had this problem, and if anyone has managed to fix it
Also I tried using OnDisconnect, and it doesnt seem to be working, (im placing a lot of blocks, and sometimes it randomly disconnects, sometimes throwing an error (but not calling OnDisconnect), and sometimes just continuing as if its still connected)
Has anyone had this problem too?
Offline
Well, now that Javascript is out, imagine you'd have a little server running.
You could potentially use a website to let players turn your BAL on, on demand.
Aside from that you can also do something else funny: make stuff like Keep Talking and Nobody Explodes. Where one person (group) has one portion of the information, and the other the rest and they'd have to communicate to get through.
Obviously you can just do that through 2 EE rooms, but in a website you have way more control over what and how you display stuff, and make it generally more user-friendly.
The big problem with this idea, however, would be cheating. How are you going to make sure the player can ONLY be in one of the two: the EE room or the website? You can check for the IP on the website, but not on EE. Username is obviously a bad method too, since somebody can just make an alt account.
Offline
You could potentially use a website to let players turn your BAL on, on demand.
javascript runs on someone's stuff, if there's an advantage, we'd assume it wasn't on my stuff because I already could run my stuff
so my question, they would have to run the BAL themselves.. is there a way to authenticate without giving them the username/password?
Offline
den3107 wrote:You could potentially use a website to let players turn your BAL on, on demand.
javascript runs on someone's stuff, if there's an advantage, we'd assume it wasn't on my stuff because I already could run my stuff
so my question, they would have to run the BAL themselves.. is there a way to authenticate without giving them the username/password?
Yes there is, but nothing stops them from using the connection to break the rules and get your account banned, sadly.
Also, guys, Socket.IO has always existed if you wanted to do anything multiplayer in the browser.
I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.
Offline
I think what Processor is getting at, and what makes the most sense, is to run the bot on your own server (programmed in any language that has the Player.IO SDK), and control it from a webpage.
You've never needed the Player.IO JavaScript SDK to do this, and it would be beneficial to not use it if you are interested in protecting your source code or credentials. Essentially you could write the bot in whatever you want, and use Socket.IO (or any Websockets library) to communicate with that bot. For example, you could have a button on a webpage send a message to your bot, hosted on a server, to run a certain function. The bot would execute that, and your logic would all be private, just exposing a communication method so it could be controlled from the web.
When you are using the JS SDK, you are creating an instance of the bot's connection whenever you use the webpage, rather than having a persistent bot running behind the scenes. (Which is why I am confused at the "24/7" aspect of this, when it is really just for the duration of the webpage unless you do what I described)
Note that this advice applies to traditional BALs and not bots that are meant to be distributed and ran by anyone.
Player Since 2011. I used to make bots and stuff.
Offline
I agree ^
I'm not personally going to convert any BALs to JavaScript as there isn't much of an advantage, as you've said
The thing that JavaScript excels at is having bots like NinjaBot or EEditor, which people could use by connecting to a website, instead of needing to download it, and if you're not on Windows, also setting up some third party .net thing
I personally have quite a few ideas, and I'm in the process of setting a few of them up right now (not giving any spoilers)
Offline
[ Started around 1732393275.0688 - Generated in 0.155 seconds, 15 queries executed - Memory usage: 1.8 MiB (Peak: 2.08 MiB) ]