Page 1 of 1

This code knows your name. Can I use it?

PostPosted: Wed Jan 09, 2019 5:26 am
by FlameVapour
So I was messing around and wrote up this script:
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.

Re: This code knows your name. Can I use it?

PostPosted: Thu Jan 10, 2019 10:34 am
by FRA32
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.

Re: This code knows your name. Can I use it?

PostPosted: Thu Jan 10, 2019 7:13 pm
by FlameVapour
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.)

Re: This code knows your name. Can I use it?

PostPosted: Wed Jan 30, 2019 9:00 am
by Xray
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!

Re: This code knows your name. Can I use it?

PostPosted: Wed Jan 30, 2019 1:30 pm
by FRA32
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.

Re: This code knows your name. Can I use it?

PostPosted: Wed Jan 30, 2019 7:15 pm
by Xray
Oh, cool! I'll have to try it out and see what it does. Thanks!

Re: This code knows your name. Can I use it?

PostPosted: Thu Jan 31, 2019 6:23 pm
by FlameVapour
Yeah I love OneShot, which sort of inspired this.