Author Topic: TrailMyx's Namespace Interface Routines  (Read 9437 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13310
  • 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: +3089
  • Referrals: 34
    • View Profile
    • ScriptUO
TrailMyx's Namespace Interface Routines
« on: September 10, 2010, 10:57:00 AM »
0
Code: [Select]
--[[-------------------------------------------------------------
 Script Name: TrailMyx's Namespace Interface Routines
 Author: TrailMyx
 Version: v7
 Shard OSI / FS: sure, why not?
 Revision Date: 9/10/2010
 Purpose: Collection of routines to simulate the namespace functions found in
          the original EasyUO

 Functions:
      New(o) - creates a new namespace object.  You will only need one.
          OEUO example:  myns = TM_NS:New() -- create TM_NS object
          EUO example: none
      Push() - pushes or "remembers" current nsname and nstype from the stack
          OEUO example:  myns:Push() -- saves nsname and nstype
          EUO example: namespace push
      Pop() - pops or "recalls" the saved nsname and nstype from the stack
          OEUO example: myns:Pop() -- recall last saved nsname and nstype
          EUO example: namespace pop
      Switch(ns_type, ns_name) - sets the current values of nsname and nstype
          OEUO example: myns:Switch("local","ns1")
          EUO example: namespace local ns1
      Exists(ns_type, ns_name) - determines if a namespace exists (true)
          OEUO example: myns:Exists("local","ns1") -- true if exists, otherwise false
          EUO example: no equivalent
      Read(item) - reads a variable from the current namespace
          OEUO example: myns:Read("var1")
          EUO example: !var1
      ReadAbs(ns_type, ns_name, item) - reads a variable from a specified namespace
          OEUO example: myns:Read("global", "ns1", "var1") -- reads "var1" from global:ns1
          EUO example: namespace copy var1 from global ns1 ; careful, overwrites current var1
      Write(item, value) - writes a value to a variable in the current namespace
          OEUO example: myns:Write("var1", 5)
          EUO example: !var = 5
      WriteAbs(ns_type, ns_name, item, value) - writes a writes a value to a variable in a specified namespace
          OEUO example: myns:Write("local", "ns1", "var1", 5)
          EUO example: namespace copy var1 to local ns1
      Clear() - clears the contents of the current namespace
          OEUO example: myns:Clear()
          EUO example: namespace clear
      CopyTo(ns_type, ns_name, item) - copies current namespace values to specified NS
          OEUO example: myns:CopyTo("local", "ns1", "var") -- copies vars starting with "var" to local:ns1
          OEUO example: myns:CopyTo("local", "ns1", "*") -- copies everything to local:ns1
          EUO example: namespace copy var* to local ns1
          EUO example: namespace copy * to local ns1 ; copy everything
      CopyFrom(ns_type, ns_name, item) - copies specific values from namespace to local namespace
          OEUO example: myns:CopyFrom("local", "ns1", "var") -- copies vars starting with "var" from local:ns1
          OEUO example: myns:CopyFrom("local", "ns1", "*") -- copies everything from local:ns1
          EUO example: namespace copy var* from local ns1
          EUO example: namespace copy * from local ns1 ; copy everything
      Match(ns_type, ns_name, item) - creates a table of items that match "item" from specified namespace
          OEUO example: tbl = myns:Match("local", "ns1", "var") -- creates table(tbl) that holds matchs {varname, value}
          EUO example: none
 Special Thanks:

 Beta testers:
 Bug testers:

---------------------------------------------------------------]]

See attached sample code commented out a the bottom.  

This collection of routines gives the scripter much of the same functionality lost when EUO moved to Lua.  Global and Local namespaces are again available.  See the syntax as described in the header.

The lookup process uses indexed tables for exceptional speed.

Note that with the CopyTo and CopyFrom, these are automatically considered wildcard arguments.  Also the argument of "*" can be used to copy EVERYTHING.  If you need to copy just one variable, then use ReadAbs() and WriteAbs()

Also notice that you can copy from local<-->global namespaces with these functions.  Very useful.

There are 2 attachment(s) in this post. You must register and post an acceptable introduction to download
tm_namespaces8.lua
tm_namespaces9.lua
« Last Edit: November 06, 2010, 02:49:23 AM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13310
  • 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: +3089
  • Referrals: 34
    • View Profile
    • ScriptUO
Re: TrailMyx's Namespace Interface Routines
« Reply #1 on: September 10, 2010, 10:57:27 AM »
0
Reserved...
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13310
  • 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: +3089
  • Referrals: 34
    • View Profile
    • ScriptUO
Re: TrailMyx's Namespace Interface Routines
« Reply #2 on: September 13, 2010, 11:18:36 PM »
0
Updated to version 8.  Fixed a couple bugs in o:CopyTo() and o:CopyFrom().
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13310
  • 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: +3089
  • Referrals: 34
    • View Profile
    • ScriptUO
Re: TrailMyx's Namespace Interface Routines
« Reply #3 on: September 13, 2010, 11:20:23 PM »
0
These should be stable enough for general use.  I'm using them pretty effectively in the OEUO-version of my rail engine.  Almost time to port the CLAw...
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13310
  • 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: +3089
  • Referrals: 34
    • View Profile
    • ScriptUO
Re: TrailMyx's Namespace Interface Routines
« Reply #4 on: October 20, 2010, 11:43:37 AM »
0
Upgraded to version 9.  Just found a couple little bugs that might crop up if you are using local namespaces.  Globals shouldn't be effected.
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: TrailMyx OEUO