Jump to content




Api Doesn't Load Via Resource Pack


6 replies to this topic

#1 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 05 August 2013 - 11:54 AM

So basically, I want to make a resource pack that inserts my arealib API into the rom/apis folder. When I set everything up, however, any computer I try to start up freezes and just outright refuses to load, giving me a blank screen with no error. The computer's texture shows the arrow, as if a program is looping without end.

Another small example API I made works fine, and is loaded automatically, and other users' APIs work without problems as well.

Here's the resource pack: https://dl.dropboxus...ing/arealib.zip
And the API itself: http://pastebin.com/1ytHScab

I feel like I missed something somewhere that I was supposed to do or avoid in making this api, and I apologize if this is the case.

#2 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 05 August 2013 - 01:11 PM

It sounds like some kind of issue with the terminal API rather than your loading of the resource pack. I've had a lot of issues when working with the terminal API and a blank screen with no error is pretty common :P.

An error I found in the function area:fill is you're passing a y parameter to target.setCursorPos which is nil. You forgot to access the self.y value and used just y instead :P.

function area:fill()
	local line = string.rep(' ', self.width)
	target.setBackgroundColor(self.color)

	for y=self.y, self.y + self.height - 1 do
		-- Right here.
		target.setCursorPos(self.x, y)
		target.write(line)
	end

	return self
end

Other than that, you might want to check over your code for simple syntax errors which might cause an error to be thrown when the API is being loaded. Especially potential errors regarding manipulating the terminal API.

However, it still might be related to the resource pack although I don't see anything out of the ordinary with it.

#3 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 05 August 2013 - 01:37 PM

The API by itself loads normally without a resource pack, and works fine in use, so I pretty much ruled out any syntax or logic errors. As for what you've pointed out, the y there is the y in the for loop. It takes a line, and prints it the amount of times equivalent to the area's height.

for y=self.y, self.y + self.height - 1 do

And yeah, I figured it had something to do with using the term API, but it's not targeted towards using just the terminal. By that logic, setting the local "target" variable to nil would work, because the API would have nothing to do with term, but I've tried that, sadly.

#4 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 06 August 2013 - 12:59 AM

After some testing, I think I know the problem.

You're setting the variable color within the local table 'area' to white in the colors table. However, since your API name starts with 'a', it loads before APIs whose name is further on in the alphabet. Therefore, when you try to access the colors API, it hasn't been loaded and therefore throws an error because you're trying to index a nil value.

TLDR: APIs load in alphabetical order, so arealib loads before colors and throws an 'attempt to index ? a nil value' error when you try to set area.color to colors.white; the table 'colors' is nil because the colors API hasn't been loaded.

A simple, but poorly designed, solution would be to just set area.color to 32,768, but the value for colors.white might change in a future update.

P.S. Kirito kicks ass.

#5 BlankWolf

  • Members
  • 51 posts

Posted 06 August 2013 - 01:14 AM

View PostGrim Reaper, on 06 August 2013 - 12:59 AM, said:

You're setting the variable color within the local table 'area' to white in the colors table. However, since your API name starts with 'a', it loads before APIs whose name is further on in the alphabet. Therefore, when you try to access the colors API, it hasn't been loaded and therefore throws an error because you're trying to index a nil value.

TLDR: APIs load in alphabetical order, so arealib loads before colors and throws an 'attempt to index ? a nil value' error when you try to set area.color to colors.white; the table 'colors' is nil because the colors API hasn't been loaded.

A simple, but poorly designed, solution would be to just set area.color to 32,768, but the value for colors.white might change in a future update.
Oh man thanks. I hade the same problem and I could n't figure out what the problem was.
Now it works fine. Thanks again =D

#6 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 06 August 2013 - 09:05 AM

View PostGrim Reaper, on 06 August 2013 - 12:59 AM, said:

After some testing, I think I know the problem.

You're setting the variable color within the local table 'area' to white in the colors table. However, since your API name starts with 'a', it loads before APIs whose name is further on in the alphabet. Therefore, when you try to access the colors API, it hasn't been loaded and therefore throws an error because you're trying to index a nil value.

TLDR: APIs load in alphabetical order, so arealib loads before colors and throws an 'attempt to index ? a nil value' error when you try to set area.color to colors.white; the table 'colors' is nil because the colors API hasn't been loaded.

A simple, but poorly designed, solution would be to just set area.color to 32,768, but the value for colors.white might change in a future update.

P.S. Kirito kicks ass.

Holy shit, you're a genius! Thank you so much!

And yes, he does. :P

EDIT: I do believe I'd be able to use the colors table if I set an area's color on object creation, and not on API creation, so I just threw "self.color = colors.white" under area:init().

#7 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 06 August 2013 - 12:09 PM

View PostKingdaro, on 06 August 2013 - 09:05 AM, said:

I do believe I'd be able to use the colors table if I set an area's color on object creation, and not on API creation, so I just threw "self.color = colors.white" under area:init().

Great idea! :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users