This code knows your name. Can I use it?
7 posts • Page 1 of 1
This code knows your name. Can I use it?
So I was messing around and wrote up this script:
What it does is it takes the file directory of the scene and extracts the name of the user. It only works if the directory is not in the Algodoo directory (or if the directory is not listed as such and shows "/Users..." instead of "Algodoo..."). It works on Windows for certain, and it should work on Mac. Now, the name, of course, stays within the scene. It can't be accessed by anyone other than the user viewing the scene. I wasn't sure if this was allowed, so I'm asking here before using it in anything.
- Code: Select all
Scene.fileDir != string.list2str(scene.my.thing) ? {
scene.my.name = "";
scene.my.num = 0;
scene.my.thing = string.str2list(Scene.fileDir);
scene.my.done = 0
} : {};
scene.my.done == 0 ? {
scene.my.thing(0) == "/" ? {
scene.my.thing(7 + scene.my.num) != "/" ? {
scene.my.name = scene.my.name + scene.my.thing(9 + scene.my.num);
scene.my.num = scene.my.num + 1
} : {
scene.my.done = 1
}
} : {
scene.my.thing(9 + scene.my.num) != "/" ? {
scene.my.name = scene.my.name + scene.my.thing(9 + scene.my.num);
scene.my.num = scene.my.num + 1
} : {
scene.my.done = 1
}
}
} : {}
What it does is it takes the file directory of the scene and extracts the name of the user. It only works if the directory is not in the Algodoo directory (or if the directory is not listed as such and shows "/Users..." instead of "Algodoo..."). It works on Windows for certain, and it should work on Mac. Now, the name, of course, stays within the scene. It can't be accessed by anyone other than the user viewing the scene. I wasn't sure if this was allowed, so I'm asking here before using it in anything.
- FlameVapour
- Posts: 4
- Joined: Wed Jan 09, 2019 5:14 am
Re: This code knows your name. Can I use it?
Well, since the script only works outside the Algodoo repository, theres obviously no way of it working for anyone unless you deliberately move the downloaded scene outside. Besides, no sensitive information is being published or anything, it literally only reads what you already know.
Btw: You dont need to use Scene.my for every single variable you want. If the variable is only used by one object, make it a local variable using "_var = something" in the black mini-console of the object.
Btw: You dont need to use Scene.my for every single variable you want. If the variable is only used by one object, make it a local variable using "_var = something" in the black mini-console of the object.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: This code knows your name. Can I use it?
Thanks.
(Also, I know about the instance variable thing, and I used them in the original version of the script. I just changed it here so that you could just paste it into something without having to define them which was probably useless.)
(Also, I know about the instance variable thing, and I used them in the original version of the script. I just changed it here so that you could just paste it into something without having to define them which was probably useless.)
- FlameVapour
- Posts: 4
- Joined: Wed Jan 09, 2019 5:14 am
Re: This code knows your name. Can I use it?
Algodoo already has a built-in function that allows you to read or write the scene's author's name. It is: fileInfo.author
I'm not sure if that's the same information that your code provides. Try it out and let me know if your code is different in some way.
Thanks!
I'm not sure if that's the same information that your code provides. Try it out and let me know if your code is different in some way.
Thanks!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: This code knows your name. Can I use it?
The code actually reads the name of the computer user itself, instead of whatever username you chose for the algobox. this is very similar in a way to what a game called "Oneshot" does (incredible game btw), it figures out what your Username on the device is and then utilizes that data somehow.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: This code knows your name. Can I use it?
Oh, cool! I'll have to try it out and see what it does. Thanks!
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: This code knows your name. Can I use it?
Yeah I love OneShot, which sort of inspired this.
- FlameVapour
- Posts: 4
- Joined: Wed Jan 09, 2019 5:14 am
7 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 6 guests