Converting LUA scripts to vbscript

Posted by Ashass on Thu 25 Nov 2010 06:00 PM — 3 posts, 16,471 views.

#0
[ALL ISSUES RESOLVED - topic can be closed]

<triggers>
  <trigger
   keep_evaluating="y"
   match="^\&lt;(\d+)\/(\d+)hp\, (\d+)\/(\d+)m\, (\d+)\/(\d+)mv\, (.*)\&gt; (?&lt;hour&gt;\d+)\:(?&lt;minute&gt;\d+)(am|pm)\."
   regexp="y"
   send_to="12"
   sequence="100"
   variable="health"
  >
  <send>if %&lt;hour&gt; ~= old_hour or
%&lt;minute&gt; ~= old_minute then
old_hour = %&lt;hour&gt;
old_minute = %&lt;minute&gt;
DoAfterNote (34, "TICK IN 7 SECONDS!") -- 7 seconds warning
end -- if</send>
  </trigger>
</triggers>


Became

 <triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^\&lt;(\d+)\/(\d+)hp\, (\d+)\/(\d+)m\, (\d+)\/(\d+)mv\, (.*)\&gt; (?&lt;hour&gt;\d+)\:(?&lt;minute&gt;\d+)(am|pm)\."
   regexp="y"
   send_to="12"
   sequence="100"
   variable="health"
  >
  <send>if (%&lt;hour&gt; &lt;&gt; old_hour OR %&lt;minute&gt; &lt;&gt; old_minute) then
old_hour = %&lt;hour&gt;
old_minute = %&lt;minute&gt;
world.DoAfterNote 34, "TICK IN 7 SECONDS!" '7 seconds warning
end if</send>
  </trigger>
</triggers>




========================

<triggers>
  <trigger
   expand_variables="y"
   match="*[Str: *  Int: *  Wis: *  Dex: *  Con: *]"
   send_to="12"
   sequence="100"
  >
  <send>percent = math.floor (%2+%3+%4+%5+%6)
Note ("You rolled ", percent)
if(percent &gt;= 240) then
  Send "y"
end -- if

if(percent &lt; 240) then
  Send ""
  Send "n"
end -- if</send>
  </trigger>
</triggers>


became


Dim percent 
percent = (%1/%2 * 100)

if(percent >= 100) then
Note "You are in excellent condition."
end if

if(percent < 100 and percent >= 90) then
Note "You have a few scratches."
end if

if(percent < 90 and percent >= 75) then
Note "You have some small wounds and bruises"
end if

if(percent < 75 and percent >= 50) then
Note "You have quite a few wounds"
end if

if(percent < 50 and percent >= 30) then
Note "You have some big & nasty wounds"
end if

if(percent < 30 and percent >= 15) then
Note "You are pretty hurt"
end if

if(percent < 15 and percent > 0) then
Note "You are in awful condition"
end if

if(percent = 0) then
Note "You are dead!"
end if


=======================================

<triggers>
  <trigger
   expand_variables="y"
   keep_evaluating="y"
   match="&lt;*/*hp, */*m, */*mv, *&gt; *. *"
   send_to="12"
   sequence="100"
   variable="health"
  >
  <send>percent = math.floor (%1/%2 * 100)

if(percent &gt;= 100) then
Note "You are in excellent condition."
end -- if

if(percent &lt; 100 and percent &gt;= 90) then
Note "You have a few scratches."
end -- if

if(percent &lt; 90 and percent &gt;= 75) then
Note "You have some small wounds and bruises"
end -- if

if(percent &lt; 75 and percent &gt;= 50) then
Note "You have quite a few wounds"
end -- if

if(percent &lt; 50 and percent &gt;= 30) then
Note "You have some big &amp; nasty wounds"
end -- if

if(percent &lt; 30 and percent &gt;= 15) then
Note "You are pretty hurt"
end -- if

if(percent &lt; 15 and percent &gt; 0) then
Note "You are in awful condition"
end -- if

if(percent == 0) then
Note "You are dead!"
end -- if</send>
  </trigger>
</triggers>


Became


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="*[Str: *  Int: *  Wis: *  Dex: *  Con: *]"
   send_to="12"
   sequence="100"
  >
  <send>total = %2+%3+%4+%5+%6
Note "You rolled " &amp; total
if(total &gt;= 240) then
  Send "y"
end if

if(percent &lt; 240) then
  Send ""
  Send "n"
end if</send>
  </trigger>
</triggers>
Amended on Thu 25 Nov 2010 09:34 PM by Ashass
Australia Forum Administrator #1
OK, good. Although the original post asked how to convert from Lua to VBscript to resolve problems with MSSQL.

Personally I prefer Lua, and if you have problems with the ODBC SQL I would try to resolve those.

Also, if this is a single-user database, you might consider using SQLite3, which is built into MUSHclient, so you don't need to have external database engines around.
#2
It's more of a proof of concept project, I am familiar with VBA which is pretty much vbscript, granted, it's not my language of choice, but oh well. the ODBC connection to MSSQL is to see just how far I can take things for storage, automation, and integration [to web services]

Also going to see about connecting a local ASP page to an external MySQL database to see if I can go from my client->local database->local website->external website->external database [just to see what I can integrate with]

One of the next few thing's I'm going to be doing, is taking an ASP page and making a GUI representation of certain things, such as fights, spells cast on me [durations left], maps of areas, etc. that can be up next to your mud window to see graphically what normally you have to do score/inventory/map etc.

Just poking the boundaries to see when things break, then when they break, see if there is a way to fix it or work around it to do what I want.

Would be much harder to do this with LUA script [for me, anyway] - because in addition to not knowing the language very well, it doesn't integrate as cleanly as vbscript does into a large slew of different projects.