how do i read an array with thyme?
22 posts • Page 1 of 1
Re: how do i read an array with thyme?
reading an array is like reading any other variable but with a slight change
Where X is, is the value in the array you are reading.
Ps, the value starts from 0
E.g. In the array, [0,1,2,3.4]
array(0) would return 0
Array(3) would return 3
If you need more help just ask
- Code: Select all
scene.my.array(X)
Where X is, is the value in the array you are reading.
Ps, the value starts from 0
E.g. In the array, [0,1,2,3.4]
array(0) would return 0
Array(3) would return 3
If you need more help just ask
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: how do i read an array with thyme?
i was doing
for oncollide, but it keeps changing it to
and it doesnt work.
so how do i fix this??
- Code: Select all
e.other.text(0) == "MONITOR"?{e.this.text = e.other.text(1)} e.other.text(0) == "CLEAR"?{e.this.text = ""}
for oncollide, but it keeps changing it to
- Code: Select all
e.other.text(0) == "MONITOR"(?)({e.this.text = e.other.text(1)})(e.other.text)(0) == "CLEAR"(?)({e.this.text = ""})
and it doesnt work.
so how do i fix this??

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: how do i read an array with thyme?
cocolover76 wrote:i was doing
- Code: Select all
e.other.text(0) == "MONITOR"?{e.this.text = e.other.text(1)} e.other.text(0) == "CLEAR"?{e.this.text = ""}
for oncollide, but it keeps changing it to
- Code: Select all
e.other.text(0) == "MONITOR"(?)({e.this.text = e.other.text(1)})(e.other.text)(0) == "CLEAR"(?)({e.this.text = ""})
and it doesnt work.
so how do i fix this??
Like this:
- Code: Select all
e.other.text(0) == "MONITOR" ? {e.this.text = e.other.text(1)} : {e.other.text(0) == "CLEAR" ? {e.this.text = ""} : {}}
or:
- Code: Select all
e.other.text(0) == "MONITOR" ? {e.this.text = e.other.text(1)} : {};
e.other.text(0) == "CLEAR" ? {e.this.text = ""} : {}
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: how do i read an array with thyme?
bozbez wrote:Like this:
- Code: Select all
e.other.text(0) == "MONITOR" ? {e.this.text = e.other.text(1)} : {e.other.text(0) == "CLEAR" ? {e.this.text = ""} : {}}
or:
- Code: Select all
e.other.text(0) == "MONITOR" ? {e.this.text = e.other.text(1)} : {};
e.other.text(0) == "CLEAR" ? {e.this.text = ""} : {}
I tried both ways and it still didnt work.
If this helps you fix it, I am using Algodoo Phun Edition v5.28

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: how do i read an array with thyme?
I just realised that there is a deeper problem. You can't have an array in "text". "textureMatrix" would be the one to use.
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: how do i read an array with thyme?
For textureMatrix, you can only use float values, like 39.0.
And I think he's trying to reverse-engineer the AHOX computers.
And I think he's trying to reverse-engineer the AHOX computers.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
Someone Else wrote:And I think he's trying to reverse-engineer the AHOX computers.
Read viewtopic.php?f=6&t=4013 . Before I release my PC, I will get permission (I already private messaged Kutis96 to ask for permission but he didn't reply yet)
EDIT: he replyed.
Last edited by cocolover76 on Tue May 24, 2011 11:33 pm, edited 1 time in total.

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: how do i read an array with thyme?
I will pass a message on to kutis to check his PM over skype in the morning. well, what is morning to me 
ps, fell free to send me a link >D
Have you managed to get the programing system working?
Kutis uses the eval command to remove the array out of the text.
I just cant remember how exactly it is used...
i mainly focus on helping with the actual programs and not the actual CPU...
------------
Electronicboy
AHOX Beta Tester and Developer <yay im now a dev (kinda) >D
yup, now im showing off with my lame fancy sig >D
yup, im in one of my crazy moods...
ps, fell free to send me a link >D
Have you managed to get the programing system working?
Kutis uses the eval command to remove the array out of the text.
I just cant remember how exactly it is used...
i mainly focus on helping with the actual programs and not the actual CPU...
------------
Electronicboy
AHOX Beta Tester and Developer <yay im now a dev (kinda) >D
yup, now im showing off with my lame fancy sig >D
yup, im in one of my crazy moods...
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: how do i read an array with thyme?
Hmm... I am also trying (unsuccessfully) to reverse-engineer the AHOX computers.
Maybe I will try to look at a really old version, and also fool around with eval.
Maybe I will try to look at a really old version, and also fool around with eval.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
NOW, i am doing
it accepted it, but it still does not work!!!!
and no, i CAN see the text if i change it in appearance so how do i fix this??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
edit: i might not post for a while and it will be a long time for me to finish typing this if i explain why.
- Code: Select all
eval(e.other.text)(0) == "MONITOR" ? {e.this.text = eval(e.other.text)(1)} : {}; eval(e.other.text)(0) == "CLEAR" ? {e.this.text = ""} : {}
it accepted it, but it still does not work!!!!
and no, i CAN see the text if i change it in appearance so how do i fix this??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
edit: i might not post for a while and it will be a long time for me to finish typing this if i explain why.

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: how do i read an array with thyme?
You're still trying to use a string as an array.
-

bozbez - Posts: 149
- Joined: Tue Apr 12, 2011 7:01 pm
Re: how do i read an array with thyme?
i think i know how to do it!
This will create a new variable on the cpu, called "program"
The program variable is where the program array will be stored.
this also presumes that the code is on the thyme CPU:
Put this code on a block collider (circles can have text)
The program will go in the text field on the collider.
e.other.program = eval(e.this.text)
This is based upon the eval code you have gave.
You will need to modify existing code in the processor.
E.g.
[code]eval(e.other.text)(0) == "MONITOR" ? {e.this.text = eval(e.other.text)(1)} : {}; eval(e.other.text)(0) == "CLEAR" ? {e.this.text = ""} : {}
Should be
[code]e.geom.program(0) == "MONITOR" ? {e.this.text = e.geom.program(1)} : {}; e.geom.program)(0) == "CLEAR" ? {e.this.text = ""} : {}
I see that the CPU is also the monitor
This will create a new variable on the cpu, called "program"
The program variable is where the program array will be stored.
this also presumes that the code is on the thyme CPU:
Put this code on a block collider (circles can have text)
The program will go in the text field on the collider.
e.other.program = eval(e.this.text)
This is based upon the eval code you have gave.
You will need to modify existing code in the processor.
E.g.
[code]eval(e.other.text)(0) == "MONITOR" ? {e.this.text = eval(e.other.text)(1)} : {}; eval(e.other.text)(0) == "CLEAR" ? {e.this.text = ""} : {}
Should be
[code]e.geom.program(0) == "MONITOR" ? {e.this.text = e.geom.program(1)} : {}; e.geom.program)(0) == "CLEAR" ? {e.this.text = ""} : {}
I see that the CPU is also the monitor
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: how do i read an array with thyme?
Thank You Electronicboy! It (mostly) works!
What you really want is this:
Make sure you set controllerAcc to 0 first. That got me. Also, this is the syntax you want:
I found that for this setup, you want the box with the program in its text to be fixated to a long bar, hinged to the background at the other end. The program box and the CPU should both have restitution of 1. The code box should swing into the CPU, bounce off, swing away, swing back, and strike the CPU again, performing the next opcode.
What you really want is this:
- Code: Select all
e.this.program = eval(e.other.text);
{program(controllerAcc)(0) == "MONITOR"} ? {text = "" + program(controllerAcc)(1)} : {};
{program(controllerAcc)(0) == "MONITOR+"} ? {text = text + "\n" + program(controllerAcc)(1)} : {};
{program(controllerAcc)(0) == "CLEAR"} ? {text = ""} : {};
controllerAcc = controllerAcc + 1
Make sure you set controllerAcc to 0 first. That got me. Also, this is the syntax you want:
- Code: Select all
[["MONITOR", "Hello"],
["MONITOR+", "World"],
["CLEAR"]]
I found that for this setup, you want the box with the program in its text to be fixated to a long bar, hinged to the background at the other end. The program box and the CPU should both have restitution of 1. The code box should swing into the CPU, bounce off, swing away, swing back, and strike the CPU again, performing the next opcode.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
*bump*
I just found out that you can use code such as
Instead of scene.my.array(--put integer here--)
So if scene.my.array=[2, 4, 8, 16, 32, 64], and scene.my.arrayccess = 3, the result would be 16. This will make my new project so much easier!
I just found out that you can use code such as
- Code: Select all
scene.my.array(scene.my.arrayaccess)
Instead of scene.my.array(--put integer here--)
So if scene.my.array=[2, 4, 8, 16, 32, 64], and scene.my.arrayccess = 3, the result would be 16. This will make my new project so much easier!
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: how do i read an array with thyme?
That's exactly how the code in the post above uses controllerAcc.
Sorry, pointless bump, you fail.
Sorry, pointless bump, you fail.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
Well, it had a point-- It was an accurate summary of the above code for those of use (like myself) who didn't understand a word of it 
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: how do i read an array with thyme?
Fine.
Whatever.
Whatever.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
I think I get it now....
So, after the above code happened, and e.other.text is:
, scene.my.one would be 1, .two = 2, and .three = 3?
(I am incredbly busy, so I didn't have time to try this, sorry
)
- Code: Select all
scene.my.program = e.other.text;
scene.my.one = scene.my.program(0);
scene.my.two = scene.my.program(1);
scene.my.three = scene.my.program(2);
So, after the above code happened, and e.other.text is:
- Code: Select all
[1,2,3]
, scene.my.one would be 1, .two = 2, and .three = 3?
(I am incredbly busy, so I didn't have time to try this, sorry

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
Re: how do i read an array with thyme?
okay, firstly, the concept you have is correct, but it wont work like that (because of line one)
scene.my.program = eval{e.other.text}
Try that...
ps, if you had read the topic before posting, chances are, you wouldn't need to have bumped...
scene.my.program = eval{e.other.text}
Try that...
ps, if you had read the topic before posting, chances are, you wouldn't need to have bumped...
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: how do i read an array with thyme?
No, actually, it's eval(e.other.text).
Eval is a function, so the argument goes in parenthesis, not braces.
Eval is a function, so the argument goes in parenthesis, not braces.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: how do i read an array with thyme?
Sorry, I just held Page Down to get to the Post Reply because I was in a hurry so I would post it before I forgot my idea.

- cocolover76
- Posts: 135
- Joined: Sun May 08, 2011 10:49 pm
22 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests





