#1
Posted 26 January 2013 - 08:46 AM
tried myself and checked the forums without success
please help
thanks in advance
#2
Posted 26 January 2013 - 08:48 AM
os.loadAPI("myApiFile")
myApiFile.functionName()
#3
Posted 26 January 2013 - 08:54 AM
sjele, on 26 January 2013 - 08:48 AM, said:
path/to/my/file.functionName()
That's a syntax error, since that's equivalent to (path/to/my) / ( file.functionName() ), which is an expression, not a statement (in the same way that 1 + 1 is not a valid line of lua code).
#4
Posted 26 January 2013 - 08:56 AM
#5
Posted 26 January 2013 - 08:57 AM
#6
Posted 26 January 2013 - 09:06 AM
Eric, on 26 January 2013 - 08:54 AM, said:
Lyqyd, on 26 January 2013 - 08:57 AM, said:
Eric, have you made sure that you're correct? Because you're not.
What Lyqyd said is true, like this will work:
os.loadAPI("myOS/apis/testAPI")
testAPI.function()
That function will run
#7
Posted 26 January 2013 - 09:10 AM
since i collect my functions as an api in "rom/apis"
it works with just FILENAME.FUNCTION()
yay new possibilities for me
#8
Posted 26 January 2013 - 11:06 AM
remiX, on 26 January 2013 - 09:06 AM, said:
Eric, on 26 January 2013 - 08:54 AM, said:
Lyqyd, on 26 January 2013 - 08:57 AM, said:
Eric, have you made sure that you're correct? Because you're not.
What Lyqyd said is true, like this will work:
os.loadAPI("myOS/apis/testAPI")
testAPI.function()
That function will run
Eric is correct; the code he was talking about would be a syntax error. However, he was correcting code that was incorrect in another way, namely that you do not include the API path when calling functions from it. Including the path like that would probably cause something like "attempt to perform arithmetic __div on nil and nil".
#9
Posted 26 January 2013 - 12:44 PM
Put "3/4" in a file and run it (the CC Lua shell doesn't show this behavior) and you'll see what I mean.
#10
Posted 26 January 2013 - 01:43 PM
Eric, on 26 January 2013 - 12:44 PM, said:
Put "3/4" in a file and run it (the CC Lua shell doesn't show this behavior) and you'll see what I mean.
you can't run
(/dir/file).fn()
you have to do
os.loadAPI("/dir/file")
file.fn()
#11
Posted 26 January 2013 - 01:45 PM
in another file put
os.loadAPI("/dir/file")
file.fn()
and see if you get an error
#12
Posted 26 January 2013 - 02:03 PM
Eric, on 26 January 2013 - 12:44 PM, said:
Put "3/4" in a file and run it (the CC Lua shell doesn't show this behavior) and you'll see what I mean.
Ah, that is true indeed! The CC Lua shell should produce the same behavior; `func = function() 3/4 end` should cause the syntax error.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











