(06-21-2012, 03:14 PM)Jacob_ Wrote:(06-21-2012, 02:49 PM)Dignity Wrote:(06-21-2012, 02:48 PM)Jacob_ Wrote:(06-21-2012, 02:39 PM)Dignity Wrote: (Mods - I wasn't sure where to post this, so I posted it here)
I haven't released this yet, because it doesn't work.
I just need to add it the the "functions list." Except, I can't find the functions list.
Syntax
Code:str=httpGet("http://something.com")
About
httpGet() is a global function, you can use it from anywhere in your scripts.
It takes one argument: url
Its the URL to a website, such as http://buildism.net/
Remember the http:// at the beginning or Java will cause an error!
httpGet() is also not a member of any object in the game.
On success, it returns a string with the contents of the url.
On failure, Java errors.
DO NOT USE LARGE WEBSITES SUCH AS BUILDISM OR ROBLOX.
(Jacob_ where's the Kahlua environment table?!?!)
I wouldn't suggest adding another global function, just go to the "Root" object and copy one of the existing addFunction() lines. Then it would be game:httpGet().
kay
I did that, except now it thinks I didn't add any arguments when I call it.
Better than not doing anything when I call it though.
WAit - does callFrame.get() start on 0 or 1?
Grrr...
Error:
Code:Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at net.buildism.MainView.updateBackground(MainView.java:409)
at net.buildism.GamePanel$1.componentResized(GamePanel.java:70)
at java.awt.Component.processComponentEvent(Component.java:6330)
at java.awt.Component.processEvent(Component.java:6284)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4860)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Code:
What?Code:addFunction("httpGet", new JavaFunction()
{
public int call(LuaCallFrame callFrame, int nArguments) {
try {
if (nArguments!=1) {
throw new RuntimeException("httpGet() requires a string argument");
}
CloudService cls=new CloudService();
String url=callFrame.get(1).toString();
callFrame.push(cls.getContents(url));
} catch (Exception ex) {
throw new RuntimeException(ex);
}
return 1;
}
});
Okay, that error is gone, but...
Code:httpGet() requires a string argument.
It starts counting at 0, but parameter 0 is the object that the function is being used on. So there would be 2 arguments, not 1.
Thanks!
Testing some scripts now.
Its working now.