- ComputerCraft | Programmable Computers for Minecraft
- → ReBraLaCC's Content
ReBraLaCC's Content
There have been 76 items by ReBraLaCC (Search limited from 10-February 22)
#258390 [FIXED] Cannot serialize type function?
Posted by
ReBraLaCC
on 25 August 2016 - 12:27 PM
in
Ask a Pro
But I ran in to this error
Cannot serialize type function
And I have no idea why this happens
So if you guys could see what I'm doing wrong
API: -- called Utils..
buttons = {}
local len = string.len
local sub = string.sub
local width,height = term.getSize()
function reset()
buttons = {}
end
function drawButtons()
if len(textutils.serialise(buttons)) > 0 then
for k,v in pairs(buttons) do
term.setTextColor(v.textC)
term.setBackgroundColor(v.backC)
term.setCursorPos(v.pos.x,v.pos.y)
term.write(" "..v.text.." ")
end
end
end
function addButton(label,name,px,py,func,tC,bC,r) -- Button Management
if px == "mid" then
a = width-len(" "..name.." ")
px = a/2
end
local tries = 0
defLabel = label
while buttons[label] ~= nil and not r do
tries = tries+1
label = defLabel..""..tries
end
buttons[label] = {
["text"] = name,
["func"] = func,
["pos"] = {
["x"] = px,
["y"] = py,
},
["textC"] = tC,
["backC"] = bC,
}
return label
end
function removeButton(label)
found = false
for k,v in pairs(buttons) do
r = 1
if k == label then
found = true
end
r = r+1
if found then
buttons[label] = nil
break
end
end
return found
end
function checkClick(x,y)
for k,v in pairs(buttons) do
if x >= v.pos.x and x <= v.pos.x+len(v.text)+1 and y == v.pos.y then
v.func()
end
end
end
function clear(c)
c = c or colors.black
term.setBackgroundColor(c)
term.clear()
end
Program itself:
os.loadAPI("Utils")
test = function()
print("works")
end
---------------- Label name x y function textcolor backcolor
Utils.addButton("clrScrn", "Clear", "mid", 3, test, colors.white, colors.purple)
Utils.drawButtons()
while true do
_, button, x, y = os.pullEvent("mouse_click")
Utils.checkClick(x, y)
end
I've added the thing at Utils.addButton (in the program not API) because i think somewhere these is the problem
Thanks already for taking a look
-- ReBraLa
#258197 Keybindings?
Posted by
ReBraLaCC
on 20 August 2016 - 10:01 AM
in
Ask a Pro
while true do
ev = {os.pullEvent()}
if ev[1] == "key" then
ev2 = {os.pullEvent()}
if ev2[1] == "key" then
if ev[2] == keys.leftCrtl and ev2[2] == keys.u then
return true
end
end
end
end
i hope that there is maybe a simpler way to do this and a working one
thanks
-- ReBraLa
#258160 Minecraft Map....
Posted by
ReBraLaCC
on 19 August 2016 - 05:49 PM
in
Media
A Map?
Yes I've been working on a map..
Maybe you're rigt now asking, Why and what kind?
Well.. It's not going to be an adventure map or horror map or something like that...
No not at all... What it is going to be is a map that you need to code for ![]()
Well not really code but a bit like this Hour of Code
It lets you look at the code also, this will I be implementing also!
What should the name be of the map? Because I don't know ![]()
I hope I'll get this 'done' quickly, so i'm done with coding and can start building the map ![]()
Somewhere a link to a photo of the map......
-- ReBraLa
#258110 AdvancedOS
Posted by
ReBraLaCC
on 18 August 2016 - 07:51 PM
in
Operating Systems
#257894 Scoreboard Program
Posted by
ReBraLaCC
on 12 August 2016 - 03:43 PM
in
APIs and Utilities
#257891 Scoreboard Program
Posted by
ReBraLaCC
on 12 August 2016 - 02:29 PM
in
APIs and Utilities
A Lot of people are looking for a scoreboard program.
but those use monitors..
Ánd doesn't it look way better on the side of the screen?
Well that's what i thought!
So I've been working on a command program that creates a sidebar with what ever you want on it!
Screenshots:
maybe for a map?

in a list

Some information you need to know!
When using this program first run it as 'scoreboard init'
that will create all the things needed to run this properly
Wanna remove all the things it created? use 'scoreboard de-init'
Loading a scoreboard file is the simplest thing in the world! just use 'scoreboard load <file>'
Formatting the file is a bit harder... See this example G31x0vAb
A list of all the colors
"black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", "white"
Type them with the _ otherwise they won't work!
Okay now the fun part.... DOWNLOAD!!!!
pastebin get 11P0AHK4 scoreboard
and remember first 'scoreboard init'!!! Have fun!
CAUTION: The names as in Balance and such can't have spaces in between if you want spaces download a recourse pack that removes a letter as a space and use that letter!
#255763 RandString - a random string generator API
Posted by
ReBraLaCC
on 08 July 2016 - 03:05 PM
in
APIs and Utilities
#255723 I cant use Peripheral.wrap. ...
Posted by
ReBraLaCC
on 07 July 2016 - 07:00 PM
in
Ask a Pro
<def> is the definition you gave it
would suggest looking at this http://computercraft.info/wiki/Monitor
#255504 Circles 2 - A Simple API that draws circles
Posted by
ReBraLaCC
on 04 July 2016 - 08:00 PM
in
APIs and Utilities
function filledCircle(rad,centerx,centery,color) for i = 1,rad do draw(rad-i+1,centerx,centery,color) end end
maybe it works but its a prototype
nice api!
#255173 [SOLVED] Weird Bug
Posted by
ReBraLaCC
on 30 June 2016 - 03:57 PM
in
Ask a Pro
And the second time I do it, it renders the cubes in black color (if i reboot the computer it works again)
Maybe there is something wrong with the code so that's why i've posted it here
w,h = term.getSize()
colors = {colors.white,colors.green,colors.yellow,colors.red,colors.blue,colors.orange}
local function renderCube(side)
for k,v in pairs(cube[side]) do
drawPiece(cube[side][k],k)
end
end
function drawPiece(var,nPiece)
if nPiece == 1 then
paintutils.drawFilledBox(w/2-2-5,h/2-2-2,w/2-2-2,h/2-2,var)
elseif nPiece == 2 then
paintutils.drawFilledBox(w/2-2,h/2-2-2,w/2-2+3,h/2-2,var)
elseif nPiece == 3 then
paintutils.drawFilledBox(w/2-2+5,h/2-2-2,w/2-2+8,h/2-2,var)
elseif nPiece == 4 then
paintutils.drawFilledBox(w/2-2-5,h/2-2+2,w/2-2-2,h/2-2+4,var)
end
end
for a = 1,100 do
drawPiece(colors[math.random(1,6)],1)
drawPiece(colors[math.random(1,6)],2)
drawPiece(colors[math.random(1,6)],3)
drawPiece(colors[math.random(1,6)],4)
sleep(0.04)
end
#254924 Custum Turtle API
Posted by
ReBraLaCC
on 27 June 2016 - 09:12 AM
in
APIs and Utilities
#254898 Custum Turtle API
Posted by
ReBraLaCC
on 26 June 2016 - 10:00 PM
in
APIs and Utilities
KingofGamesYami, on 26 June 2016 - 09:56 PM, said:
http://computercraft...iki/Rednet_(API)
don't see a
rednet.brodcast()
#254896 Custum Turtle API
Posted by
ReBraLaCC
on 26 June 2016 - 09:53 PM
in
APIs and Utilities
#254847 [SOLVED] Problem with math.random()
Posted by
ReBraLaCC
on 26 June 2016 - 01:31 PM
in
Ask a Pro
Dog, on 25 June 2016 - 08:31 PM, said:
math.random(math.min(x - 1, x - spreadRad), math.max(x - 1, x - spreadRad))
NanoBob, on 25 June 2016 - 08:21 PM, said:
ReBraLaCC, on 25 June 2016 - 07:46 PM, said:
math.random(x-1,x-spreadRad)
The first parameter, x is 35. And spreadRad (third parameter) is 5.
fire(35,19,5,5,13,6,colors.black)
So your math random is basicly
math.random(35-1,35-5)Which results in
math.random(34,30)Which is not valid since 30 is lower than 34. The second argument has to be higher in math.random()
Oh my gosh, you're totally right xD thanks!
- ComputerCraft | Programmable Computers for Minecraft
- → ReBraLaCC's Content


