Jump to content




Creating an Ink-based program-creator.. Help


  • You cannot reply to this topic
7 replies to this topic

#1 Goof

  • Members
  • 751 posts

Posted 30 March 2014 - 06:03 PM

Hello everyone!

Im trying to make an unofficial Ink-based program-creator program, but im quite stuck in making headerMenus...

The first menu does never show up?

Picture:
Posted Image
Picture info: There should be a button called "Edit" just before the "View" button... but it seems like its not even creating that? nothing happens when i click on the "edit" invisible button's position, but it works with the "View", "Project" etc...

CODE ( line 34 to 72 and 259 to 290 )

Thanks in Advance

Edited by Mikk809h, 30 March 2014 - 06:03 PM.


#2 CometWolf

  • Members
  • 1,283 posts

Posted 30 March 2014 - 06:41 PM

My that is a messy setup you have there, you're gonna have to do some debugging yourself. Here's the funcftion i use to debug variables
debug = {
  times = 0,
  prep = function()
    screen:setBackgroundColor(colors.black)
    screen:setTextColor(colors.white)
    screen:setLayer(6)
    screen:fill()
    screen:setCursorPos(1,1)
  end,
  pause = function()
    while true do
	  local _e,key = os.pullEvent"key"
	  if key == 14 then
	    error()
	  else
	    return
	  end
    end
  end,
  variables = function(...)
    debug.times = debug.times+1
    local tLines = {}
    for i=1,#arg do
	  local var = arg[i]
	  if not var then
	    tLines[#tLines+1] = "nil"
	  elseif type(var) == "table" then
	    for k,v in pairs(var) do
		  tLines[#tLines+1] = k..": "..tostring(v)
	    end
	  else
	    tLines[#tLines+1] = type(var).." "..var
	  end
    end
    local lines = tTerm.screen.y-2
    local pages = math.ceil(#tLines/lines)
    for page = 1,pages do
	  debug.prep()
	  print("Page "..page.."/"..pages.." Debug call #"..debug.times.." on "..tFile.program)
	  for line = lines*(page-1)+1,lines*page do
	    if not tLines[line] then
		  break
	    else
		  print(tLines[line])
	    end
	  end
	  debug.pause()
    end
  end,
}
I'd suggest using it to check the variables determining where the text is loacted. See if any of them are incorrect, then check where they're generated.
	  v["position"] = {}
	  v["position"]["xPos"] = xText;
	  v["position"]["xMin"] = xStart;
	  v["position"]["xMax"] = xEnd;
	  v["position"]["yMin"] = yMin;
	  v["position"]["yMax"] = yMax;
	  debug.variables(v.position)


#3 Goof

  • Members
  • 751 posts

Posted 30 March 2014 - 06:44 PM

Well i can only say that something in that debugging code is wrong... thers attempt to index'es ( a nil value ) several times... woo?

Is this debug-program used in something else with custom term etc?

#4 CometWolf

  • Members
  • 1,283 posts

Posted 30 March 2014 - 06:46 PM

oh right, my bad :P
debug = {
  times = 0,
  prep = function()
    term.setBackgroundColor(colors.black)
    term.setTextColor(colors.white)
    term.clear()
    term.setCursorPos(1,1)
  end,
  pause = function()
    while true do
		  local _e,key = os.pullEvent"key"
		  if key == 14 then
		    error()
		  else
		    return
		  end
    end
  end,
  variables = function(...)
    debug.times = debug.times+1
    local tLines = {}
    for i=1,#arg do
		  local var = arg[i]
		  if not var then
		    tLines[#tLines+1] = "nil"
		  elseif type(var) == "table" then
		    for k,v in pairs(var) do
				  tLines[#tLines+1] = k..": "..tostring(v)
		    end
		  else
		    tLines[#tLines+1] = type(var).." "..var
		  end
    end
    local lines = tTerm.screen.y-2
    local pages = math.ceil(#tLines/lines)
    for page = 1,pages do
		  debug.prep()
		  print("Page "..page.."/"..pages.." Debug call #"..debug.times.." on "..tFile.program)
		  for line = lines*(page-1)+1,lines*page do
		    if not tLines[line] then
				  break
		    else
				  print(tLines[line])
		    end
		  end
		  debug.pause()
    end
  end,
}
There, try that

#5 Goof

  • Members
  • 751 posts

Posted 30 March 2014 - 06:52 PM

tTerm.screen.y-2 is making everything error...
Spoiler
startup:43: attempt to index ( a nil value! )


#6 CometWolf

  • Members
  • 1,283 posts

Posted 30 March 2014 - 06:54 PM

Guess i should get around to throwing this stuff in a standalone api at some point, it's proven quite handy lol.
just change it to 17, it's the size of the screen on the y-axis.

#7 Goof

  • Members
  • 751 posts

Posted 30 March 2014 - 06:56 PM

xD... now theres an error online 47
print("Page "..page.."/"..pages.." Debug call #"..debug.times.." on "..tFile.program) -- what is tFile.program?
Same type of error. (attempt to index)


EDIT: Im going to make a quick debug test... then ill respond

EDIT 2:
Well after some debugging, i found out that i wasn't setting the cursor position at the beginning so everything went to place the
text/button -1 to the comparrison of the table,
which makes the first button invisible.
so End result so far:
CODE

Edited by Mikk809h, 30 March 2014 - 07:08 PM.


#8 CometWolf

  • Members
  • 1,283 posts

Posted 30 March 2014 - 07:07 PM

It's not really important, it's the path of the program. You can change it to shell.getRunningProgram()





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users