This code knows your name. Can I use it?

About advanced scenes, and the Thyme scripting language used in Algodoo.

This code knows your name. Can I use it?

Postby FlameVapour » Wed Jan 09, 2019 5:26 am

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.
FlameVapour
 
Posts: 4
Joined: Wed Jan 09, 2019 5:14 am

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

Postby FRA32 » Thu Jan 10, 2019 10:34 am

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.
FRA32
 
Posts: 227
Joined: Wed Dec 03, 2014 9:51 pm

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

Postby FlameVapour » Thu Jan 10, 2019 7:13 pm

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.)
FlameVapour
 
Posts: 4
Joined: Wed Jan 09, 2019 5:14 am

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

Postby Xray » Wed Jan 30, 2019 9:00 am

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!
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

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

Postby FRA32 » Wed Jan 30, 2019 1:30 pm

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: 227
Joined: Wed Dec 03, 2014 9:51 pm

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

Postby Xray » Wed Jan 30, 2019 7:15 pm

Oh, cool! I'll have to try it out and see what it does. Thanks!
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

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

Postby FlameVapour » Thu Jan 31, 2019 6:23 pm

Yeah I love OneShot, which sort of inspired this.
FlameVapour
 
Posts: 4
Joined: Wed Jan 09, 2019 5:14 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron