{"id":3722,"date":"2024-05-13T08:59:08","date_gmt":"2024-05-13T08:59:08","guid":{"rendered":"https:\/\/simlab-soft.com\/blog\/?p=3722"},"modified":"2024-05-19T10:57:30","modified_gmt":"2024-05-19T10:57:30","slug":"lua-scripting-in-simlab-training-builder-from-beginner-to-beyond","status":"publish","type":"post","link":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/","title":{"rendered":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond"},"content":{"rendered":"\n<p>At the heart of the&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">Training Builder<\/a>&nbsp;of&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-main.aspx\">SimLab Composer<\/a>&nbsp;is the&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;scripting language. Recognized for being straightforward, effective, and adaptabe, SimLab Soft provides an <a href=\"https:\/\/www.simlab-soft.com\/3d-products\/docs\/help\/scripting\/English\/Lua\/\">API <\/a>that defines the methods and classes for users to create Lua scripts, catering to their unique requirements. This customization ability transforms the tool into a dynamic platform for fostering creativity and innovation.<\/p>\n\n\n\n<p>The integration of&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;scripting in&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">SimLab Training Builder<\/a>&nbsp;presents a unique blend specifically designed for users with advanced skills. It allows for the creation of more complex and feature-rich experiences beyond the default capabilities of&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">SimLab Training Builder<\/a>. This feature enables users to accommodate their training scenarios precisely, adding unique functionalities and details for more immersive and intricate outcomes. It\u2019s an avenue for limitless creativity within&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">SimLab Training Builder<\/a>&nbsp;environment.<\/p>\n\n\n\n<p>The feature of&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;Scripting is exclusively accessible with the&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-buy.aspx\">Ultimate edition<\/a>&nbsp;of&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-main.aspx\">SimLab Composer<\/a> ver. 12.1 or newer, and it\u2019s important to note that this feature is not included in<a href=\"https:\/\/www.simlab-soft.com\/3d-products\/vr-studio.aspx\"> SimLab VR Studio<\/a>.<\/p>\n\n\n\n<p>In order to execute your&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;script, you simply need the \u2018<strong>Run Script<\/strong>\u2019 node graph, show in Figure 1-3. This can be created by simply right-clicking within the view of&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">SimLab Training Builder<\/a>&nbsp;and choosing \u2018<strong>Run Script<\/strong>\u2019. This particular node offers the capability to input or compose&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;script. Of course, you have to link the \u2018<strong>Run Script<\/strong>\u2019 node into your graph execution flow, enabling your script to function smoothly within the overall process.<\/p>\n\n\n\n<p>Bear in mind that the&nbsp;<code>print(\"Hello World!\")<\/code>&nbsp;function is a key tool in script writing and testing. It helps track data flow and variable states, aiding in identifying issues. It acts like a simple logging system, providing insights into the script\u2019s operation. In short, it\u2019s essential for debugging and understanding your&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;code\u2019s behavior while building up your experience.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<p>Before proceeding further in reading, let&#8217;s keep in mind the following key syntax rules in Lua programming:<\/p>\n\n\n\n<ul><li>Case sensitivity:&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;is a case-sensitive language. This means that&nbsp;<code>Variable<\/code>,&nbsp;<code>variable<\/code>, and&nbsp;<code>VARIABLE<\/code>&nbsp;are all considered different identifiers in&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>.<\/li><li>Termination: In&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>, it\u2019s not necessary to use a&nbsp;<code>;<\/code>&nbsp;at the end of each statement.<\/li><li>Commenting: To comment out a single line, place&nbsp;<code>--<\/code>&nbsp;at the start of the line. For commenting out multiple lines, start with&nbsp;<code>--[[<\/code>&nbsp;the first line and end with&nbsp;<strong><code>]]<\/code><\/strong>&nbsp;on the final line.<\/li><li>Array Indexing: In&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>, the convention is to start arrays with an index of 1. However, you can technically start an array at index 0, 1, or any other value. But if you stick to the convention of starting arrays with index 1, you will be able to use Lua\u2019s libraries directly. So, while it\u2019s possible to start an array at index 0, it\u2019s generally more convenient to start at index 1.<\/li><\/ul>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><em><strong><span class=\"has-inline-color has-vivid-red-color\">Caution:<\/span><\/strong> Please be aware that improper use of&nbsp;<a href=\"https:\/\/www.lua.org\/\">Lua<\/a>&nbsp;scripting can lead to unexpected crashes in&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-showroom.aspx\">SimLab VR Viewer<\/a>. Always test your scripts thoroughly before running them in production. If you encounter consistent crashes, consider reaching out to the&nbsp;<a href=\"https:\/\/www.simlab-soft.com\/simlab-discord-community.aspx\">SimLab community<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/simlabsoftware.zohodesk.com\/portal\/en\/signin\">support<\/a>&nbsp;for assistance. Your understanding and caution are appreciated. Happy scripting!<\/em><\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 id=\"Beginner-Tutorial\">[1] Beginner: Print Hello World!<\/h2>\n\n\n\n<p>Just starting out? Don\u2019t fret, you\u2019ll advance beyond this stage swiftly. Let&#8217;s execute the simplest script ever by print some text on the screen in a step-by-step manner:<\/p>\n\n\n\n<ol><li><a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-main.aspx\">Download<\/a> SimLab Composer 12.1 or newer.<\/li><li><a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-faq.aspx#install-uninstall-simlab-composer\">Install<\/a> SimLab Composer.<\/li><li><a href=\"https:\/\/www.simlab-soft.com\/simlab-composer-license-steps.aspx\">Enter<\/a> an Ultimate edition key, <a href=\"https:\/\/www.simlab-soft.com\/simlab-composer-license-steps.aspx\">request<\/a> a fully featured 21-day free trial, or <a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-buy.aspx\">buy<\/a> a license.<\/li><li>Run SimLab Composer.<\/li><li>As Virtual Reality is the default active workbench, left-click over &#8220;Training Builder&#8221;, located on the ribbon of the application as shown in Figure 1-1, to open SimLab Training Builder.<\/li><li>Right-click anywhere within the view of SimLab Training Builder.<\/li><li>Search for &#8220;<strong>Run Script<\/strong>&#8221; located under the &#8220;<strong>Responses<\/strong>&#8221; category as shown in Figure 1-2, or type &#8220;<strong>run script<\/strong>&#8221; in the filter text field then hit the Enter key on your keyboard <em>(Note: this node graph is only accessible from the context menu)<\/em>.<\/li><li>Left-click over &#8220;<strong>Run Script<\/strong>&#8221; to create the node graph in the view as shown in Figure 1-3.<\/li><li>Left-click over the &#8220;<strong>Scene Start<\/strong>&#8221; located within the &#8220;<strong>Events<\/strong>&#8221; category to create another node graph in the view.<\/li><li>Connect the &#8220;<strong>Execute<\/strong>&#8221; output port of the &#8220;<strong>Scene Start<\/strong>&#8221; node graph to the &#8220;<strong>Execute<\/strong>&#8221; input port of the &#8220;<strong>Run Script<\/strong>&#8221; node graph as shown in Figure 1-4.<\/li><li>Left-click the edit button located next to the &#8220;<strong>Script<\/strong>&#8221; input port of the &#8220;<strong>Run Script<\/strong>&#8221; node graph to start typing a Lua script.<\/li><li>The Lua Script dialog appears as shown in Figure 1-5, type <code>print(\"Hello World!\")<\/code>, and left-click the OK button.<\/li><li>Go to the &#8220;<strong>VR Viewer<\/strong>&#8221; menu on the application&#8217;s ribbon. and left-click over it.<\/li><li>As the &#8220;<strong>VR Viewer<\/strong>&#8221; menu is revealed, left-click over the &#8220;<strong>Show in Viewer<\/strong>&#8221; option shown in Figure 1-6.<\/li><li>The &#8220;<strong>Viewer Modes<\/strong>&#8221; dialog box appears which is demonstrated in Figure 1-7, left-click over the &#8220;<strong>Desktop<\/strong>&#8221; button option to start importing the Viewer Start Position.<\/li><li>Left-click over the tick button, shown in Figure 1-8, to finalize the scene for export.<\/li><li>SimLab VR Viewer will be opened with the message &#8220;Hello World!&#8221; printed in black on the top-left corner of the viewer as shown in Figure 1-9.<\/li><li>Congratulation! You did it and successfully ran your first Lua script in SimLab Training Builder.<\/li><\/ol>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"97\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1-1024x97.jpg\" alt=\"\" class=\"wp-image-3786\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1-1024x97.jpg 1024w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1-300x28.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1-768x73.jpg 768w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1-950x90.jpg 950w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/1.jpg 1169w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><strong>Figure 1-1:<\/strong> SimLab Training Builder on the ribbon of SimLab Composer<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"290\" height=\"244\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2.jpg\" alt=\"\" class=\"wp-image-3789\" \/><figcaption><strong>Figure 1-2:<\/strong> The context menu of SimLab Training Builder showing the &#8220;Run Script&#8221; response.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"361\" height=\"254\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3.jpg\" alt=\"\" class=\"wp-image-3792\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3.jpg 361w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-300x211.jpg 300w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><figcaption><strong>Figure 1-3:<\/strong> The &#8220;Run Script&#8221; node graph.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"615\" height=\"265\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/4.jpg\" alt=\"\" class=\"wp-image-3796\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/4.jpg 615w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/4-300x129.jpg 300w\" sizes=\"(max-width: 615px) 100vw, 615px\" \/><figcaption><strong>Figure 1-4:<\/strong> The &#8220;Scene Start&#8221; and &#8220;Run Script&#8221; nodes appear as linked to each other.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"581\" height=\"190\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/5.jpg\" alt=\"\" class=\"wp-image-3799\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/5.jpg 581w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/5-300x98.jpg 300w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><figcaption><strong>Figure 1-5: <\/strong>The Lua Script dialog box shows a written line of Lua script.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"460\" height=\"527\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/6.jpg\" alt=\"\" class=\"wp-image-3806\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/6.jpg 460w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/6-262x300.jpg 262w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/6-300x344.jpg 300w\" sizes=\"(max-width: 460px) 100vw, 460px\" \/><figcaption><strong>Figure 1-6:<\/strong> The &#8220;Show in Viewer&#8221; option as being located under &#8220;Viewer Viewer&#8221; menu.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"757\" height=\"337\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/7.jpg\" alt=\"\" class=\"wp-image-3810\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/7.jpg 757w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/7-300x134.jpg 300w\" sizes=\"(max-width: 757px) 100vw, 757px\" \/><figcaption><strong>Figure 1-7: <\/strong>The Viewer Modes dialog box.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"438\" height=\"782\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/8.jpg\" alt=\"\" class=\"wp-image-3811\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/8.jpg 438w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/8-168x300.jpg 168w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/8-300x536.jpg 300w\" sizes=\"(max-width: 438px) 100vw, 438px\" \/><figcaption><strong>Figure 1-8:<\/strong> Demonstrating the tick option to be clicked to finalize the scene for export. <\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"859\" height=\"503\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/9.jpg\" alt=\"\" class=\"wp-image-3813\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/9.jpg 859w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/9-300x176.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/9-768x450.jpg 768w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><figcaption><strong>Figure 1-9:<\/strong> SimLab VR Viewer shows the &#8220;Hello World!&#8221; message.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 id=\"Intermediate-Tutorial\">[2] Intermediate: OpenWeatherMap API<\/h2>\n\n\n\n<p>You can use the <a href=\"https:\/\/openweathermap.org\/\">OpenWeatherMap<\/a> API for free. They offer a freemium plan that allows you to make limited API calls per day for free.<\/p>\n\n\n\n<p>To start using their<a href=\"https:\/\/openweathermap.org\/api\"> APIs<\/a>, you need to sign up on their <a href=\"https:\/\/openweathermap.org\/\">website<\/a> and verify your email, Figure 2-1 shows the account confirmation email. Once you sign up using your email, an API key (APPID) will be sent to you in a confirmation email as shown in Figure 2.2. This API key is all you need to call any of their <a href=\"https:\/\/openweathermap.org\/api\">weather APIs<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-1.jpg\" alt=\"\" class=\"wp-image-3842\" width=\"437\" height=\"527\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-1.jpg 582w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-1-249x300.jpg 249w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-1-300x362.jpg 300w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><figcaption><strong>Figure 2-1<\/strong>: OpenWeatherMap account confirmation.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-2.jpg\" alt=\"\" class=\"wp-image-3846\" width=\"442\" height=\"565\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-2.jpg 589w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-2-235x300.jpg 235w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-2-300x384.jpg 300w\" sizes=\"(max-width: 442px) 100vw, 442px\" \/><figcaption><strong>Figure 2-2<\/strong>: OpenWeatherMap API instruction containing the API key.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The free plan includes access to current weather data for any location, which is collected and processed from different sources such as global and local weather models, satellites, radars, and a vast network of weather stations. The data is available in JSON, XML, and HTML formats.<\/p>\n\n\n\n<p>Here&#8217;s an example of a JSON API call:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"coord\": {\n        \"lon\": -0.1257,\n        \"lat\": 51.5085\n    },\n    \"weather\": &#091;\n        {\n            \"id\": 800,\n            \"main\": \"Clear\",\n            \"description\": \"clear sky\",\n            \"icon\": \"01d\"\n        }\n    ],\n    \"base\": \"stations\",\n    \"main\": {\n        \"temp\": 290.03,\n        \"feels_like\": 289.39,\n        \"temp_min\": 288.01,\n        \"temp_max\": 291.86,\n        \"pressure\": 1021,\n        \"humidity\": 62\n    },\n    \"visibility\": 10000,\n    \"wind\": {\n        \"speed\": 5.14,\n        \"deg\": 70\n    },\n    \"clouds\": {\n        \"all\": 2\n    },\n    \"dt\": 1715075447,\n    \"sys\": {\n        \"type\": 2,\n        \"id\": 268730,\n        \"country\": \"GB\",\n        \"sunrise\": 1715055654,\n        \"sunset\": 1715110389\n    },\n    \"timezone\": 3600,\n    \"id\": 2643743,\n    \"name\": \"London\",\n    \"cod\": 200\n}<\/code><\/pre>\n\n\n\n<p>And here\u2019s a basic Lua example of how you might use the <a href=\"https:\/\/openweathermap.org\/\">OpenWeatherMap<\/a> API to get the current weather for a specific city. Lua doesn\u2019t have built-in support for HTTP requests, so you\u2019ll need to use the <a href=\"https:\/\/www.simlab-soft.com\/3d-products\/docs\/help\/scripting\/English\/Lua\/\">SimLab library<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function on_response()\n  --print(\"Response is received\")\n  local iterate = http_request:GetResponse()\n\n  local weather_array = iterate:GetArrayField(\"weather\")\n  local weather_first_index_object = weather_array&#091;1]:AsObject()\n  local json_string = weather_first_index_object:ToString()\n  print(json_string)\n\n  local weather_description = weather_first_index_object:GetStringField(\"description\")\n  local vr_var = SimLabUtils:GetVariableByName(\"weather_description\")\n  vr_var:SetStringValue(weather_description)\nend\n\nlocal your_api_key = \"2fd8e44a56f0300246bacf9ec237b6da\"\nlocal city = \"Amman\"\nlocal base_url = \"http:\/\/api.openweathermap.org\/data\/2.5\/weather\"\n\n-- Construct the API endpoint\nlocal endpoint = base_url .. \"?q=\" .. city .. \"&amp;appid=\" .. your_api_key\n\nhttp_request = SimLabUtils:NewHttpRequest()\nhttp_request:SetVerb(\"GET\")\nhttp_request:SetEndpoint(endpoint)\nhttp_request.OnResponse:Add(http_request, on_response)\nhttp_request:ProcessRequest()<\/code><\/pre>\n\n\n\n<p>In this example, replace&nbsp;<code>'your_api_key'<\/code>&nbsp;with your actual API key. The&nbsp;<code>city<\/code>&nbsp;variable is the city you want to get the weather for. The&nbsp;<code>base_url<\/code>&nbsp;is the base URL for the OpenWeatherMap API. The&nbsp;<code>endpoint<\/code>&nbsp;is the specific URL you will send a GET request to in order to retrieve the weather data.<\/p>\n\n\n\n<p>Please note that the temperature is returned in Kelvin by default. If you prefer Celsius or Fahrenheit, you can add&nbsp;<code>&amp;units=metric<\/code>&nbsp;or&nbsp;<code>&amp;units=imperial<\/code>&nbsp;to the endpoint respectively.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Enough talking! Now, let&#8217;s run the example and see the retrieved data reflected in a VR experience:<\/p>\n\n\n\n<ol><li>Open <a href=\"https:\/\/www.simlab-soft.com\/3d-products\/simlab-composer-main.aspx\">SimLab Composer<\/a>.<\/li><li>Create a <a href=\"https:\/\/simlab-soft.com\/blog\/introduction-to-vr-variables\/#VariableWriter\">Variable Writer<\/a> and place it in the scene.<\/li><li>Create a <a href=\"https:\/\/help.simlab-soft.com\/books\/simlab-composer-help\/page\/training-builder-menu#bkmrk-create%2Fedit-variable\">VR Variable<\/a> of type string and rename it &#8220;<strong>weather_description<\/strong>&#8220;.<\/li><li>Bind the created <a href=\"https:\/\/simlab-soft.com\/blog\/introduction-to-vr-variables\/#VariableWriter\">Variable Writer<\/a> with the <a href=\"https:\/\/help.simlab-soft.com\/books\/simlab-composer-help\/page\/training-builder-menu#bkmrk-create%2Fedit-variable\">VR Variable<\/a> as shown in Figure 2-3.<\/li><li>Open <a href=\"https:\/\/help.simlab-soft.com\/books\/simlab-composer-help\/page\/training-builder-menu#bkmrk-create\">SimLab Training Builder<\/a>, create &#8220;<strong>Scene Start<\/strong>&#8221; and &#8220;<strong>Run Script<\/strong>&#8221; nodes, and connect them via the &#8220;<strong>Execute<\/strong>&#8221; ports as shown in Figure 2-4.<\/li><li>Enter the Lua script of the example in the &#8220;<strong>Edit Lua Script<\/strong>&#8221; dialog box of the &#8220;<strong>Run Script<\/strong>&#8221; node graph as shown in Figure 2-5.<\/li><li>Run the experience in <a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-showroom.aspx\">SimLab VR Viewer<\/a>.<\/li><li>Congratulations! You should now see the weather description in the <a href=\"https:\/\/simlab-soft.com\/blog\/introduction-to-vr-variables\/#VariableWriter\">Variable Writer<\/a> as demonstrated in Figure 2-6.<\/li><\/ol>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"540\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5-1024x540.jpg\" alt=\"\" class=\"wp-image-3871\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5-1024x540.jpg 1024w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5-300x158.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5-768x405.jpg 768w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5-950x501.jpg 950w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-5.jpg 1285w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><strong>Figure 2-3:<\/strong> The properties of the created &#8220;VR Variable Writer&#8221; with the new created VR variable &#8220;weather_description&#8221;.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"621\" height=\"214\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-6.jpg\" alt=\"\" class=\"wp-image-3875\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-6.jpg 621w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-6-300x103.jpg 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><figcaption><strong>Figure 2-4:<\/strong> The &#8220;Scene Start&#8221; and &#8220;Run Script&#8221; nodes are connected to each other via the &#8220;Execute&#8221; ports. <\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"575\" height=\"624\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-4.jpg\" alt=\"\" class=\"wp-image-3869\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-4.jpg 575w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-4-276x300.jpg 276w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-4-300x326.jpg 300w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><figcaption> <strong>Figure 2-5:<\/strong> The Lua script is shown in the Edit Lua Script dialog box of the &#8220;Run Script&#8221; node graph.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"575\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3-1024x575.jpg\" alt=\"\" class=\"wp-image-3867\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3-1024x575.jpg 1024w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3-300x168.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3-768x431.jpg 768w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3-950x533.jpg 950w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/2-3.jpg 1281w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><strong>Figure 2-6:<\/strong> Running the Lua Script shows the JSON data of the &#8220;weather&#8221; object printed on the upper-left corner in SimLab VR Viewer and the created VR Variable Writer displays the weather description in the scene.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 id=\"Advanced-Tutorial\">[3] Advanced: A Flask Server Application<\/h2>\n\n\n\n<p>Let&#8217;s create a simple Flask server application. Here are the steps:<\/p>\n\n\n\n<p><strong>Step 1: Install Flask<\/strong>.&nbsp;First, you need to install Flask. You can do this using pip, which is a package manager for Python. Open your terminal and type the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install flask<\/code><\/pre>\n\n\n\n<p><strong>Step 2: Create a new Python file<\/strong>.&nbsp;Next, create a new Python file for your application. You can name it anything you like, but for this example, let\u2019s call it&nbsp;<code>app.py<\/code>.<\/p>\n\n\n\n<p><strong>Step 3: Import Flask<\/strong>.&nbsp;At the top of your&nbsp;<code>app.py<\/code>&nbsp;file, you need to import the Flask module:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask, jsonify<\/code><\/pre>\n\n\n\n<p><strong>Step 4: Create an instance of the Flask class<\/strong>.&nbsp;Next, create an instance of the Flask class. This instance will be our WSGI application.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app = Flask(__name__)<\/code><\/pre>\n\n\n\n<p><strong>Step 5: Define a route<\/strong>.&nbsp;A route is what Flask uses to determine what should be returned when a specific URL is accessed. In this case, we want to return a user\u2019s occupation when their user ID is accessed. Let\u2019s create a dictionary to simulate a database of users and their occupations:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>users = {\n    '121410': 'Engineer',\n    '121411': 'Doctor',\n    '121412': 'Artist',\n    # Add more users as needed\n}<\/code><\/pre>\n\n\n\n<p>Then, define a route that will return a user\u2019s occupation based on their user ID:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@app.route('\/user\/&lt;id&gt;', methods=&#091;'GET'])\ndef get_user(id):\n    if id in users:\n        return jsonify({id: users&#091;id]})\n    else:\n        return jsonify({\"error\": \"User not found\"}), 404<\/code><\/pre>\n\n\n\n<p><strong>Step 6: Run the application<\/strong>.&nbsp;Finally, tell Flask to run your application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if __name__ == '__main__':\n    app.run(debug=True)<\/code><\/pre>\n\n\n\n<p>Your complete&nbsp;<code>app.py<\/code>&nbsp;file should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask, jsonify\n\napp = Flask(__name__)\n\nusers = {\n    '121410': 'Engineer',\n    '121411': 'Doctor',\n    '121412': 'Artist',\n    # Add more users as needed\n}\n\n@app.route('\/user\/&lt;id&gt;', methods=&#091;'GET'])\ndef get_user(id):\n    if id in users:\n        return jsonify({id: users&#091;id]})\n    else:\n        return jsonify({\"error\": \"User not found\"}), 404\n\nif __name__ == '__main__':\n    app.run(debug=True)<\/code><\/pre>\n\n\n\n<p>To run your application, navigate to the directory containing your&nbsp;<code>app.py<\/code>&nbsp;file in the terminal and type&nbsp;<code>python app.py<\/code>. Your Flask server should start, and you can access it at&nbsp;<code>http:\/\/localhost:5000\/user\/&lt;id&gt;<\/code>, replacing&nbsp;<code>&lt;id&gt;<\/code>&nbsp;with the ID of the user whose occupation you want to retrieve. If the user exists, their occupation will be returned in JSON format. If the user does not exist, you will receive a 404 error and a JSON response of&nbsp;<code>{\"error\": \"User not found\"}<\/code>.<\/p>\n\n\n\n<p>Remember to replace the&nbsp;<code>users<\/code>&nbsp;dictionary with your actual database or data source in a real application. This is just a simple example to get you started.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Now, let&#8217;s retrieve the occupation of some user ID* by using SimLab Training Builder:<\/p>\n\n\n\n<ol><li>Make sure that the server of the Flask application is active and running as show in Figure 3-1.<\/li><li>Build the graph shown in Figure 3-2 in <a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-training-builder.aspx\">SimLab Training Builder<\/a> by creating and connecting the necessary nodes.<\/li><li>Enter the <a href=\"https:\/\/www.lua.org\/\">Lua<\/a> script presented in Figure 3-3 in the &#8220;<strong>Run Script<\/strong>&#8221; node graph. Also, you can copy it from below.<\/li><li>Run the experience in <a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-showroom.aspx\">SimLab VR Viewer<\/a>. Figures 3-4 and 3-5 show the occupation of the requested user ID appearing as printed at the top-level corner of <a href=\"https:\/\/www.simlab-soft.com\/technologies\/simlab-showroom.aspx\">SimLab VR Viewer<\/a>. <em>(Note: Please ensure that you are signed into the SimLab VR Viewer to guarantee the user ID is properly assigned and does not remain at the default value of -1.)<\/em><\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>function on_response()\n  --print(\"Response is received\")\n  local iterate = http_request:GetResponse()\n  local occupation = iterate:GetStringField(id)\n  print(occupation)\nend\n\nlocal vr_var = SimLabUtils:GetVariableByName(\"UserId\")\nid = vr_var:ValueToString()\n--id = \"121410\"\n\nlocal base_url = \"http:\/\/localhost:5000\/user\/\"\nlocal full_url = base_url .. id\n\nhttp_request = SimLabUtils:NewHttpRequest()\nhttp_request:SetVerb(\"GET\")\nhttp_request:SetEndpoint(full_url)\nhttp_request.OnResponse:Add(http_request, on_response)\nhttp_request:ProcessRequest()<\/code><\/pre>\n\n\n\n<p>* Every SimLab user has a unique global identifier.<\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"975\" height=\"266\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-3.jpg\" alt=\"\" class=\"wp-image-3952\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-3.jpg 975w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-3-300x82.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-3-768x210.jpg 768w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-3-950x259.jpg 950w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><figcaption><strong>Figure 3-1:<\/strong> The running Flask application server shows some received requrest.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"787\" height=\"407\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-1.jpg\" alt=\"\" class=\"wp-image-3950\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-1.jpg 787w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-1-300x156.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-1-768x397.jpg 768w\" sizes=\"(max-width: 787px) 100vw, 787px\" \/><figcaption><strong>Figure 3-2:<\/strong> The needed nodes graph created in SimLab Dynamic Builder responsible to retrieve a user occupation from the dictionary.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"508\" height=\"484\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-2.jpg\" alt=\"\" class=\"wp-image-3951\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-2.jpg 508w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-2-300x286.jpg 300w\" sizes=\"(max-width: 508px) 100vw, 508px\" \/><figcaption><strong>Figure 3-3:<\/strong> Lua Script to be entered in the &#8220;Run Script&#8221; node graph. <\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"171\" height=\"84\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-5-1.jpg\" alt=\"\" class=\"wp-image-3956\" \/><figcaption><strong>Figure 3-4:<\/strong> Printed on the screen the value of the occupation of some user ID.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"725\" src=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4-1024x725.jpg\" alt=\"\" class=\"wp-image-3954\" srcset=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4-1024x725.jpg 1024w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4-300x212.jpg 300w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4-768x544.jpg 768w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4-950x672.jpg 950w, https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/3-4.jpg 1475w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><strong>Figure 3-5:<\/strong> A screenshot showing the system diagram, the Lua script, the output in SimLab VR Viewer, and application terminal.<\/figcaption><\/figure>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3>Links to Relative External Resources:<\/h3>\n\n\n\n<ul><li><a href=\"https:\/\/devdocs.io\/lua~5.4\/\">The official Lua 5.4 Reference Manual<\/a><\/li><li><a href=\"https:\/\/devdocs.io\/lua~5.4\/index#pdf-math.abs\">Lua&#8217;s Mathematical Functions and Expressions<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>At the heart of the&nbsp;Training Builder&nbsp;of&nbsp;SimLab Composer&nbsp;is the&nbsp;Lua&nbsp;scripting language. Recognized for being straightforward, effective, and adaptabe, SimLab Soft provides an API that defines the methods and classes for users to create Lua scripts, catering to their unique requirements. This customization ability transforms the tool into a dynamic platform for fostering creativity and innovation. The integration [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":4006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[68,57],"tags":[168,162,166,165,163,167,64,11,16,170,164,51,169],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog\" \/>\n<meta property=\"og:description\" content=\"At the heart of the&nbsp;Training Builder&nbsp;of&nbsp;SimLab Composer&nbsp;is the&nbsp;Lua&nbsp;scripting language. Recognized for being straightforward, effective, and adaptabe, SimLab Soft provides an API that defines the methods and classes for users to create Lua scripts, catering to their unique requirements. This customization ability transforms the tool into a dynamic platform for fostering creativity and innovation. The integration [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\" \/>\n<meta property=\"og:site_name\" content=\"SimLab Soft Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/SimLab-Soft\/154245504646447\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-13T08:59:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-19T10:57:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/featured_image_4.png\" \/>\n\t<meta property=\"og:image:width\" content=\"950\" \/>\n\t<meta property=\"og:image:height\" content=\"673\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jamal Said\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SimLabSoft\" \/>\n<meta name=\"twitter:site\" content=\"@SimLabSoft\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jamal Said\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#organization\",\"name\":\"SimLab Soft\",\"url\":\"https:\/\/simlab-soft.com\/blog\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/simlabsoft\",\"https:\/\/www.linkedin.com\/company\/simlab-soft\",\"https:\/\/www.youtube.com\/user\/SimLabSoft\",\"https:\/\/www.facebook.com\/pages\/SimLab-Soft\/154245504646447\",\"https:\/\/twitter.com\/SimLabSoft\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/vrforcad.com\/wp-content\/uploads\/2019\/09\/Artboard-2.png\",\"contentUrl\":\"https:\/\/vrforcad.com\/wp-content\/uploads\/2019\/09\/Artboard-2.png\",\"width\":107,\"height\":110,\"caption\":\"SimLab Soft\"},\"image\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#website\",\"url\":\"https:\/\/simlab-soft.com\/blog\/\",\"name\":\"3D CAD VR\",\"description\":\"Lets do more with 3D Models\",\"publisher\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/simlab-soft.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\",\"url\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\",\"name\":\"Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog\",\"isPartOf\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/#website\"},\"datePublished\":\"2024-05-13T08:59:08+00:00\",\"dateModified\":\"2024-05-19T10:57:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/simlab-soft.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lua Scripting in SimLab Training Builder: From Beginner to Beyond\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\"},\"author\":{\"name\":\"Jamal Said\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/7413e5a34f1e361f90115fc85e594421\"},\"headline\":\"Lua Scripting in SimLab Training Builder: From Beginner to Beyond\",\"datePublished\":\"2024-05-13T08:59:08+00:00\",\"dateModified\":\"2024-05-19T10:57:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/\"},\"wordCount\":2081,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/simlab-soft.com\/blog\/#organization\"},\"keywords\":[\"Dynamic Builder\",\"Lua\",\"Lua Programming\",\"Lua Scripting\",\"programming\",\"Script Node\",\"Scripting\",\"SimLAb\",\"Simlab Composer\",\"SimLab Composer Ultimate Edition\",\"SimLab Training Builder\",\"Training Builder\",\"Ultimate Edition\"],\"articleSection\":[\"Scripting\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/7413e5a34f1e361f90115fc85e594421\",\"name\":\"Jamal Said\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2019\/11\/T65R3SRM3-U65U91QEN-da3ebefa6c73-512-150x150.png\",\"contentUrl\":\"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2019\/11\/T65R3SRM3-U65U91QEN-da3ebefa6c73-512-150x150.png\",\"caption\":\"Jamal Said\"},\"url\":\"https:\/\/simlab-soft.com\/blog\/author\/jamal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/","og_locale":"en_US","og_type":"article","og_title":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog","og_description":"At the heart of the&nbsp;Training Builder&nbsp;of&nbsp;SimLab Composer&nbsp;is the&nbsp;Lua&nbsp;scripting language. Recognized for being straightforward, effective, and adaptabe, SimLab Soft provides an API that defines the methods and classes for users to create Lua scripts, catering to their unique requirements. This customization ability transforms the tool into a dynamic platform for fostering creativity and innovation. The integration [&hellip;]","og_url":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/","og_site_name":"SimLab Soft Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/SimLab-Soft\/154245504646447","article_published_time":"2024-05-13T08:59:08+00:00","article_modified_time":"2024-05-19T10:57:30+00:00","og_image":[{"width":950,"height":673,"url":"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2024\/05\/featured_image_4.png","type":"image\/png"}],"author":"Jamal Said","twitter_card":"summary_large_image","twitter_creator":"@SimLabSoft","twitter_site":"@SimLabSoft","twitter_misc":{"Written by":"Jamal Said","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/simlab-soft.com\/blog\/#organization","name":"SimLab Soft","url":"https:\/\/simlab-soft.com\/blog\/","sameAs":["https:\/\/www.instagram.com\/simlabsoft","https:\/\/www.linkedin.com\/company\/simlab-soft","https:\/\/www.youtube.com\/user\/SimLabSoft","https:\/\/www.facebook.com\/pages\/SimLab-Soft\/154245504646447","https:\/\/twitter.com\/SimLabSoft"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simlab-soft.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/vrforcad.com\/wp-content\/uploads\/2019\/09\/Artboard-2.png","contentUrl":"https:\/\/vrforcad.com\/wp-content\/uploads\/2019\/09\/Artboard-2.png","width":107,"height":110,"caption":"SimLab Soft"},"image":{"@id":"https:\/\/simlab-soft.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/simlab-soft.com\/blog\/#website","url":"https:\/\/simlab-soft.com\/blog\/","name":"3D CAD VR","description":"Lets do more with 3D Models","publisher":{"@id":"https:\/\/simlab-soft.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simlab-soft.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/","url":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/","name":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond &bull; SimLab Soft Blog","isPartOf":{"@id":"https:\/\/simlab-soft.com\/blog\/#website"},"datePublished":"2024-05-13T08:59:08+00:00","dateModified":"2024-05-19T10:57:30+00:00","breadcrumb":{"@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simlab-soft.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond"}]},{"@type":"Article","@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#article","isPartOf":{"@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/"},"author":{"name":"Jamal Said","@id":"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/7413e5a34f1e361f90115fc85e594421"},"headline":"Lua Scripting in SimLab Training Builder: From Beginner to Beyond","datePublished":"2024-05-13T08:59:08+00:00","dateModified":"2024-05-19T10:57:30+00:00","mainEntityOfPage":{"@id":"https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/"},"wordCount":2081,"commentCount":0,"publisher":{"@id":"https:\/\/simlab-soft.com\/blog\/#organization"},"keywords":["Dynamic Builder","Lua","Lua Programming","Lua Scripting","programming","Script Node","Scripting","SimLAb","Simlab Composer","SimLab Composer Ultimate Edition","SimLab Training Builder","Training Builder","Ultimate Edition"],"articleSection":["Scripting","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/simlab-soft.com\/blog\/lua-scripting-in-simlab-training-builder-from-beginner-to-beyond\/#respond"]}]},{"@type":"Person","@id":"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/7413e5a34f1e361f90115fc85e594421","name":"Jamal Said","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simlab-soft.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2019\/11\/T65R3SRM3-U65U91QEN-da3ebefa6c73-512-150x150.png","contentUrl":"https:\/\/simlab-soft.com\/blog\/wp-content\/uploads\/2019\/11\/T65R3SRM3-U65U91QEN-da3ebefa6c73-512-150x150.png","caption":"Jamal Said"},"url":"https:\/\/simlab-soft.com\/blog\/author\/jamal\/"}]}},"_links":{"self":[{"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/posts\/3722"}],"collection":[{"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/comments?post=3722"}],"version-history":[{"count":146,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/posts\/3722\/revisions"}],"predecessor-version":[{"id":4013,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/posts\/3722\/revisions\/4013"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/media\/4006"}],"wp:attachment":[{"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/media?parent=3722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/categories?post=3722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simlab-soft.com\/blog\/wp-json\/wp\/v2\/tags?post=3722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}