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

superbacon

Members
  • Content Count

    3
  • Joined

  • Last visited

Posts posted by superbacon

  1. On 10/30/2016 at 11:27 AM, JuhaJGamer said:

    I have no idea how to implement color mid-print but color is achieved by these commands

    EDIT: Remember that you have to do the gpu getting at the first lines of the program(before anything else happens in the code)

    
    --Get GPU
    local c = require("component")
    local gpu = c.gpu
    --Set Foreground(text color), or Background(Background color)
    --Background color only changes for the places BEHIND THE TEXT PRINTED AFTER THIS
    gpu.setForeground(0x444444) - set text to gray
    gpu.setBackground(0x33DBFF) - set background to light blue

    This was my test result by changing the background color then writing the text, changing the cursor position, and repeating. I don't know exactly how you would go about this over the whole screen, but i hope this helps

    local gpu = require("component").gpu
    local term = require("term")
    --cursor is already set a (1,1), no need to change anything if you don't want to
    gpu.setBackground(0x003d99) -- example dark blue
    term.write("Insert your stuff here, this is basically like the print function except no auto indenting!") -- color should be different BEHIND the text here
    term.setCursor(1,3) -- Moves cursor down a bit
    gpu.setBackground(0x005ce6) -- Normal Blue
    term.write("yada yada") --only should be color behind the text
    term.setCursor(1,4) -- this is what made mine connect for some reason
    gpu.setBackground(0x66a3ff) --Lighter blue
    term.write("You get the idea") -- only color behind the text

    Hope this helps!

    2016-12-28_21.36.20.png

  2. Well, last i checked ComputerCraft does essentially the same thing without hexadecimal if i recall correctly, but the way i would go about it is on the next line, change it back to white with

    gpu.setForeground(0xFFFFFF)

    so your finished code would be

    local term = require("term")
    local component = require("component")
    local gpu = component.gpu
    term.clear()
    print(gpu.setForeground(0x2E86C1) .. "Test")
    gpu.setForeground(0xFFFFFF)

     

  3. I've been working on this library to automatically change decimal to hexadecimal, but i've been running into a few problems. The first one being that for some reason when i try to load the library, it returns;

    home/test; 1; module 'hex' not found

        no field package.preload['hex']

        no field package.delayed['hex']

    /lib/hex.lua; 3; <name> expected near '='

    Here's the code:

    hex = {}
    
    local function = hex.toHex(input)
    	local a = input/16
    	local b = a/16
    	local c = b/16
    	local d = c/16
    	local e = d/16
    	local g = input%16
    	local h = a%16
    	local i = b%16
    	local j = c%16
    	local k = d%16
    	local l = e%16
    	if g,h,i,j,k,l < 9 then
    		if g = 10 then
    			g = "a"
    		end
    		if g = 11 then
    			g = "b"
    		end
    		if g = 12 then
    			g = "c"
    		end
    		if g = 13 then
    			g = "d"
    		end
    		if g = 14 then
    			g = "e"
    		end
    		if g = 15 then
    			g = "f"
    		end
    		if h = 10 then
    			h = "a"
    		end
    		if h = 11 then
    			h = "b"
    		end
    		if h = 12 then
    			h = "c"
    		end
    		if h = 13 then
    			h = "d"
    		end
    		if h = 14 then
    			h = "e"
    		end
    		if h = 15 then
    			h = "f"
    		end
    		if i = 10 then
    			i = "a"
    		end
    		if i = 11 then
    			i = "b"
    		end
    		if i = 12 then
    			i = "c"
    		end
    		if i = 13 then
    			i = "d"
    		end
    		if i = 14 then
    			i = "e"
    		end
    		if i = 15 then
    			i = "f"
    		end
    		if j = 10 then
    			j = "a"
    		end
    		if j = 11 then
    			j = "b"
    		end
    		if j = 12 then
    			j = "c"
    		end
    		if j = 13 then
    			j = "d"
    		end
    		if j = 14 then
    			j = "e"
    		end
    		if j = 15 then
    			j = "f"
    		end
    		if k = 10 then
    			k = "a"
    		end
    		if k = 11 then
    			k = "b"
    		end
    		if k = 12 then
    			k = "c"
    		end
    		if k = 13 then
    			k = "d"
    		end
    		if k = 14 then
    			k = "e"
    		end
    		if k = 15 then
    			k = "f"
    		end
    		if l = 10 then
    			l = "a"
    		end
    		if l = 11 then
    			l = "b"
    		end
    		if l = 12 then
    			l = "c"
    		end
    		if l = 13 then
    			l = "d"
    		end
    		if l = 14 then
    			l = "e"
    		end
    		if l = 15 then
    			l = "f"
    		end
    		local hexnum = tonumber(l..k..j..i..h..g)
    		return hexnum
    	end
    	return hex

    Sorry it's so long!

×
×
  • Create New...

Important Information

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