<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Luascript Service in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513601#M10253</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;First defined the service as below:&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;serviceDefinitions.RemoteService (&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="a", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="b", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="c", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; output { baseType="NOTHING" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; description { "Values" }&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;)&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P&gt;services.RemoteService = function(me, headers, query, data)&lt;/P&gt;&lt;P&gt;if not a then&lt;/P&gt;&lt;P&gt;return 400, "You must provide the 'a' parameter"&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;return 200, me.setProperty("d",0,0,0)&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have proceeded like this but getting in error&amp;nbsp; in this piece of code itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Feb 2017 17:53:03 GMT</pubDate>
    <dc:creator>adityaku</dc:creator>
    <dc:date>2017-02-16T17:53:03Z</dc:date>
    <item>
      <title>Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513599#M10251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to write a service in Lua script, for the below conditions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Accepts three inputs – a (integer), b(minute, integer), and c (integer, 1-3)&lt;/P&gt;&lt;UL style="list-style-type: circle;"&gt;&lt;LI&gt;Sets d property to zero, for a greater than 0.&amp;nbsp; Hold it at zero if a &amp;gt; 0, tasker should not increment or change d property, if a &amp;gt; 0.&lt;/LI&gt;&lt;LI&gt;Places text message in LSR log window as below:&lt;UL style="list-style-type: disc;"&gt;&lt;LI&gt;if C value is 1 then “Green”&lt;/LI&gt;&lt;LI&gt;if C value is 2 then “Yellow”&lt;/LI&gt;&lt;LI&gt;if C value is 3 then “Red"&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to do this ? I am getting an error while writing this as i am new to lua.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aditya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2017 13:07:19 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513599#M10251</guid>
      <dc:creator>adityaku</dc:creator>
      <dc:date>2017-02-16T13:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513600#M10252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4f; font-family: 'Source Sans Pro', sans-serif; font-size: 13px;"&gt;Aditya,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4f; font-family: 'Source Sans Pro', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4f; font-family: 'Source Sans Pro', sans-serif; font-size: 13px;"&gt;Can you show us the code you already have? I think with the logic you described you can do this with a while loop with a repeat function. If you can show me how far you got I should be able to help get it working.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2017 16:36:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513600#M10252</guid>
      <dc:creator>jgorsline</dc:creator>
      <dc:date>2017-02-16T16:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513601#M10253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;First defined the service as below:&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;serviceDefinitions.RemoteService (&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="a", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="b", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; input { name="c", baseType="INTEGER" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; output { baseType="NOTHING" },&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; description { "Values" }&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;)&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P&gt;services.RemoteService = function(me, headers, query, data)&lt;/P&gt;&lt;P&gt;if not a then&lt;/P&gt;&lt;P&gt;return 400, "You must provide the 'a' parameter"&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;return 200, me.setProperty("d",0,0,0)&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have proceeded like this but getting in error&amp;nbsp; in this piece of code itself.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:53:03 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513601#M10253</guid>
      <dc:creator>adityaku</dc:creator>
      <dc:date>2017-02-16T17:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513602#M10254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jeremy!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please help me &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2017 17:54:49 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513602#M10254</guid>
      <dc:creator>adityaku</dc:creator>
      <dc:date>2017-02-16T17:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513603#M10255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can&amp;nbsp; anyone help on this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 01:29:22 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513603#M10255</guid>
      <dc:creator>adityaku</dc:creator>
      <dc:date>2017-02-17T01:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513604#M10256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aditya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming that you're working from this tutorial:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.ptc.com/help/thingworx_hc/thingworx_edge/index.html#page/twx_edge_cs_hc%2Fems_xmpp_topics%2Fc_ems_xmpp_edge_enhanced_thing_defining_custom_services.html%23" title="http://support.ptc.com/help/thingworx_hc/thingworx_edge/index.html#page/twx_edge_cs_hc%2Fems_xmpp_topics%2Fc_ems_xmpp_edge_enhanced_thing_defining_custom_services.html%23"&gt;Defining and Implementing Custom Services at the Edge&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that's the case, you're probably getting one of two errors.&lt;/P&gt;&lt;P&gt;1. lua: user.lua:15: 'end' expected (to close 'function' at line 9) near &amp;lt;eof&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -This is because you are missing an 'end' to close the function. You have one to close the if statement, but the function is still open&lt;/P&gt;&lt;P&gt;2. &lt;SPAN style="font-size: 10pt;"&gt;attempt to index global 'serviceDefinitions' (a nil value)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stack traceback:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user.lua:1: in main chunk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;C&gt;: in ?&lt;/C&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -This is because the data in the service you defined is provided from outside the script (from the Edge service.) Essentially, there is nothing input into the input lines leaving it empty, hence the complaint of a nil value. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For this reason, the lua script in the example from the tutorial will not work outside the context of the Edge server. It might be a good idea to go though all the steps of that tutorial and set up an Edge Enhanced Thing to work with if you're not doing that already. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I also found this tutorial on scope very useful when researching this issue: &lt;A href="https://coronalabs.com/blog/2015/06/16/tutorial-scope-for-beginners/" title="https://coronalabs.com/blog/2015/06/16/tutorial-scope-for-beginners/"&gt;Tutorial: Scope for beginners | Corona Labs&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2017 16:35:56 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513604#M10256</guid>
      <dc:creator>jgorsline</dc:creator>
      <dc:date>2017-02-17T16:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Luascript Service</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513605#M10257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aditya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any update on this? Was my post helpful?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:36:07 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Luascript-Service/m-p/513605#M10257</guid>
      <dc:creator>jgorsline</dc:creator>
      <dc:date>2017-03-03T18:36:07Z</dc:date>
    </item>
  </channel>
</rss>

