ScriptUO

Scripting Resources & Utilities => OEUO => OpenEUO Scripting Tutorials => Topic started by: Cerveza on October 20, 2010, 04:18:58 AM

Title: Couple of commands
Post by: Cerveza on October 20, 2010, 04:18:58 AM
I'm wondering how scripts speak to each other. In EUOx I use this to make my script wait till looting is completed:
Code: [Select]
    repeat
      namespace copy TM_loot_in_progress from global TM_loot
    until !TM_loot_in_progress <> #TRUE

How does that translate?

Actually, how would this entire sub translate?

Code: [Select]
sub Check_Status
if #targCurs = 1 || #lLiftedKind = 1
  return #TRUE
namespace copy TM_HEAL from global TM_HEAL
if !TM_HEAL = #TRUE
  return #TRUE
wait 10
namespace copy TM_loot_in_progress from global TM_loot
if !TM_loot_in_progress = #TRUE
  return #TRUE
return #FALSE
Title: Re: Couple of commands
Post by: TrailMyx on October 20, 2010, 08:04:32 AM
That's exactly why I created my namespace interface routines.  I'll post an example today, but with my namespace routines, you can make that code look hauntingly similar to your OEUO code.
Title: Re: Couple of commands
Post by: TrailMyx on October 20, 2010, 08:19:09 AM
These values are also what I'm using in my new OEUO scripts.  Sample code for both of your questions:

Code: [Select]
dofile("tm_namespaces9.lua")
ns = TM_NS:New() -- setup local and global namespaces
-- ..
-- ..
-- ..
function Check_Status()
  if UO.TargCurs == true or UO.LLiftedKind == true then
    return true
  end
  if ns:ReadAbs("global","TM_HEAL","TM_HEAL") == true then
    return true
  end
  if ns:ReadAbs("global","TM_loot","TM_loot_in_progress") == true then
    return true
  end
  return false
end

-- Inline looter busy test
--
-- repeat
-- until ns:ReadAbs("global","TM_loot","TM_loot_in_progress") ~= true
--

I created the "ReadAbs" and "WriteAbs" routines because there's lots of times when you want to directly read from an addressed namespace, so it's a pain in the butt to copy the value from that namespace and then address it using the current namespace.  Again, that just came from lots of experience using Cheffes namespace stuff to see what works and what's cumbersome.