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

natedogith1

Members
  • Content Count

    36
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by natedogith1

  1. As a general rule of thumb, the name of a texture is modid + ":" + blockName

     

    And after a bit of searching, I believe the fluids you're looking for have the following texture names:

     

    tconstruct:molten_enderium
     
    mo:matter_plasma
     
    tconstruct:molten_stone
     
    thermalfoundation:fluid/Fluid_ender_Still
    thermalfoundation:fluid/Fluid_ender_Flow
  2. I'm only receiving the last line from the file in my table so there's only 1 entry?

    What code are you using to unserialize the file? (if you had said it was the first line you might have gotten around it by making the file contain one table instead of two (wrap the entire thing in {}))

     

    Maybe you need to remove the trailing comma from the lines - every line except the last one has a comma at the end, and a trailing comma isn't valid table/serialization syntax, that would explain why only the last line loads.

    Actually, from the lua manual (section 3.4.8 or 3.4.9 - Table Constructors) "The field list can have an optional trailing separator, as a convenience for machine-generated code."

  3. Just curious, what exactly do you mean with that? Coroutines aren't like threads, Lua doesn't automatically run them concurrently. Logically if you call computer.pullSignal in one coroutine, that will block all execution, even if you have some kind of "manual threading" (Plan9k).

    OpenComputer wraps calls to coroutine.yield and coroutine.resume so that they can bubble sysyields. It's part of how OC handles component methods. (if you want to look at the code that does the yielding stuff you can check here )

  4. I think os.date might be calculating things incorrectly, as it's designed for the minecraft world, not the real world. You could use another implementation top get a better value. (Also, while not an ideal option, if you have an internet you could use a web api (I've done that with computer craft))

  5. Other than a loop you'd also need to: keep track of the state, make sure one step equals one trigger, sleep
     

    local component = require("component")
    local sd = require("sides")
    local rs = component.redstone
    
    local oldSignal = false
    local state = false
    while true do
      local signal = rs.getInput(sd.front) > 0 --check if we have a redstone signal
      if signal ~= oldSignal then --make sure we don't trigger twice when the plate was stepped on once '
        oldSignal = signal
        state = not state --make it so we toggle
        if state then
          print("Opening door")
          rs.setOutput(sd.right, 15)
        else
          print("Closing door")
          rs.setOutput(sd.right, 0)
        end
      end
      event.pull("redstone_changed",rs.address,sd.front) --sleep until redstone input on our device's front changes '
    end
    
    
  6. True, it does assume that the contents are text. For Lua code that shouldn't be an issue though - leading newlines don't matter, and line endings are all the same to Lua.

    Line endings may be the same to Lua, but they might not be to the compression code. For instance, if I were to replace all instances of "local " with "\0\13" and put that in a long string and read it in, my algorithm would break. (\13 is \r)

  7. Or use [[raw multiline strings]], which take all characters literally, except for the closing brackets. This is even possible if there are such strings in the code itself - Lua allows you to add any number of equals signs between the two brackets, and they will still be valid, as long as the opening and closing ones use the same number of equals signs. For example, the text

    This string has [[brackets]] in it for some reason.
    would break normal multiline strings, but can still be stored like this:

    [=[This string has [[brackets]] in it for some reason.]=]

    actually, \n and \r characters at the begining and end will be striped out, and \r will be converted to \n

  8. as far as I'm aware there are three ways to do that sort of compression, each with its own upside/downsides

     

    return load((source):gsub("\0","function"))()
    --good if you're only have one key word
    
    return load((source):gsub("\0(.)",{a="function",b="local",c="table",d="string"}))()
    --good general solution for multiple key words, relatively easy to read the shortened version of
    
    return load((source):gsub("\0(.)",function(a)return({"function","local","table","string"})[a:byte()]end))()
    --grows slower than the table version as you add words, but requires more space in the beginning
    --probably require more RAM than the table version
    --should only use over the table version if you have more than 8 key words
    where (source) is a string representation of the source code

    I use \0 because you're almost guaranteed never to run in to it, but code that generates these should probably search for an unused character (preferably a printable one)

    also, I'd like to note from my attempt at implementing this: the only characters that need escaping are the things that close your strings (double quote (") or single quote (')), newline, carriage return, and backslash. You could also try backslash to not have to worry about escaping the carriage return

  9. I was making a thing with tcp via the internet card, but I ran into a thing. How do you check if the server closed the connection? I think I can pcall the internet component's finishConnect method to check if the connection has been closed, but that feels hacky and unreliable.

×
×
  • Create New...

Important Information

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