Author Topic: FIRST SUO OEUO TUTO. :)  (Read 3500 times)

0 Members and 1 Guest are viewing this topic.

Scrripty

  • Guest
FIRST SUO OEUO TUTO. :)
« on: April 28, 2010, 01:17:25 PM »
0
Code credit here goes to: Seinken, reused here to demonstrate simple OEUO functions and syntax.  Hope this gives a little insight into OEUO usage for others.
 
I thought since others are going to be picking up OEUO, we better get started.  First.  FindItem.  The new command works different then FindItem did.  Now you actually have to do a for loop to scan all items.  You could do this manually to find a specific item in EUO by doing this:

Code: [Select]
finditem yourmom G_10
for #findindex 1 #findcnt
{
  look for specific mom code here
}

We all know, if you just did a #finditem by itself, it would just find the first item you came to with the same type or id.  Well now you have more control over the scan.  Here's an example below.  Remember these things:  "function" is just the new lua syntax for "sub", "~=" = NOT EQUAL, everything is GLOBAL if it's not defined LOCAL.  LUA IS CASE SENSITIVE.  You must DEFINE LOCAL IF YOU WANT IT LOCAL, and all if statements and while statements MUST be "closed" with an "end" command.  Like this:

Code: [Select]
if var = yourmom
  do whatever
end

while var = something
  do this
end

Code: [Select]
function scanitems()      --; function is the same as sub in EUO.  This just says "sub scanitems()"
local cnt = UO.ScanItems(false) --; This just sets the "count" or local variable cnt to the number of items found by the UO.ScanItems

i=0
   while i ~= cnt do --; While i is NOT EQUAL to the total number of items in cnt, keep doing the while until condition met (i ~= cnt).
    
   local ID,Type,Kind,ContID,X,Y,Stack,Rep,Col = UO.GetItem(i) --;Set all these variables (Type, Kind, etc) to the scanned item under i, starting at i=0 and ending at the total item count which was set to the "cnt" var.

   local Name,Info = UO.Property(ID) --; This just sets 2 vars with the returned property for each.

   print("Item ID Is:" .. ID,"Item Type Is:" .. Type) --; You'll notice the .. in my print message here, this is how you concatenate items to the same line. Used to be . in old EUOX code.

   print("Item Name Is:" .. Name,"Item Properties Are:" ..Info)

   print("Press F9 while this window is active for the next item.")  This waits for you to hit F9 to continue to next item with the pause below.

   pause()

   i = i+1 --; Increment var to look at the next item, return to top until expression evaluates to false.

   end --; Always end (case sensitive) your while/for/if's!! Will cause headaches if you do not remember!

end

while true do --; This is the actual code that the script runs.  The stuff above is the called sub or "FUNCTION" in OEUO syntax.
  scanitems() --; This calls the function "scanitems" with no passed parameters in the parenthesis.
end           --; While's need ends too. :)
 

This is just my basic understanding so far of some simple things in OEUO.  To my limited understanding so far, the syntax is just more mature in that it uses a full fledged programming language.  But it's the very same concepts used as in EUO.  If you can learn the EUO syntax you're perfectly capable of learning this one too. :)  
« Last Edit: April 28, 2010, 03:12:26 PM by Scripty »

Scrripty

  • Guest
Re: FIRST SUO OEUO TUTO. :)
« Reply #1 on: April 28, 2010, 03:13:31 PM »
0
Fixed a typo.  The UO.GetItem(i) starts at "i=0" not 1. :)  Oops.

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: FIRST SUO OEUO TUTO. :)
« Reply #2 on: April 29, 2010, 04:14:04 AM »
0
I thought I read that Cheffe is still debating whether to have oeuo use the '1' or '0' count based on other languages that can read it. Or is it now set that it will be '0'?

Scrripty

  • Guest
Re: FIRST SUO OEUO TUTO. :)
« Reply #3 on: April 29, 2010, 08:33:06 AM »
0
I thought I read that Cheffe is still debating whether to have oeuo use the '1' or '0' count based on other languages that can read it. Or is it now set that it will be '0'?

(i) was actually set to 0 in this snippet.  But he hasn't decided and there is still two conventions used on OEUO from my understanding.  

Tags: