{"id":709,"date":"2014-03-28T16:41:10","date_gmt":"2014-03-28T03:41:10","guid":{"rendered":"http:\/\/www.davidbrebner.com\/?p=709"},"modified":"2014-08-14T14:38:03","modified_gmt":"2014-08-14T02:38:03","slug":"scripting-support","status":"publish","type":"post","link":"https:\/\/www.davidbrebner.com\/?p=709","title":{"rendered":"Scripting support"},"content":{"rendered":"<p>Exciting news for the Umajin engine.  We can now include run time scripting with support for many languages.  Here is an example using Lua.  <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/factorial.png\" alt=\"factorial\" width=\"338\" height=\"171\" class=\"alignnone size-full wp-image-713\" srcset=\"https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/factorial.png 338w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/factorial-150x75.png 150w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/factorial-300x151.png 300w\" sizes=\"(max-width: 338px) 100vw, 338px\" \/><\/p>\n<p>Here is a factorial function in Lua which is added to the MyScript object using dostring.  Then it can be called from Umajin by name and parameters passes in. <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/bee2.png\" alt=\"bee2\" width=\"460\" height=\"351\" class=\"alignnone size-full wp-image-847\" srcset=\"https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/bee2.png 460w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/bee2-150x114.png 150w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2014\/03\/bee2-300x228.png 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><\/p>\n<p>This example shows bidirectional calling.  First we create a script object and add our Lua code.  This has a move_bee function which will in turn call a method on a Umajin object called animate which takes an object an x, y position.<\/p>\n<p>Then we create a bee object from the image class.  This object has an animate method which takes an x, y position as parameters.<\/p>\n<p>Finally when the mouse_down event is raised we execute the move_bee function in the Lua code, passing the bee object and x,y parameters.  The Lua code executes calling the Umajin animate method on the bee object triggering the animation!!   <\/p>\n<p><iframe width=\"640\" height=\"480\" src=\"\/\/www.youtube.com\/embed\/aKRfArWo2qU\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exciting news for the Umajin engine. We can now include run time scripting with support for many languages. Here is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-709","post","type-post","status-publish","format-image","hentry","category-umaijn","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=709"}],"version-history":[{"count":5,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/709\/revisions"}],"predecessor-version":[{"id":848,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/709\/revisions\/848"}],"wp:attachment":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}