Total players online: 8



Take the Tour | Site Map

It is currently Wed Feb 20, 2019 8:28 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sat Jan 26, 2019 11:06 am 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 23
I guess what I am asking on that previous post is how to get a value from a variable within a variable?


Top
  Profile 
PostPosted: Sat Jan 26, 2019 4:18 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 23
OK nevermind
I was thinking I may be able to replace all of the * . % to just % (from persistant to standard variables inside the script) and add all those set variables to a file that I call at the beginning but its not working on so many levels.
hhhhmmm. I am thinking it might be best to start from the ground up.


Top
  Profile 
PostPosted: Sun Jan 27, 2019 2:38 am 
Offline
Adept Scripter
Adept Scripter

Joined: 04/14/2007 16:18
Posts: 135

Groups:
I realize you said "nevermind..." however you look to be very close in what you are trying to accomplish.

nomorchaos wrote:
hope I can communicate this properly, in the script below:
the original script is:
set %amitherex %currentshard , _b , %tempbook , r , %temprune , xs

"%amitherex' now is set to "wiz_idoc_shard1_b1r6xs"

which is correct but I want it to return the value of %wiz_idoc_shard1_b1r6xs instead which I have set to a value at the beginning of the script. When I had all the variables saved in the registry it would be able to pull the value using * . %amitherex = #charposx but i have since tried to not use the registry at all and only have 1 set of variables saved per shard to a text file that I call at the beginning like:
set %wiz_idoc_shard1_b1r6xs 528


Im really trying to learn


There are 3 categories of variables based on the prefix:
% = regular local variable accessible only to the current script
* = global variable stored in registry, persistent across running easyuo and accessible by multiple scripts
! = namespace variables which do not have persistence, but can be accessible between scripts (global) or not (local)

The original author used a construct built like:
  1.  
  2. set %value * . %amitherex ; %value holds the contents of whatever variable name was in %amitherex
  3.  


Instead of referencing the persistent variable, use your local variable. This turns the contents of the variable into the variable name to give you what you are seeking:

  1.  
  2. set %value % . %amitherex
  3.  


Now %value holds the contents of the variable naemd in %amitherex.

The prefix ( * , % , ! ) represents the kind of variable space you are accessing the variable from, the dot ( . ) concatenates the variable and makes evaluates the right side at the same time. Usually this is considered the way arrays are built, because you can set in a loop a variable name like:

  1.  
  2. for %i 1 10
  3.  {
  4.  set %array . %i %i * %i ; calculates the square of number 1 to 10 in an array
  5.  }
  6.  


So in this case the loop has built a set of variables named %array1, %array2, %array3, ... %array10. This is demonstrating how the dot operator works. The right side (%i) is evaluated, but the left side of the dot is taken literally. So in your case, you would take advantage of this by giving it the kind of variable you are referencing on the left side of the dot, and what you want evaluated to become the variable name on the right side.

While as humans we may be able to think we can build this for multidimensional arrays and pass it as parameters, the parser cannot. So if you need to do another layer of building the variable name, you need an interim variable to hold the result and build more on top. The dot operator only works well for it's right and left side, but it isn't so good at recursively using the dot operator.

  1.  
  2. for %i 1 to 3
  3.  {
  4.  for %j 1 to 2
  5.   {
  6.   ; set %array . %i . %j %i * %j ; this doesn't build %array11 = 1
  7.   set %temp array , %i , %j ; this builds the name array11, array12, array21, ... array32
  8.   set % . %temp %i * %j ; this uses the built value within the variable %temp to create a multidimensional array named %array11, %array12, %array21, %array22, %array31, %array32 with values of a multiplication table
  9.   }
  10.  }
  11.  


This second example shows how the built value in %temp is used to use the contents of %temp as the variable you wish to access. In this case, the left hand side of the dot operator is only the variable prefix (% in this case, * in the original code you were modifying), while the right hand side is the contents of the variable

If your array dimensions were not a fixed number of places, then it requires a delimiter between in order to deciper if %array111 is row 1, column 11 or row 11, column 1. Authors tend to use an underscore and set it up as %array1_11 or %array11_1, or set a fixed number of digits like: %array0111 and %array1101.

Gaderian


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sun Jan 27, 2019 2:06 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 23
Thank you. I am back working on this and am now getting somehwhere finally.


Top
  Profile 
PostPosted: Mon Jan 28, 2019 1:55 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2286

Gaderian had it almost correct. But just setting the variable to:

  1. set %value % . %amitherex


Isn't enough. The variable is set to if I'm reading what he said right, I haven't looked:

  1. set %value * . %amitherex


The variable %amitherex, is actually probly the value of the coordinate. So the variable is formed maybe something like this:

  1. *522333838


The period basically just puts the value of %amitherex up against the *. And that variable holds data. In that way, you can use the unique coordinates of x/y and z to make a variable, and store info at the variable using the unique coordinate in UO by it's xyz. And recall it easily if you go to that location. So the variable might actually be formed like this:

  1. set %value * . (#charposx , #charposy , #charposz)


And that variable would be set to the info at that coordinate. It's just a slight difference, and I'm not 100% sure that's how it is in Wiz's script, but that's how I was discussing using it. But I don't suggest you use the * variables to do that. You could just use standard variables with the % (percent) symbol, and then use Trailmyx's registry saving subs to save any number of those variables you like, with any amount of data, using the least amount of registry variables possible, because Trailmyx took care of using too many variables in the registry for you, in his subs. If neither of you have used those subs before, I suggest you check them out. You can find the newest version of them in the secondary script that comes with my looter. Lootmaster. It would be the most efficient way imho. I'd write a new one from scratch. Wiz's is nice, but it's old, and there's way better and easier ways to do it. I do it that way in my mining script. And I store literally thousands of variables easily. And you can separate it easily by #shard, by #charname, whatever you like. Using those in the variable name to make the data unique per shard, or per shard, per character even if you wanted to go that far. Honestly, you don't even need to use the #charposz coordinate. The x and the y should be unique enough. Especially if you use the facet info on the right of easyuo to separate the info by facet and shard. So you could easily have separate data for fel and tram. Using the same coordinates, but making them unique with the facet and shard info.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Mon Jan 28, 2019 12:59 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 23
Ok, I used what both of you have said and I now have it working like I want! Just took me giving up for a night and retrying with both of yours advice. The only variables I am using in the registry is 2 for each shard, saying what the last book and rune was that I ran so that I know where I left off the rest of the variables are coming from a file I call at the beginning specific to each shard with waypoints and book id's. Its for sure not anywhere near as efficient as what you are describing Scripty but I at least am now able to run the same rails on every shard. Its funny though even though I got that working, I will be starting to write one from the ground up that is more efficient and functional. I appreciate all the help.


Top
  Profile 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.