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

ATastyPeanut

Members
  • Posts

    15
  • Joined

  • Last visited

About ATastyPeanut

  • Rank
    Newbie
    Newbie

Contact Methods

  • Minecraft
    A_Tasty_Peanut

Recent Profile Visitors

7568 profile views
  1. Thank you for catching this mistake, all the TPSBaseRaw filenames have been updated. I have also been able to test on a new server, the data from those tests have helped identify additional intricacies with TPS estimation. Updates to the estimator and a new high-resolution display will be coming soon.
  2. I'm unsure of its accuracy. Unfortunately, I have not had access to enough servers to do the accuracy tests under various load conditions. The testing method used was TNT detonation; A large sum of TNT (>50k) was detonated, this caused a slow down to 1-2 TPS, from the servers nominal 20 TPS, which the monitor did correctly estimate. The huge slow down from TNT proved the code worked, but was unable to provide more controlled scenarios. Additional tests are needed for a consistent load where the server runs at 5-10, 10-15, and 15-20 TPS. If you know of any servers that may work, I would love to come and test the code further. Either way, I hope the scripts helped you accomplish your project. ~A_Tasty_Peanut
  3. If you're on a server you can still just copy and paste the code over. Use the insert key or middle mouse button to paste the code into the window.
  4. I'm going to assume you meant to say that you're trying to split a string, not that you're trying to spit a string. Then my next question is how do you want to split it? Will the split be in the same location all the time? Will there only be one split with two output strings or are you trying to split the string into multiple parts? Like do you want to split the string into a bunch of individual words? Then what do you want to do with the strings? Maybe load each word into a table? Please be clearer with what you are trying to do/accomplish.
  5. HI, so I've made two programs aimed at measuring server ticks per second (TPS). One is as monitor based program and the other is designed to display on a T2 hologram. The Github address are https://github.com/ATastyPeanut/OpenComputers-Minecraft-Lua/tree/master/Ticks-Second-Tools the TPSBaseRaw can also be accessed from Pastebin at http://pastebin.com/t73SikXu Below is the standalone measure its name is OC-TPS-Check.lua The bars change color based on what the estimated TPS is, a TPS of 10 and below is red, 10 and up is and increasing Hue. Below is the Hologram based Estimator its name is TPS-Holo-Display.lua The TPS number changes color the same as bars. The Hologram also uses the .setRaw function which gets rid of the annoying redraw time. (If you get an error about f not existing then you should check to make sure TPSBaseRaw is saved in the same folder and is named "TPSBaseRaw" with no file extension. Hopefully someone else will find the tools useful, or learn a new way to do things from the code! Thank you. OC-TPS-Check.lua TPS-Holo-Display.lua TPSBaseRaw.txt
  6. Hi, for a basic timer you can use this: local com = require "component" local rs = com.redstone while true do rs.setOutput(1,0) os.sleep(360) rs.setOutput(1,15) os.sleep(30) end However, you should check to see if you can use an adapter with the thermalilies as a way to pull weather they are ready for more lava or not, thus eliminating the need for a timer. To check whether it's a valid component type "components" to get a list of connected components (after you place an adapter next to it). Then you can use this Pastebin program I wrote to check its API, http://pastebin.com/xVKqv7GE if you still need help from there post the results you get for its API and I'll see if I can write something up for you as a starting point. GL -Peanut
  7. Hey can you please include the snippet of code that caused the error since I'm not sure my computer format your file correctly.
  8. Hi vitamin_c, I actually wrote a program to do just that. I'm not sure if it will fit your needs exactly but it can provide a good jumping off point for what you need to do. http://pastebin.com/HFXnDqRs is the Pastebin link. Best of luck.
  9. Hi, what's nice is that robot.forward, etc return a value. Learn more about the function returns on this wiki page http://ocdoc.cil.li/api:robot So all we need to do is check its return value as being true or nil. When it's nil, then it returns a reason why it's failed. In the code below I included two possible reasons it could have failed, and you can add what you want it to do yourself. Hope it helps you, also try having it either be on pastebin/github or just written in the post details so that we don't need to download sketchy internet files. Wish I knew how to put the code in the spoiler thing. :/ local os = require("os") local component = require("component") local robot = require("robot") local computer = require("computer") local shell = ("shell") function up(a) while a >= 1 do local result, possibleError = robot.up() if result == true then a = a - 1 else print(possibleError) if possibleError == "solid" elseif possibleError == "entity" else end end end end function forward(a) while a >= 1 do local result, possibleError = robot.forward() if result == true then a = a -1 else print(possibleError) if possibleError == "solid" elseif possibleError == "entity" else end end end end function back(a) while a >= 1 do local result, possibleError = robot.back() if result == true then a = a - 1 else print(possibleError) if possibleError == "solid" elseif possibleError == "entity" else end end end end function down(a) while a >= 1 do local result, possibleError = robot.down() if result == true then a = a - 1 else print(possibleError) if possibleError == "solid" elseif possibleError == "entity" else end end end end function sleep(a) os.sleep(a) end
  10. well you assigned the component to the correct thing to start then you reassigned it to the sides api. Try this instead, also put the code into the code quotes. there is a button for it that looks like this <> it makes code stand out like code. local component = require "component" local sides = require "sides" local color = require "color" --for fun lets use a variable for the Redstone card too local redstone = component.redstone --oh and you need to use setBundledOutput from the tier 2 card redstone.setBundledOutput(sides.back, color.lightGrey, 16) print("Event Initialized") Bear in mind, I didn't test any of this so it might not work, but it addresses the obvious issues. Best of luck doing the thing
  11. Hey Neo, I'm sorry if I don't understand your problem or what you're trying to do. But from what you wrote it seems like you would like to be able to call a function and have all the chat boxes say the word you passed. Something like this should work though, right? local com = require "component" local function speak(phrase, distance, name) for address, componentType in com.list("chat_box") do com.invoke(address,"setName", name) com.invoke(address,"say", phrase, distance) end end speak("say my name", 10, "Jimmy")
  12. So I wrote a proof of concept code that does successfully write characters to stand for the series of 4 base4 numbers and also successfully reads the file back. http://pastebin.com/SKAkEM8w Sorry if I was supposed to put the code in a spoilers tag, I couldn't figure out how to. local fs = require "filesystem" local string = require "string" local testDensity = {} local j = 0 for i=0,255 do testDensity[i] = math.floor(math.random()*3) end local number1 = 0 local number2 = 0 local number3 = 0 local number4 = 0 --convert a passed number to base 4 local function convToFour(num) number4 = math.floor(num)%4 number3 = (math.floor(num/4))%4 number2 = (math.floor(num/16))%4 number1 = (math.floor(num/64))%4 end --convert a passed number to base 10 from base 4, numbers must be in range of 0-3 for all places local function convToTen(num) local bTenNum1 = math.floor(num/1000) local bTenNum2 = math.floor((num-(bTenNum1*1000))/100) local bTenNum3 = math.floor((num-bTenNum1*1000-bTenNum2*100)/10) local bTenNum4 = math.floor(num-bTenNum1*1000-bTenNum2*100-bTenNum3*10) local bTenNum11 = bTenNum1*4^3 local bTenNum22 = bTenNum2*4^2 local bTenNum33 = bTenNum3*4^1 local bTenNum44 = bTenNum4*4^0 return(math.floor(bTenNum11+bTenNum22+bTenNum33+bTenNum44)) end local str = "" for i=0,63 do local compressedNum = 0 --turns 4 table values into a fake base 4 number that the convToTen can work with compressedNum = testDensity[i*4] * 1000 compressedNum = compressedNum + testDensity[i*4+1] * 100 compressedNum = compressedNum + testDensity[i*4+2] * 10 compressedNum = compressedNum + testDensity[i*4+3] --then uses that number to write a character assosiated with it str = str..string.char(convToTen(compressedNum)) end print(str) print(string.len(str)) local file = io.open("testBinaryFile", "w") file:write(str) io.close(file) str = "" --tests to make sure it can write and read correctly local file = io.open("testBinaryFile", "r") str = file:read("*all") io.close(file) local recompiledString = "" for i = 1,64 do convToFour(string.byte(string.sub(str,i,i))) recompiledString = recompiledString..tostring(number1) recompiledString = recompiledString..tostring(number2) recompiledString = recompiledString..tostring(number3) recompiledString = recompiledString..tostring(number4) end print(testDensity[0]..table.concat(testDensity)) print(recompiledString)
  13. Turns out your right, it's indeed a bug with the modpack I'm using. After trying the same code you suggested earlier but in a different pack it worked exactly as one would expect it to, revealing a bunch of nonsense characters when edited in OC. Since saving binary data seems to not be an option I'm going to instead be using the string.byte() and string.char() functions. My plan is to write(string.char(#)) where the # is value i get using string.byte() on a value from 0-255. This decimal value I determine by doing a conversion from base 4 to base 10. Essentially writing the same binary data. But using the method of writing a string with the same value instead of the binary itself. I will post the converter I come up with when done. Thank you for the help you've provided with this issue GreaseMonkey, don't know what I would have done without ya.
  14. First off thank you for the reply, the string.char() function is much cleaner than what I had before. Unfortunately, the file is still blank when I open it to see if it saved correctly. As for the Lua version, I am using 5.3. Does the write() function only accept strings so that when it gets a non-string value it errors out and doesn't write anything? I also tried using io.write(d) after setting the io.output(file), but the file is still empty. Would never have guessed writing binary data would be this difficult :/ thanks for the help. Would have figured I could just write a bunch of text 0's and 1's then call some function to turn it into binary.
  15. Hello OC community, I am hoping I can get help with a project where I'm saving geolyzer data. The issue is how to make the data files small enough. My current method is to write the single digit density values 0, 1, 2, 3 into string form so that it's a string of 255 numbers. Then using the debug card's deflate function on it for final writing to the file. However, that's wasting a bunch of space since its saving the characters as 8bit values when I only need 2bit. The new way I wish to use involves saving binary data. But not the standard 8bit files but a shorter 2bit data. As in saving the values 00, 01, 10, 11 to represent air, low density, intermediate density and high density respectively. But not having them write like 00000000, 00000001, 00000010, 00000011. Follows is my attempt at the code for saving 8bit values, unfortunately, I couldn't get it to work, though. local fs = require "filesystem" --create fake testing data local testDensity = {} local j = 0 for i=1,255 do testDensity[i] = j if j > 2 then j = 0 else j = j + 1 end end --opens test binary file local file = io.open("testBinaryFile", "wb") for i=1, 255 do local bit --attempt to convert the table's value into a binary value using the escape character \ if testDensity[i] == 0 then bit = "\0" elseif testDensity[i] == 1 then bit = "\1" elseif testDensity[i] == 2 then bit = "\2" else bit = "\3" end file:write(bit) end io.close(file) The result of this code is an empty file and I am unsure how to fix it to write the binary data, and then how to make that binary data 2bit and not 8bit. Thank you for any assistance provided. I'm sorry if this post didn't follow the common guidelines, it is my first post on the site.
×
×
  • Create New...

Important Information

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