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

CptMercury

Members
  • Content Count

    54
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by CptMercury

  1. It would be helpful to see the entire code of drawText, not only lines 39 - 50, but I may have found your problem. It seem like you named your variable 'string', is that right? If so, you are either overriding the global string variable, if you declared 'string' as a public variable, or if you used local, your code is not actually looking for the global 'string' variable, but for your local one. So basically, either way you don't have access to the string functions. In oder to solve this, you should not name your variables after globally ones unless you don't need to have access to t
  2. The inputs for gpu.copy() are x, y, width, height, x_offset (relative position to x; so the new rectangle starts at coordinate x - tx), y_offset (same as for x_offset). So basically if you want to copy the lower part to the upper part, you have to call: gpu.copy(1, y/2, x, y, 0, -y/2) -- x_offset is 0 because you want to have the rectangle at the same x position as the old one -- y_offset is -y/2 (-25 for tier 3 screen), because the rectangle starts at a smaller y value compared to the old one
  3. Alright, so I tried to incorporate a function for exporting into the searching algorithm. It does not contain all features your code has, but I think the message and red stone stuff is not too important for the search function, I hope you'll be able to add all the stuff that I left out. local component = require"component" local sides = require"sides" local event = require"event" local database = component.database local exportBus = component.me_exportbus local controller = component.me_controller local sleep = os.sleep -- exports an item stack using the connected export bus and the da
  4. Ok, I have never worked with the database component before, so I don‘t know what its limits are. But is it really necessary to use the database? Isn‘t it enough to just use the ae2 methods and look for items‘ names? Or are the labels you set not visible for the ae2 api? I‘m currently kinda busy, but on friday I will have some time to do some investigation using the database. I will let you know when I found a solution.
  5. Hey, here is a list of all methods for ic2 reactors. local component = require'component' local reactor = component.reactor reactor.getHeat() reactor.getMaxHeat() reactor.getReactorEUOutput() reactor.getReactorEnergyOutput() reactor.producesEnergy() You have to connect the reactor via an adapter.
  6. Alright, I guess I know now what you want to do. I came up with some code that allows you to do some fuzzy search, just like you wanted..hopefully local tbl = require'component'.me_controller.getItemsInNetwork() -- tbl contains all items, from getItemsInNetwork methods -- fuzzy search allows you to specify one or multiple variables -- use nil for variables you don#t want to specify -- fuzzySearch(nil, 32, nil); fuzzySearch(nil, nil, 45) etc -- this function currently looks for the 'name' entry in the table, you might need to change that local function fuzzySearch(x, y, z) local p
  7. Hey, I might have an idea how to solve your issue, but some more information might help. With what method you get these specific labels? I've been using OC with AE2 a couple times and I do not remember any method that provided data about stored items in that specific format. If you could tell me in what kind of data structure you have stored these labels and stuff like that, I might be able to help you.
  8. Ok, then it might be a bug, but I can't think of a reason why. Are you working with a computer or a robot? Could you send a screen shot of your setup? We might find a solution.
  9. Hey, don't know why oppm isn't working, but you can simply run this command: wget https://raw.githubusercontent.com/OpenPrograms/Sangar-Programs/master/geo2holo.lua geo2holo.lua
  10. I guess the geolyzer would be your best choice. I have not worked with them yet, but I guess you could do the following: You scan a large area using the geolyzer, so you don't use the 'analyze' method but the 'scan' method, that way you can scan large areas at once. This is going to take a while, it takes (I think) 0.05 s to scan one block. The max column height is 64 blocks (32 up and 32 down) but sadly I can't tell you what's the radius of the geolyzer. You don't get the kind of block at each position but the 'density' and ores have a high density. That way you scan the entire area and
  11. Hey! That is very strange, as this should work. Try this, if this doesn't work, something must be wrong. local component = require'component' for i = 0, 5 do print(component.inventory_controller.getStackInSlot(i, 1)) end
  12. Hey! It is not that hard to run a program on multiple screens and being able to interact with all monitors. If you want to have the terminal on multiple screens you could modify the modules and then restart the computer, but there might be a better solution than this. One gpu can only be bound to one screen, so you could basically write a lib that will redirect any gpu call to a function that iterates through all screens, binding the gpu and call the function for every screen. Instead of doing this by hand for every function, we're going to use metatables (if you don't know abou
  13. @Piorjade What also helps to speed up screen redrawing is to update your screen dynamically, so that you are only reprinting the areas that actually changed. Also if you are moving large areas on your screen, like scrolling or dragging, make sure to use the gpu.copy method.
  14. You can use io.open(path):read() to read a specific line, but only indirectly. But it might be easier to use the iterator io.lines(path). -- # use io.read to get the whole file, it returns a string; then use string.gmatch/string.match to extract the specific line -- # Examples: -- # Ex1: get line 5 local path = "/somepath" local count = 1 local targetline = 5 local file = io.open(path):read("*all") for line in file:gmatch("[^\n]+") do if count == targetline then return line end count = count + 1 end -- # Ex2: find line starting with # local path = "/somepath" local indicator = "#" lo
  15. Hey If you want to insert a variable into a existing string, you can use the concat operator .. (2 dots). io.open("/WH/db/"..LOC, "w") -- # this will create a string that starts with /WH/db/ and ends with the string contained by LOC
  16. 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 oper
  17. I think there might be a better solution, but this is what I came up with: local info = computer.getDeviceInfo() local cputier for k in pairs(info) do if info[k].class == "processor" then cputier = tonumber((info[k].product):match("%d")) end end
  18. 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/w
  19. Well, more practical might be not the best way to put it, but it'll reduce the amount of components you need to hook up to your computer, so reading the energy consumption of a few energy cells or of hundreds doesn't really make a difference. But you need a central place to set this system up and each energy connection cannot connect with others from this point on. It also might require some more coding than using that simple approach. Basically you have an array of 2 energy cells for each base. The robot will move back and forth placing down the adapter and applying the Redstone sig
  20. Ok, so how is your town‘s energy supply set up? Do you have central power generation and then transfer the energy to each base? If that‘s the case I might have a different approach that would make the setup smaller and more practical.
  21. Hey, I hope I interpreted your question correctly. You want to monitor how much energy your base actually consumes, the rf/t that leaves your energy storage device and not the relative difference between input and output, right? I did some testing and I came up with a solution that give you exactly that, the rf/t output of the storage device (used TE energy cell), now matter how much you input. This will stop the output of the cell for a limited amount of time tho (this is needed to do the calculation), so it's best to put a small energy storage device between the actual energy stora
  22. Ok, did some testing: You can see whats going on in a TE machine by using an adapter with an inventory controller inside, but you can not push items in/pull items out. For i/o interaction you have to use an robot equipped with an inventory controller. Then you can transfer items in and out of the machine using the robots inventory as a buffer. local component = require'component' local inv = component.inventory_controller local side = x -- #side where your inventory is attached -- #i/o stuff inv.suckFromSlot(side, slot, itemCount) inv.dropIntoSlot(side, slot, itemCount) -- #inv
  23. You might be able to manage i/o with an adapter. Just place the adapter next to the machine and put an invetory controller inside the adapter. With this you should be able to interact with the item slots in the machine. You still can not access the mashine directly, you call functions on the controller. I‘ll try it later and let you know.
  24. Btw if you want to speed up the drawing process, here are some tips: A gpu can only perform a small amount of tasks each tick. 4 copy, 8 fill, 16 set, 8 setBackground and 8 setForeground; if you call more of these funtions, they are delayed, and it seems that you call a ton of these funtions. For example instead of using gpu.fill in order to set a single character use gpu.set() since you can call it 16 times per tick. And if you want to fill a line in x direction with a string like "/" you can use gpu.set(x,y,string.rep("/", n)); the string "/" is replicated n times. This can also reduce
×
×
  • Create New...

Important Information

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