Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Forum Connectivity Upgrade Read more... ×

Search the Community

Showing results for tags 'lua'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Minecraft


GitHub


IRC


Location


Interests

Found 13 results

  1. Varscott11

    Lua force garbage collection?

    I'm writing a kernel that has cooperative multi-tasking. It works great, but one job of it is to track a process' memory usage. It can track more memory being used but If the coroutine sets a bunch of stuff to nil, it should be able to subtract the difference as well. However sometimes the garbage collector might not get around to freeing it by the time the test is performed leading to an inaccurate result. Is there some way of forcing a garbage collector cycle?
  2. I am attempting to write an OS from scratch and I have come up with a couple questions that somebody can hopefully clarify for me as I cannot continue without the following knowledge. 1).Since a critical function like require is unavailable, can someone point me to general steps needed to write a custom require function. 2).What would be needed to implement a custom filesystem without any libraries from openos. Any help is greatly appreciated
  3. IceG4merBR

    Got a problem with reactor.setActive()

    I did a program to manage my batteries and reactors, and i got a problem in reactor.setActive(true/false) for address, name in pairs(reactorsID) do local reactor = component.proxy(address) countR = countR + 1 local tR = (countR + count) * 3 progressBar( name, tR, reactor.getEnergyStored(), reactor.getEnergyCapacity(), 0x00bb00, true, "RF") progressBar( "Reactor(Energy Last Tick)", tR + 3, math.ceil(reactor.getEnergyProducedLastTick()), 6200, 0x00bb00, true, "RF") if brPower + totalPower < brMaxPower + totalMaxPower then reactor.setActive(True) else reactor.setActive(False) end end The reactor doesn't turn on or off, and the program doesn't return any error . Here is the full code : https://pastebin.com/gkmtstis
  4. IceG4merBR

    attemp to index a nil value (local 'i')

    Got this error, but i have no idea how to fix it, need some help!. Here is the code. local component = require("component") local term = require("term") local gpu = component.gpu local cube = component.basic_energy_cube local event = require("event") local colors = { black = 0x000000, red = 0xC14141} gpu.setBackground(colors.black) term.clear() local infos = {} cube["stats"] = {} function setInfos() infos["stored"] = { x = 3, y = 2, weight = 73, height = 1, title = "STORED ENERGY : ", unit = " RF"} infos["capacity"] = { x = 3, y = 4, weight = 73, height = 1, title = "BATTERY CAPACITY : ", unit = " RF"} end function printInfos(infoName) local maxLenght = 15 local i = infos[infoName] gpu.set(i.x, i.y, i.title .. cube.stats[infoName] .. i.unit) end function updateCubeStats() cube.stats["stored"] = cube.getEnergyStored end function startup() updateCubeStats() setInfos() printInfos() end startup() repeat updateCubeStats() until event.pull(0.1) == "interrupted"
  5. IceG4merBR

    How can i terminate this program?

    I did this program, it's very simple, but i want to terminate it and i don't know how to do it... I tried Ctrl + C, Ctrl + Alt + C. I need some help. local component = require("component") local term = require("term") local event = require("event") local keyboard = require("keyboard") local cube = component.basic_energy_cube local computer = component.computer local gpu = component.gpu local w, h =gpu.getResolution() local colors = {} colors.gray = 0x555555 colors.red = 0xFF0000 colors.lime = 0x00FF00 function label(x, y, message, color, ...) local color = color or gpu.getForeground() local oldColor = gpu.getForeground() gpu.setForeground(color) term.setCursor(x, y) print(string.format(message, ...)) gpu.setForeground(oldColor) end function toMRf(val) return val / 1000000 end function toJ(val) return val / 4 / 100000 end os.sleep(2) term.clear() computer.beep(1000,1.5) while true do energy = toMRf(cube.getEnergyStored()) energyMax = toMRf(cube.getMaxEnergyStored()) energyJ = toJ(cube.getEnergyStored()) energyMaxJ = toJ(cube.getMaxEnergyStored()) label(1, 1, "%.2f MRf / %.2f MJ (Energia Acumulada)", colors.red, energy, energyJ ) label(1, 3, "%.2f MRf / %.2f MJ (Capacidade da bateria)", colors.lime, energyMax, energyMaxJ) end
  6. So I am coming from ComputerCraft and the term API there is pretty straight forward and allows us to create windows to write / redirect to. Anyway, in the term API wikipage of OpenComputers there is for example the method term.bind with an optional parameter "window", the problem is I can't find any information about this parameter and I assumed that this would be the same kind of "window" as in CC and I won't have to write my own API for it. Do you guys know something about it?
  7. Gladox114

    Testing nummber

    I know that "not nil" is wrong but how to test if the input is a nummber and do something when input is a nummber. read = io.read() if string.match(read, "(%d+)") == not nil then -- do something end
  8. Gladox114

    Testing nummber

    I know that "not nil" is wrong but how to test if the input is a nummber and do something when input is a nummber. read = io.read() if string.match(read, "(%d+)") == not nil then -- do something end
  9. Michael

    Energy Stored

    Hello everyone, I'm trying to set up a Opencomputers energy monitoring system that will control the energy level of an Industrialcraft2 mfsu by turning on 1 to 6 reactors but I'm having problems at the energy reading part. Here is my code so far: https://pastebin.com/654kRYaf (ignore that getEnergyStored is commented out, I was testing something and uploaded to pastebin wrong version), but here is an abbreviated version with comments: -------------start of script---------- local fill = 0 --predefine variable fill local cap = 0 --predefine variable capacity require 'normal' things (event, component, term, colors, sides) local rs = component.redstone --Redstone I/O block local mfsu = component.ic2_te_mfsu ---as shown when components is run ----------create writing------------------ ---create writing and boxes ----------reset redstone (just in case) ---- set colors used to 0 ------------------------------------------- ------------------------------------------------------------------------ while true do local _,_,x,y = event.pull("touch") -----works up to this point fill = mfsu.getEnergyStored() --find amount of energy in mfsu cap = mfsu.getMaxEnergyStored() --find capacity of mfsu print(fill, cap) ---print it (temp) --------check user clicks squares and set redstone outputs-------- --//insert computer turn on reactors here (to do later)\\-- end ---end of script--- I plan to implement code that will turn off and on the reactors depending on the amount of energy in the mfsu but I havent been able to read the amount of energy in the mfsu to be able to make the calculations. (the big empty space on the left of the screen is for a progress bar that is currently hidden, which depends on the amount of energy in the capacitor) As you can see (bellow) the code works fine until the user clicks the screen, at which point it errors, the Max energy or current energy "returns a nil" and the code discontinues running. to my understanding this means that this doesn't exist therefore what is the current terminology? I could find one that works but I wanted to make one myself. Minecraft v. 1.10.2 Age Of Engineering v. 1.1.2 (Twitch modpack) OpenComputers v. 1.7.1.150
  10. GreenHawk1220

    3D printer 'Empty block' error

    I sent the command '=component.printer3d.addShape(6,6,0,9,7,0,"hardened_clay_stained_lime")', and ended up with this error 'empty block' That's it. What am I doing wrong?
  11. Good morning. I have a problem with an operation to do in the LUA language: I have a file in which I have stored data, separated by line. I would need to read this file and store every line of this in an array, ignoring the first one. For example: array = {line2, line3, etc} Next, I would also need to compare each of these lines with a string, to check if it is contained, and I would need to know how to do both. Thanks in advance for the help.
  12. The Simon

    Trouble with Library

    Hi! I have some problems with getting this library to work that should add buttons to the hud of the mod OpenGlasses: I made it first as a program and then converted it to a library for better organization of the code (and for later use). It worked fine when it was a program that called it's own functions, but now it throws errors when it calls them from another program. It says it can't insert the value to the empty table "API.buttonsName". When it was a standalone table it worked fine to insert the value into it, but it keeps saying the that spot is "bad" (that it doesn't exist?). I did try as you guys can see another method to insert it, to no success. Here is the program that calls the library: --buttonTest1.lua local gButtons = require("gButtonAPI3") local function test1() print("Working.") end gButtons.createNewButton("box1","Box 1",2,8,45,15,255,0,0,test1) while true do gButtons.update() end And here is the whole library (better write too much than too little): --gButtonsAPI3.lua local component = require("component") local event = require("event") local API = {} local glasses = component.glasses API.buttons = {} API.buttonsNames = {} local xV, yV = -1,-1 function API.createNewButton(name,label,x,y,w,h,cR,cG,cB,callback) --API.buttonsNames[#buttonsNames+1] = name table.insert(API.buttonsNames, name) API.buttons[name] = { rect = glasses.addRect(), lbl = glasses.addTextLabel(), posRect = {x,y}, sizeRect = {w,h}, colo = {cR,cB,cG}, state = false, callbk = callback, posTxt = {x + (w / 2) - ((string.len(label) / 2) + (w / 4.5)),y + (h / 3)} } API.buttons[name]["rect"].setPosition(x,y) API.buttons[name]["rect"].setSize(w,h) API.buttons[name]["rect"].setColor(cR,cG,cB) API.buttons[name]["rect"].setAlpha(0.4) API.buttons[name]["lbl"].setPosition(API.buttons[name]["posTxt"][1],API.buttons[name]["posTxt"][2]) API.buttons[name]["lbl"].setText(label) API.buttons[name]["lbl"].setScale(1) API.buttons[name]["lbl"].setColor(255,255,255) end function clickEvent(id, device, user, x, y, button, maxX, maxY) fX = x * (512 / maxX) fY = y * (288 / maxY) xV = fX yV = fY end local function initialize() event.ignore("interact_overlay", clickEvent) event.listen("interact_overlay", clickEvent) end initialize() function API.update() os.sleep(1/20) for i in pairs(API.buttonsNames) do if xV >= API.buttons[API.buttonsNames[i]].posRect[1] and xV <= API.buttons[API.buttonsNames[i]].posRect[1]+API.buttons[API.buttonsNames[i]].sizeRect[1] and yV >= API.buttons[API.buttonsNames[i]].posRect[2] and yV <= API.buttons[API.buttonsNames[i]].posRect[2]+API.buttons[API.buttonsNames[i]].sizeRect[2] then API.buttons[API.buttonsNames[i]].callbk() xV = -1 yV = -1 end end end return API And the error log is attached to this post as a picture: If anyone got any idea what could be the error, I gladly accept any answer! If anyone has questions about the code just ask me and I'll try explaining what it does (or rather "should" do).
  13. The Simon

    Trouble with Lua

    Hi! I'm trying to do buttons in a OpenComputers addon OpenGlasses. But it seem to have problems with calling the element from the table. I am not very used to Lua and this is my first big project I'm working on in Lua. local component = require("component") local glasses = component.glasses local buttons = {} local function newButton(name,x,y,w,h,cR,cG,cB) buttons[name] = { rect = glasses.addRect(), pos = {x,y}, size = {w,h}, colo = {cR,cB,cG} } buttons[name][rect].setPosition(buttons[name][pos][1],buttons[name][pos][2]) --Here it says the value is null. buttons[name][rect].setSize(buttons[name][size][1],buttons[name][size][2]) buttons[name][rect].setColor(buttons[name][colo][1],buttons[name][colo][2],buttons[name][colo][3]) --And probably here too... end newButton("box1",2,2,10,10,255,0,0) It says the variable it's trying to reach is null for some reason. Any help would be appreciated.
×

Important Information

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