Jump to content




shell.resolve not working


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

#1 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 10 September 2016 - 08:48 AM

Hi there,
I'm trying to make an API that prints a string based on the language you select using tables. For doing this it uses a language pack file, so I wanted to use shell.resolve, given that it isn't essential I think it's pretty useful. But it gives me a "attempt to index ? (a nil value)" error on line 1. I've also tried to use it in another program and it just works fine. Can someone help me?

Here it is the code:
Spoiler
I would also be happy if you have any other suggestions about the program in any way. Thanks

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 September 2016 - 12:15 PM

APIs aren't run as children of a specific shell instance, so they won't have the shell (or multishell) tables in their environment. You could copy the function out of the shell program, but a better option is probably to have your API create and return instances that programs can use to load up a specific language pack, so multiple programs could use your API at the same time for different language packs.

#3 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 10 September 2016 - 02:38 PM

So, I should just make the API print the strings... The current language would be stored in a variable into the program that uses the API... But in this way every function in the API should have an argument that defines the path of the language pack.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 September 2016 - 02:51 PM

I'd go the route of having your API construct a table with various methods in it. The API would have a function to create and return this table, and one argument would be the path to the language pack. This table would have the language pack data loaded into it, and have functions placed into it that the program calling the API can use to get the translated strings. The program would then just call the constructor function in the API and then call the functions in the table the API returned. You could read through the vector API that comes with ComputerCraft for a simple example.

#5 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 10 September 2016 - 03:39 PM

Thanks a lot. I had never seen it before, and I'll certainly look through it. Thanks again!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users