40 posts
Posted 23 September 2012 - 02:44 PM
Hello guys, first I want to say sorry for my bad english, I'm just fifteen years old and from Switzerland.
So I started two days ago with computercraft, now I made a Programm that calculates for my.
My problem is that i could'nt find out how to print a variable (I looked also in this forum, but I was to dumb for finding it out :P/>/> ).
I play already wiht the 1.3 version of Computercraft, because I'm using the Tekkit pack.
Please help my, would be very nice.
Thank you IceCrasher
23 posts
Location
Poland
Posted 23 September 2012 - 02:46 PM
print(variable)
40 posts
Posted 23 September 2012 - 03:05 PM
Thank you for quick anwering, but I'm still to dumb. It wan't work. Every time I let it (the name of my proagram is "calculate") run it says "calculate:23: attempt to call number" but there is a number in the Variable :S
I write my code down here, maybe you can help my one more time?
local a=100
local x=1
local hv=1
local t=0
local tt1=0
local tt2=0
local tt3=0
local wert=0
tt1=1000000/512/20/x*hv
t=t+tt1
x=x+1
while x<a do
tt1=1000000/512/20/x*hv
tt2=tt1-30
tt3=tt2/tt1
x=x+1
wert=1000000/512/20*tt3/x*hv
t=t+wert+tt1
end
print(x)
3 posts
Posted 23 September 2012 - 03:07 PM
Try print or write
print(""..variablename)
Just to elaborate on what I wrote about ^.
print = start a new line and say the message on the screen. Then everything inside the brackets will be said. In this case, we will do
""
(we're not saying printing any direct text) and then
..variablename
. The
..
is important as it appends (I think) the text.
318 posts
Location
Somewhere on the planet called earth
Posted 23 September 2012 - 03:08 PM
This was wrong.
Edited to remove my error
40 posts
Posted 23 September 2012 - 03:23 PM
thank you Clueless
your solution worked (just with write and not with print, but thats fine)
and thank you code Kiddie too for trying help my
you guys are awesome ^^
318 posts
Location
Somewhere on the planet called earth
Posted 23 September 2012 - 03:28 PM
Clueless is a rank that you gain by post count. (startrank)
Code kiddie is allso a rank( 150 posts ).
My name is sjele :P/>/>
40 posts
Posted 23 September 2012 - 03:30 PM
oh fail XD
40 posts
Posted 23 September 2012 - 03:32 PM
i didn't get a message, in my forum mailbox ore the one from my normal e-mail :P/>/>
1604 posts
Posted 23 September 2012 - 03:33 PM
Remove local from varriables. should work then
Local made the var not exsist in the parts were you printed it
Please, don't listen to that. That's just wrong, you should try and use local variables whenever you can.
I think the problem was that you made at some point something like:
print = someVariable
wich replaced the print function with a number. Rebooting the computer should make print work again.
40 posts
Posted 23 September 2012 - 03:35 PM
i'll try ^^
for what is the local in front of a variable?
40 posts
Posted 23 September 2012 - 03:36 PM
thanks, you were absolutly right, now print works to XD
23 posts
Location
Poland
Posted 23 September 2012 - 03:41 PM
Print takes string, but i was pretty sure it parsed numbers to string automatically. Well, maybe in 1.3 it didn't, and in this situation the proper thing to do would be:
print(tostring(x))
Edit: ok, I didn't see the above posts, so ignore it :P/>/>
318 posts
Location
Somewhere on the planet called earth
Posted 23 September 2012 - 03:42 PM
Remove local from varriables. should work then
Local made the var not exsist in the parts were you printed it
Please, don't listen to that. That's just wrong, you should try and use local variables whenever you can.
I think the problem was that you made at some point something like:
print = someVariable
wich replaced the print function with a number. Rebooting the computer should make print work again.
Ohh, my bad :P/>/> I though the local made the var nil when he printed it ;)/>/>