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

takaqod

Members
  • Content Count

    6
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by takaqod

  1. Hi,

     

    Just to advise, you should indent your code, it's much easier to detect bugs.

     

    This is what I found : you have 2 variables called 'AdresseGp'

    When the 'coreUp()' function is executed, the local 'AdresseGp' of the function is used.

    But when you access it out of the function, this is the local 'AdresseGp' of the program scope.

     

    So i propose you to rewrite your function like this:

    function coreUp(_AdresseGp)
        for adresse, typName in hardware.list() do
            if typName == "mfsu" then
                _AdresseGp["EVerbunden"] = _AdresseGp["EVerbunden"] + 1
                _AdresseGp["EVorhanden"] = _AdresseGp["EVorhanden"] + hardware.proxy(adresse).getEUCapacity()
                _AdresseGp["EDerzeit"] = _AdresseGp["EDerzeit"] + hardware.proxy(adresse).getEUStored()
                _AdresseGp["ESpannung"] = _AdresseGp["ESpannung"] + hardware.proxy(adresse).getDemandedEnergy()
                _AdresseGp["ETick"] = _AdresseGp["ETick"] + hardware.proxy(adresse).getEUOutputPerTick()
            end
        end
    end
    

    And use it like so:

    coreUp(AdresseGp)
    

    Full suggestion with changes

     

    local hardware = require("component")
    local term = require("term")
    local os = require("os")
    local gpu = hardware.gpu
    
    local zahl = 0
    local AdresseGp = {["EVerbunden"]=0, ["EVorhanden"]=0, ["EDerzeit"]=0, ["ESpannung"]=0, ["ETick"]=0}
    
    function coreUp(_AdresseGp)
    	for adresse, typName in hardware.list() do
    		if typName == "mfsu" then
    			_AdresseGp["EVerbunden"] = _AdresseGp["EVerbunden"] + 1
    			_AdresseGp["EVorhanden"] = _AdresseGp["EVorhanden"] + hardware.proxy(adresse).getEUCapacity()
    			_AdresseGp["EDerzeit"] = _AdresseGp["EDerzeit"] + hardware.proxy(adresse).getEUStored()
    			_AdresseGp["ESpannung"] = _AdresseGp["ESpannung"] + hardware.proxy(adresse).getDemandedEnergy()
    			_AdresseGp["ETick"] = _AdresseGp["ETick"] + hardware.proxy(adresse).getEUOutputPerTick()
    		end
    	end
    end
    
    term.clear()
    while true do
    	term.clear()
    	coreUp(AdresseGp)
    	term.setCursor(1,1)
    	if AdresseGp["EVerbunden"] <= 0 then
    		if zahl == 0 then
    			gpu.setBackground(0xFFFFFF)
    			gpu.setForeground(0xFF0000)
    			print("? Fehler: Es sind keine Devices Verbunden ---")
    			zahl = 1
    		else
    			gpu.setBackground(0x000000)
    			gpu.setForeground(0xFFFFFF)
    			print("? Fehler: Es sind keine Devices Verbunden ---")
    			zahl = 0
    		end
    	else
    		gpu.setBackground(0x000000)
    		gpu.setForeground(0xFFFFFF)
    		print("!Fehler: Quell Code in Beta!")
    	end
    	gpu.setBackground(0x000000)
    	gpu.setForeground(0xFFFFFF)
    	print("###########################################")
    	print("Energie Speicher Verbunden : "..AdresseGp["EVerbunden"])
    	print("Energie Speicher Insgesammt: "..AdresseGp["EVorhanden"])
    	print("Energie Speicher Derzeit   : "..AdresseGp["EDerzeit"])
    	print("Energie Akku Ladestand     : ".."n/a")
    	print("Energie Spannung           : "..AdresseGp["ESpannung"])
    	print("Energie Richtung  Derzeit  : "..AdresseGp["ETick"])
    	os.sleep(0.5)
    end
    
    
  2. Hi,

    I want to start coding some programs in OC but i'm facing questions i would like to solve before really writing.

    1) IDE
    I usually write in NotePad++ for simple Lua programs, but i'm thinking, there must be a better way to do it for code completion, etc.
    I already checked this wiki but i want to see your personal opinions and reasons.

    2) Project Management
    I chose to use Git/GitHub for source management and i wish to have one repo for each libraries, programs, etc.
    In this way, i could easily have independent releases, and this will force me to thinking in modular and reusable manner.
    But this will also greatly increase the amount of repo and will messed up my github account with a bunch of relative projects (OC lua) side by side with potentials other projects.
    So i'm searching a way to have all the pros of multiple repositories whitout the con of the spread.
    Like one big repo container with multiple real repo in it.
    The best compromise i found is the use of an organization for that. But i ask because i must miss something easier.

    3) OC librairies
    To have access in libraries, we use 'require', ok.
    But how it works? Is there a specific directory on the in-game computer for libraries storage?
    And if not how OC knows where to search?

    If i want multiple instances of one library on a computer for example :
    myLib(v1.0.0) and myLib(v2.0.0) used by two different programs but not the same version.
    how can i handle this?


    Thanks for your answers and suggestions!

     

×
×
  • Create New...

Important Information

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