Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

augitesoul

Members
  • Content Count

    5
  • Joined

  • Last visited

Reputation Activity

  1. Upvote
    augitesoul reacted to CptMercury in systeminfo - well... showing system information...?   
    Looking good, neat program!
    Some advice for dealing with strings:
    If you want to print some text on your screen and insert some numbers/other variables/returns of functions etc. into that text, instead of writing one part of the text, writing the number, and write the second part of the text you can just concatenate(connect) the different strings and the numbers using the concat operator ..  (2 dots), then print it. In other words, combine all the different parts of the text first, and then write it to the screen. This will reduce the number of lines in your code and less screen operations are performed.
    io.write("string1") io.write("string2") -- # -> string1string2 -- # you get the same result with io.write("string1".."string2") -- # -> string1string2 -- # you can include numbers with io.write("string"..1.."string"..2) -- # -> string1string2 -- # you dont have to use the strings/numbers directly, variables containing strings and numbers work fine as well local s = "string" local num1 = 1 local num2 = 2 io.write(s..num1..s..num2) -- # -> string1string2 -- # one example of your code would be: line 55 - 59 term.write("Energy available/maximum: "..computer.energy().."/"..computer.maxEnergy().."\n") And one question: do you actually want the program to wait before printing a new set of information on the screen or do you just want to let your program yield in order to avoid "too long without yielding errors"?
  2. Upvote
    augitesoul reacted to CptMercury in Making the result of an HTTP request readable output   
    The main problem here is that "==" is used to compare two values and it returns true or false: 4 == 4 -> true; 4 == 5 -> false
    The other thing is that the response is not a string, but an iterator that will return the next line whenever you call it.
    local internet = require'internet' local url = '...' local response = interent.request(url) if response then for line in response do io.write(line.."\n") end end -- # response is an iterator, each time it's called it returns the next line/chunk, this is then stored in the var "line" -- # then you can use the var and print/write it, store it in a table etc  
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.