Author Topic: ENs - EUO to LUA Converter written in LUA  (Read 75368 times)

0 Members and 1 Guest are viewing this topic.

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #30 on: October 20, 2010, 04:15:27 AM »
+1
Could you port over my Honor and Attack script from HERE.

I'd like to see it working in OEUO.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #31 on: October 20, 2010, 07:38:07 AM »
+1
Could you port over my Honor and Attack script from HERE.

I'd like to see it working in OEUO.

Postd back in your thread.  that was a very easy to convert script.. unfortunatly it need my library file which i havent finished yet opps.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #32 on: October 20, 2010, 06:49:44 PM »
+1
Fixed conversion of these 2 trickys...

- Auto fixes split lines (+)
- Auto adjustment for code after a condtion not in {}, ie a single line. this is auto corrected (end added increases lines in file)
    ie   for !x 1 5  set %y %y + 1      translates as for x=1,5 do  y=y+1   NO end
    Commands applies to IF,For,While, CMPPIX,OnHotKEy
   (Doesnt not fixed nested bad blocks.. ie if x=y  if x=z if x=q  set x=0
- Auto Removal of blank lines left by { no longer needed.
- Added comment blocks for library function definition, script body and moved script body to end of file.

(Note: Bascailly only the menu commands and a few unsuported vars left to translate,, and of course finish writing the library functions)
« Last Edit: October 20, 2010, 10:02:40 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #33 on: October 21, 2010, 06:09:50 PM »
+1
I am working on a fix that will transalte multiple returns from a sub correctly... the number of things untranslatable has been reduced to  bascially gotos (except whre you have a single goto refrering to a single lable in the wask working space ie no jumping in out of subs). 

Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #34 on: October 23, 2010, 02:08:38 PM »
+1
OK fixed issue with mulitple returns from a sub.  It now error codes all returns except the final return, it no longer add's addiitional ends.

Proof below that multiple returns while allowed do not work as they did/do in EUO. In EUO a Return = Return END in LUA.  In LUA a return statment just sets the value returned it does not end the function

In EUO the below code would print  1 2 999
Run it you will see in lua it prints  999 999 999  

Code: [Select]
function test(x)
  if test == 1  then return 1 end
  if test == 2 then return 2 end
  return 999
end

print(test(1))
print(test(2))
print(test(3))
« Last Edit: October 23, 2010, 03:10:52 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +31
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #35 on: October 23, 2010, 02:14:47 PM »
+1
OK fixed issue with mulitple returns from a sub.  It now error codes all returns except the final return, it no longer addes addiition ends.

Proof below that multiple returns while allowed do not work as they did/do in EUO. In euo a Return = Return END in LUA.  In LUA a return statment just sets the value returned it does not end the function

In EUO the below code would print  1 2 999
Run it you will see in lua it prints  999 999 999 

Code: [Select]
function test(x)
  if test == 1  then return 1 end
  if test == 2 then return 2 end
  return 999
end

print(test(1))
print(test(2))
print(test(3))


Isn't the code doing what it's supposed to do, as "test" never has a value, only "x" has a value when the function is called?  I changed the code to:
Code: [Select]
function test(x)
  if x == 1  then return 1 end
  if x == 2 then return 2 end
  return 999
end

print(test(1))
print(test(2))
print(test(3))

and it worked correctly, so I'm not sure if your example may be wrong or if I am not understanding something else (which is very possible, as I am just beginning to grasp OEUO as it is).
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +31
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #36 on: October 23, 2010, 02:16:49 PM »
+1
Also, as a further test, I changed the code as follows:
Code: [Select]
function test(x)
  if x == 1  then return 3 end
  if x == 2 then return 4 end
  return 999
end

print(test(1))
print(test(2))
print(test(3))

and it now prints 3, 4, 999, so I believe that return does function as it did in EUO.
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #37 on: October 23, 2010, 03:13:05 PM »
+1
ow %^%&% your rigth dixie... i couldnt figure out why i previously stated multiple returns were allowed... so i ran a test.. and blow me if i borked the test..

LOL ill fix my code to now allow multiple returns. 


EDIT: Translator now Correcty processes Multiple Returns...  Changing the final return to = Return <value if exists> end.  All other returns stay as return.
« Last Edit: October 23, 2010, 03:17:31 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #38 on: October 23, 2010, 03:26:39 PM »
+1
To Highlight how the script has progressed.... SS sample code below now translates as this ...


Code: [Select]
-------------------------------------------------------------------------
-- Load Librarys
-------------------------------------------------------------------------
 
-------------------------------------------------------------------------
-- Function Definitions Start Here
-------------------------------------------------------------------------
 
function Open_Container(...)
-- %1 = container Id
-- %2 = gumpwait arg 2
-- %3 = gumpwait arg 3
-- %4 = contpos X
-- %5 = contpos Y
g_ContId=arg[1]
Reopen:
UO.LObjectID=g_ContId
UO.Macro(17,0)
EUO_Result=gumpwait(NULL,arg[2],arg[3])
if EUO_Result== false then
  --GOTO Reopen  --ERROR: GOTO -not supported:
  end
EUO_ContPos(arg[4],arg[5])
return
end  -- End Of Function: Open_Container


-- %1 = GumpWait
-- %2 = Gumpname 1
-- %3 = Gumpname 2
function GumpWait(...)
  Wait(g_Mwait * 50) -- Converted to Milliseconds
  g_timedelay=EUO_GetScnt()
GumpWait_loop1:
  if UO.ContName== arg[2]  or  UO.ContName == arg[3] then
    return true
    end
  if EUO_GetScnt()> g_timedelay + 7 then
    return false
    end
  --GOTO GumpWait_loop1  --ERROR: GOTO -not supported:
return
end  -- End Of Function: GumpWait
 
 
------------------------------------------------------------
-- Script Body
------------------------------------------------------------




Here's a few subs to try out and share here!

Code: [Select]
Sub Open_Container
; %1 = container Id
; %2 = gumpwait arg 2
; %3 = gumpwait arg 3
; %4 = contpos X
; %5 = contpos Y
set %ContId %1
Reopen:
set #lobjectid %ContId
event macro 17 0
GoSub gumpwait NULL %2 %3
if #result = #False
  goto Reopen
contpos %4 %5
Return


; %1 = GumpWait
; %2 = Gumpname 1
; %3 = Gumpname 2
Sub GumpWait
  wait %Mwait
  set %timedelay #SCNT
GumpWait_loop1:
  if #CONTNAME = %2 || #CONTNAME = %3
    Return #true
  if #SCNT > %timedelay + 7
    Return #false
  goto GumpWait_loop1
Return
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Superslayer

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #39 on: October 24, 2010, 05:19:31 AM »
+1
Odd issue, but probably me, after the script was converted, and I straightened out all the hanging errors, I was unable to run the first function.  All function definitions are open and more-or-less ready, no libraries to load needed.  When I get to the line with the function to execute, the error says:"attempt to call global 'SS_Var_Config' (a nil value)"

This line reads:
Quote
EUO_Result=SS_Var_Config(...)
the function reads:
Quote
function SS_Var_Config(...)

Running the function alone in a separate tab works just fine.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: ENs - EUO to LUA Converter written in LUA
« Reply #40 on: October 24, 2010, 12:23:18 PM »
+1
That's a good idea how you handled the function arguments.  ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #41 on: October 24, 2010, 04:28:03 PM »
+1
That's a good idea how you handled the function arguments.  ;)

Ive tried to emulate EUO were at all possible and i discovered that defineing functions with '...' allows any number of arguments that can be accessed almost identically to EUO  0%   %1... %0  LUA   arg.n   arg[1]...arg[arg.n]  how could i resist :)



As to your issue SS.. im going to have to do some investigation on that one.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Superslayer

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #42 on: October 24, 2010, 04:48:36 PM »
+1
I've tried loads of stuff. since that first function passes and returns no parameters, I removed the ... in the parentheses, changed the function name, moved it to other parts of the script, skipping that function and trying to run a different one but with the same results.

Offline Endless NightTopic starter

  • Global Moderator
  • *
  • *****
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #43 on: October 24, 2010, 05:44:54 PM »
+1
try   (not sure why the ... in the parameter passing)
EUO_Result=SS_Var_Config()

im beat tongiht but ill take a look tommorrow when i can.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Superslayer

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: ENs - EUO to LUA Converter written in LUA
« Reply #44 on: October 24, 2010, 05:59:44 PM »
+1
Ya, same result, no go. Get some rest, I'm sure your head is about to explode

Tags: