8 posts
Location
United States
Posted 18 March 2012 - 04:57 AM
I couldn't find any documentation on how or if there even is a goto command in computer craft
I found
this but it didn't seem to work :D/>/>
I also need help with the application I would use it in. The application sets a variable that is the price of an item. It displays the remaining required values (to pay for it) on screen (which would probably refresh every .5 seconds). The application detects inputs that have a pre-determined value. Every time it checks and an input is on, it subtracts the relative value from the remaining price. There are four different color input possibilities using bundled cable for the left side.
-White Value = 5
-Orange Value = 4
-Magenta Value = 3
-Light Blue Value = 2
So the application will keep running (refreshing screen and checking for new inputs every .5 seconds) until the price variable is equal to or less than 0 and it will then send out a (lets call it a) redstone signal from the back.
I understand most of it, just not the live check and refresh (repeat till or something). If someone could help that would be awesome!
Thanks in advanced :)/>/>
411 posts
Posted 18 March 2012 - 08:16 AM
goto isn't in lua 5.1, it's also considered bad coding to use goto
functions are your friend :D/>/>
473 posts
Location
Poland
Posted 18 March 2012 - 08:21 AM
using goto may lead to shark attacks, meteorite showers and/or spontaneous combustion :)/>/>
but there should be a way to program this in Lua … :D/>/>
28 posts
Posted 18 March 2012 - 09:54 AM
This was already asked (by me) so you should check but it would be back a few paes and
4+ letter word limits on searches suck (Why do bb forum programs do that?(*cough* fix it (Casper?) *cough*))
715 posts
Posted 18 March 2012 - 12:40 PM
This was already asked (by me) so you should check but it would be back a few paes and
4+ letter word limits on searches suck (Why do bb forum programs do that?(*cough* fix it (Casper?) *cough*))
That's to take away strain from the database. There is bound to be a manageable amount of 4-letter words, but there is a significantly larger amount of 3-letter words to sift through, which (depending on the number of posts) becomes slower and slower. Now imagine if many people do searches for 3 letter words concurrently and multiple times in a row. That definitely saps performance and makes browsing though the forum sloooooow.
Granted, that isn't that big of an issue if there aren't a significant amount of users, but the community around CC is growing fast.
And besides, you can always use google to search for 3-letter words or less:
"the" site:computercraft.info/forums2
This should return every page which contains the very uncommon(*mild sarcasm) 3-letter word "the". :D/>/>
8 posts
Location
United States
Posted 18 March 2012 - 03:21 PM
~
Edited on 28 August 2015 - 01:40 AM
8 posts
Location
United States
Posted 18 March 2012 - 03:38 PM
~
Edited on 28 August 2015 - 01:39 AM
473 posts
Location
Poland
Posted 18 March 2012 - 03:39 PM
repeat
code
until expression
1111 posts
Location
Portland OR
Posted 18 March 2012 - 11:01 PM
Do something liike…
function update()
local price = 15
repeat
-- insert coding here
until price <= 0
end
You could also use a while… while price >= 1 do …. end
Then anytime you want to run this in your code just simply call update() vs goto update() like in some other languages.
I noticed you said you were not sure on the live check? Do you need some help with the redstone commands as well?
8 posts
Location
United States
Posted 19 March 2012 - 07:23 PM
~
Edited on 28 August 2015 - 01:39 AM
473 posts
Location
Poland
Posted 19 March 2012 - 08:22 PM
colors.test(bundle, color)
--returns true if the color is in the given bundle reading, you can get such a reading by
rs.getBundledInput(side)
1111 posts
Location
Portland OR
Posted 19 March 2012 - 08:59 PM
You can also do something as simple as..
if redstone.testBundledInput("right", colors.orange ) == true then
print ("orange is on")
else
print ("orange is off")
end
which would test if the orange cable on the right side was on and then print a statement telling you if its on or off
LOL thanks Liraal.. I usually use a var for the side in my codes… :D/>/>
Edited on 19 March 2012 - 08:22 PM
473 posts
Location
Poland
Posted 19 March 2012 - 09:01 PM
you meant "right" with the quotations, right? :D/>/>