ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Mystre on September 25, 2008, 07:33:44 PM

Title: Variables
Post by: Mystre on September 25, 2008, 07:33:44 PM
So i am trying to create persistant variables based on the char name... im not that great a scripting but i know a lil. let me explain.

I have a script that keeps track of say wood chopped per session and total obviosly this is down with something like

%wood
and
*wood

now i am trying to run multiple accounts on the same pc, you can understand how my totals are going to get messed up unless i make multiple copies of the script with dif persistant variables. (the easy way)

I would rather find a way to create a variable based on a sys variable...

ex

set #charname . wood (clearly this doesnt work) lol


Ideas anyone?
Title: Re: Variables
Post by: TrailMyx on September 25, 2008, 07:49:06 PM
What I do is use a couple really simple subroutines to save/recall information from the persistant variable pool:

Code: [Select]
;------------------------------------------------------------
sub TM_GetPersistantVariable
  set #RESULT %1 , _ , #CHARID
  set #RESULT * . #RESULT
return #RESULT
;------------------------------------------------------------
sub TM_SetPersistantVariable
  set #RESULT %1 , _ , #CHARID
  set * . #RESULT %2
return

So when I want to set something into persistant memory, I do:

Code: [Select]
    gosub TM_SetPersistantVariable TM_HEAL_BANDAGE !heal_bandage

and when I want to retrieve this information, I do:

Code: [Select]
  gosub TM_GetPersistantVariable TM_HEAL_BANDAGE
  set !heal_bandage #RESULT

Suppose your #CHARID is XXYYZZ1, with these functions the value contained in !heal_bandage is stored in *TM_HEAL_BANDAGE_XXYYZZ1.  So now this is character specific.

Hope this helps.

TM

Title: Re: Variables
Post by: Mystre on September 28, 2008, 04:41:17 PM
thats exactly what i was looking for :) now to implement it haha *sigh*
Title: Re: Variables
Post by: 12TimesOver on September 29, 2008, 06:22:17 AM
Ah, very nicely done! I was starting to think about this very topic as I work through revamping Miner For Dummies (adding the counters). Good food for thought. I'm still thinking that I'd like to save the variables out to the file system rather than the registry though so I really need to get a handle on your file system subs TM. Life has been damn busy as of late so the idea of actually spending time to advance my EUO coding education is laughable.

XII
Title: Re: Variables
Post by: Endless Night on September 29, 2008, 06:40:16 AM
I always think saving to file is much more prefereable to the registery.. the registry is way overused in many EUO scripts for stuff that really dont need to be in thier.  just my own 2cents.
Title: Re: Variables
Post by: TrailMyx on September 29, 2008, 08:11:59 AM
I always think saving to file is much more prefereable to the registery.. the registry is way overused in many EUO scripts for stuff that really dont need to be in thier.  just my own 2cents.


I totally agree, EN!  I think it would be kinda funny to see how many registry entries people have for the EasyUO section.
Title: Re: Variables
Post by: talkmill on September 29, 2008, 10:34:48 AM
I did a fast count, about 130 entries from that kind of variables in my registry. Only a month old install though :)
Title: Re: Variables
Post by: 12TimesOver on September 29, 2008, 11:26:39 AM
I always think saving to file is much more prefereable to the registery.. the registry is way overused in many EUO scripts for stuff that really dont need to be in thier.  just my own 2cents.


I totally agree, EN!  I think it would be kinda funny to see how many registry entries people have for the EasyUO section.

Exactly why I said what I said. Especially being a systems dude, I can't stand it when applications try to take ownership of a workstation or server as if it's the only application anyone will ever need. So yeah, this is next on the learning bloack for me...
Title: Re: Variables
Post by: talkmill on September 29, 2008, 11:55:05 AM
Would have been cooler if everything was saved in some kind of easyuo database on disk so you could have the easy access (instead of the really clumsy way to go throgh cmd) but still have everything on file.
Title: Re: Variables
Post by: Endless Night on September 30, 2008, 07:32:22 PM
Well it would be really cool if easyuo did alot of things it dont.

Title: Re: Variables
Post by: Crisis on May 09, 2015, 06:08:24 AM
Can someone explain this to me and how it is used? What variables are being saved?

For example, if I set a bag as a resource bag with a script and I use TM's sub here, will it keep that bag in memory every time I open the same script so I don't have to reset it?

Is there an advantage to this? I am seeing that at the time, too many scripts were saving things in the registry, is there a better way now that 7 years has gone by?
Title: Re: Variables
Post by: The Ghost on May 09, 2015, 06:41:08 AM
Variable are nice since you only need to setup your bag once.  If you play different shard, u don't have to mod the script.  CEO use those lot and still work after 14 years :)
Title: Re: Variables
Post by: TrailMyx on May 09, 2015, 10:39:58 AM
Can someone explain this to me and how it is used? What variables are being saved?

For example, if I set a bag as a resource bag with a script and I use TM's sub here, will it keep that bag in memory every time I open the same script so I don't have to reset it?

Is there an advantage to this? I am seeing that at the time, too many scripts were saving things in the registry, is there a better way now that 7 years has gone by?

Unfortunately EUO hasn't evolved at all with regard to file I/O.  I have hopes that the next version of EUO will finally open up the file I/O thing a little bit.  Until then, the registry or actually writing a file using "execute command echo" is the only way.  There are actually other ways.  I did a .NET program that communications through command registers in the registry to send blocks of data to an external program.  That worked well, but required an external program.