In Objective-C I'm able to grab a JavaScript context and call functions on that context.
EX:
Javascript:
<html>
<head>
<title>Demo</title>
<script type="text/javascript">
function test(value) {
consoleLog("My debug message");
return value;
}
</script>
</head>
<body>
</body>
</html>
Objective-C:
self.jsContext = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
JSValue *value = [self.jsContext evaluateScript:@"test(4)"];
I can call and get the value from that javascript function in Objective-C. I also setup a consoleLog method that can be called in JavaScript to print out messages in Xcode's output log. I'm not JavaScript expert. My question is how do I properly get the BYOND game's context and what are some examples of calling functions on it? And how can I add custom functions to it where I can call them. My end goal is to create a BYOND client app that loads the game into a full screen web view that can call JavaScript methods to control the game. I want to get it to the point people can use a on-screen gamepad and/or native iOS functionality in their BYOND game through this app.
Any help would be appreciated, thanks!
For instance, say you want to send a text message to the default output control.
Or for a more complex example, say you wanted to use winget to grab the current state of a control.
You can call winget() or winset() with an object literal if you want to get more properties at once. For instance:
There are more complex things you can do obviously, but those are some of the basics.