Jump to content




Undefined Functions

api lua computer

2 replies to this topic

#1 1wsx10

  • Members
  • 14 posts
  • LocationMelbourne, Australia

Posted 19 October 2017 - 09:17 AM

I want to write a program that can run with or without an api.

Whenever i run it without the api loaded, i get an error at the first function call.

If i wanted to do this with some variable, i would do something like this:
function do_something(var)
	if not var then
		--do it without var
	else
		--use var
	end
end
Is there a way for me to do this with an API function that may or may not be loaded?

i was thinking maybe a second API that gives function pointers, but then that would have the same problem.

Edited by 1wsx10, 19 October 2017 - 10:06 AM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 19 October 2017 - 11:43 AM

APIs are tables and functions are variables.

if API and API.somefunction then
  --# do one thing
else
  --# do another
end


#3 1wsx10

  • Members
  • 14 posts
  • LocationMelbourne, Australia

Posted 19 October 2017 - 12:23 PM

Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users