ScriptUO

Scripting Resources & Utilities => OEUO => OpenEUO Scripting Chat => Topic started by: Tidus on October 13, 2010, 04:32:35 PM

Title: Flow
Post by: Tidus on October 13, 2010, 04:32:35 PM
Since there is no goto or gosub... how do i do flow on LUA?  Make sure it goes from one sub to the next. I'm guessing subs are just functions and returns are ends.
Title: Re: Flow
Post by: _C2_ on October 13, 2010, 04:41:00 PM
Since there is no goto or gosub... how do i do flow on LUA?  Make sure it goes from one sub to the next. I'm guessing subs are just functions and returns are ends.

gosub = function now
return = end

been looking stuff up and chatting with endless
Title: Re: Flow
Post by: Tidus on October 13, 2010, 05:27:38 PM
So does
Code: [Select]
repeat
function now carveleather
until UO.CliLogged == Yes
Work for the goto?
Title: Re: Flow
Post by: Cerveza on October 13, 2010, 05:35:00 PM
So show me this in OEUO:

Code: [Select]
repeat
gosub 1
gosub 2
gosub 3
until #false

sub 1
sub 2
sub 3
Title: Re: Flow
Post by: _C2_ on October 13, 2010, 05:43:38 PM
So does
Code: [Select]
repeat
function now carveleather
until UO.CliLogged == Yes
Work for the goto?

not function now.  it is function                    *now it is


repeat
function carveleather
until UO.CliLogged == Yes
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 05:53:13 PM
Specifically for Cerveza's question:

Code: [Select]
function One()
  print("1")
end
---------------------
function Two()
  print("2")
end
---------------------
function Three()
  print("3")
end
---------------------
---------------------
repeat
  One()
  Two()
  Three()
until false

Note you need to put your functions up before the code that actually executes.

Title: Re: Flow
Post by: Endless Night on October 13, 2010, 05:57:52 PM
So does
Code: [Select]
repeat
function now carveleather
until UO.CliLogged == Yes
Work for the goto?

not function now.  it is function                    *now it is


repeat
function carveleather
until UO.CliLogged == Yes




Code: [Select]
function carveleather
     end

repeat
  carveleather
until UO.CliLogged == Yes
Title: Re: Flow
Post by: _C2_ on October 13, 2010, 06:01:00 PM
wow...
so main loops per say are all at the bottom now.  hehe.  comically it makes sense since we all feel like our worlds are upside down  :P
Title: Re: Flow
Post by: Tidus on October 13, 2010, 06:06:42 PM
basically this language reads everything and then acts upon what it needs to.
Title: Re: Flow
Post by: Tidus on October 13, 2010, 06:34:52 PM
Would this work?

Code: [Select]
dofile("tm_subs_v31.lua")
function setup
LeatherMenu = MenuInfo:New()
LeatherMenu:TM_MenuFunction("menu Edit RunebookID 12 216 73 yourrunebook")
repeat
if UO.MenuButton ~= N/A
 {
  if UO.MenuButton == GetRunebook
   {
   set UO.targcurs 1
   while UO.TargCurs == 1
       wait 1
   yourrunebook = UO.LTargetID
   LeatherMenu:TM_MenuFunction("menu Edit RunebookID 12 216 73 yourrunebook")
   UO.MenuButton = N/A
   }
  if UO.MenuButton == GetButcher
    {
     set UO.TargCurs 1
   while UO.TargCurs == 1
       wait 1
   cleaver = UO.LTargetID
   LeatherMenu:TM_MenuFunction("menu Edit ButchersID 12 260 73 cleaver")
   UO.MenuButton = N/A
   }
   }
until UO.MenuButton = EUOButton1
UO.MenuButton = N/A
 LeatherMenu:TM_DeleteControl("EUOButton1")
LeatherMenu:TM_MenuFunction("menu get HouseCheck")
   if UO.MenuRes == true
commbox = true
LeatherMenu:TM_MenuFunction("menu get BankCheck")
   if UO.MenuRes == true
commbox = false
LeatherMenu:TM_MenuFunction("menu get Chiv")
   if UO.MenuRes == true
travel = SJ
LeatherMenu:TM_MenuFunction("Menu get Recall")
   if UO.MenuRes == true
travel = RE
LeatherMenu:TM_MenuFunction("menu get bankrunes")
bankrunes = UO.MenuRes
LeatherMenu:TM_MenuFunction("menu get monsterrunes")
runeamounts = UO.MenuRes
LeatherMenu:TM_MenuFunction("menu get houserunes")
houserunes = UO.MenuRes
LeatherMenu:TM_MenuFunction("menu get maxleather")
leather = UO.MenuRes
regularfinal = 0
spinedfinal = 0
hornedfinal = 0
barbedfinal = 0
corpseid = YFM_FEX_QEX
cutleather = JJG
monster = AE_DE_FE_AF_CD_NG_IG_XG_YG_ZF_EG --; Lizardmen_Wyvrnn_Dragon_Cow_Bull_Goat_LLAMA
arti = LSW_YKQ_OKQ_QKQ_MKQ_RSW_QMH_SKQ_ALQ --;The Arties that Drop in Dungeons
delay = 8 --;
ignoretimer = ( #sCnt + 1200 )
wait = You_must_wait_to_perform_another_action
bandies = ZLF
bankposition = 1
houseposition = bankrunes + 1
End
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 06:39:39 PM
Run it.  Looks like you have a bunch of "set" commands in there.  In Lua you just need the expression "x = 1" instead of "set x 1"
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 06:41:16 PM
I'm really serious, you shouldn't even attempt a GUI based script until you've played a bit more with the Lua syntax or else you are going to get REALLY frustrated.   Probably more so since we're not sure where Cheffe is headed with the GUI thing anyhow. 
Title: Re: Flow
Post by: Tidus on October 13, 2010, 06:42:51 PM
yeah...  true..  might just have to make this basic like the first one was....
Title: Re: Flow
Post by: Tidus on October 13, 2010, 06:48:39 PM
Title: Re: Flow
Post by: Tidus on October 13, 2010, 06:55:40 PM
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 07:04:49 PM
My finditem subs have ignoreitem
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 07:08:51 PM
Also, your syntax is off.  You should code just a few lines, the test.  Baby steps.
Title: Re: Flow
Post by: Tidus on October 13, 2010, 07:21:36 PM
Also, your syntax is off.  You should code just a few lines, the test.  Baby steps.

That is why i am posting it.  I don't know the LUA language enough to know the syntax.  Also the OEUO isn't running right on my client for some reason.
Title: Re: Flow
Post by: Endless Night on October 13, 2010, 08:59:29 PM
download the latest version of openEUO...
Title: Re: Flow
Post by: Scrripty on October 13, 2010, 09:18:12 PM
Nice work, looks like people finally got over the initial shock and are steppin up. :)
Title: Re: Flow
Post by: TrailMyx on October 13, 2010, 10:54:23 PM
I highly recommend the Lua book:

http://www.amazon.com/Programming-Lua-Second-Roberto-Ierusalimschy/dp/8590379825/ref=sr_1_1?ie=UTF8&qid=1287039173&sr=8-1

Also, I keep lua.org open all the time.  There is much useful information in there, at least enough to get you working with the syntax.  If you don't have that right then Lua will just complain and exit.
Title: Re: Flow
Post by: Cerveza on October 14, 2010, 05:34:12 AM
Ok so flow goes like this now...

subs
mainloop

What about these huge subs, like journal scanning or ocr etc.... You have to put in thousands of line of code before the mainloop?

And what about calling stuff? Like KalOCR... how do you go about calling that script up when needed, and interpret the results?

What about sending arguments to a sub?? %1, %2, %3 etc...

Title: Re: Flow
Post by: Endless Night on October 14, 2010, 07:01:05 AM
What about these huge subs, like journal scanning or ocr etc.... You have to put in thousands of line of code before the mainloop?

I would cut all those subs out into a standard library and add one line to top of script
dofile('mylibrary.lua')

And what about calling stuff? Like KalOCR... how do you go about calling that script up when needed, and interpret the results?
see above ..  dofile('kalocr.lua')     will load all his subs into your script.. you just dont see it and you can call all his subs like they were in your script.


What about sending arguments to a sub?? %1, %2, %3 etc...
function myfunction(arguments)

function enstest(fistarg, secondarg, thirdarg)  
  return firstarg + secondarg + thirdarg
end

x = enstest(1,2,3)
print(x)  -- should be 6