Author Topic: TrailMyx's multi-dimensional Array Handler  (Read 15797 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • 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: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
TrailMyx's multi-dimensional Array Handler
« on: June 09, 2008, 12:16:58 PM »
0
Here's the subs:
Code: easyuo
  1. ; %1 = Arrayname
  2. ; %2 = Value to add
  3. ; %3 = index 1
  4. ; %4 = index 2
  5. ; ...
  6. sub AddToArray
  7.   namespace push
  8.   namespace local Array , _ , %1
  9.   set !var
  10.   for !index 3 %0
  11.      set !var % . !index , _ , !var
  12.   set ! . !var %2
  13.   namespace pop
  14. return
  15. ; %1 = Arrayname
  16. ; %2 = index 1
  17. ; %3 = index 2
  18. ; ...
  19. sub GetFromArray
  20.   namespace push
  21.   namespace local Array , _ , %1
  22.   set !var
  23.   for !index 2 %0
  24.      set !var % . !index , _ , !var
  25.   set #RESULT ! . !var
  26.   namespace pop
  27. return #RESULT
  28.  

Here's some test code:

Code: easyuo
  1. gosub AddToArray myarray 34 5 5 ; myarray[5][5] = 34
  2. gosub GetFromArray myarray 5 5  ; gets value at myarray[5][5]
  3. stop
  4.  
« Last Edit: May 05, 2017, 05:00:20 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: TrailMyx's multi-dimensional Array Handler
« Reply #1 on: December 04, 2009, 06:41:17 PM »
0
TM,

I would love it if at some point you have time and inclination to write up a tutorial on how to use these.  Just figured I would let you know there would be an audience...

-P
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • 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: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: TrailMyx's multi-dimensional Array Handler
« Reply #2 on: December 04, 2009, 07:17:04 PM »
0
Hmm, well there's not alot to write about really.  An array is an array.  If you scrutinize the sample I gave:

Code: [Select]
gosub AddToArray myarray 34 5 5 ; myarray[5][5] = 34
gosub GetFromArray myarray 5 5  ; gets value at myarray[5][5]

I'm calling out an array named "myarray".  From the arguments, you can see I'm putting a value of "34" into index [5]][5].  The next line is just recalling the value.

I guess the one thing I can point out is this is a multidimensional array, so you could potentially have limitless indexes.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Paulonius

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: TrailMyx's multi-dimensional Array Handler
« Reply #3 on: December 04, 2009, 08:19:23 PM »
0


Quote
Hmm, well there's not alot to write about really.  An array is an array.

This tells me that you are too far away from not knowing what arrays are to explain them to me, which makes me laugh at myself for asking.  I am pretty sure I had a book on BASIC that had something like Chapter 3: Arrays...   Unfortunately that was 1984 and I didn't do anything remotely related to programming between then and when I started logging into SUO earlier this year...

When I have time I will find an explanation from some remedial text book and dovetail it into this thread for the completely ignorant... like me.  I am pretty sure I am working on a script that really wants an array or two and I need to turn myself into someone who can give it what it wants...
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline NObama

  • Everything I need to know, I learned from Miffy's Item Finder.
  • Elite
  • *
  • *
  • Posts: 3454
  • Activity:
    0%
  • Reputation Power: 43
  • NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.NObama is a force to reckon with.
  • Respect: +161
  • Referrals: 2
    • View Profile
Re: TrailMyx's multi-dimensional Array Handler
« Reply #4 on: December 04, 2009, 08:23:07 PM »
0
Multi-dimensional...like the negative zone?

 8)

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: TrailMyx's multi-dimensional Array Handler
« Reply #5 on: December 04, 2009, 08:45:50 PM »
0
Well think of a 2 dimensional array as your screen.  To locate a pxiel on your screen you use x,y postioning... So the entire screen is a mutli (2) dimensional array.

So tms example could be

gosub AddToArray myscreen %PixelColor %x  %y
gosub GetFromArray mycreen %x %y


Now a 3rd dimensional array is the same as the pinpointing a location on the UO map.. you have X,Y,Z

a 4th dimensional array could be ....

bla bla bla...
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • 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: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: TrailMyx's multi-dimensional Array Handler
« Reply #6 on: December 05, 2009, 04:23:08 AM »
0
This tells me that you are too far away from not knowing what arrays are to explain them to me, which makes me laugh at myself for asking. 

Lol!  Sorry Paul.  I guess arrays are one of those fundamentals, but I forget that even those fundamentals sometimes are hard to understand.

Probably the best example I can think of when I think of arrays are to think of your multiplication table (example of a 2 dimensional array)

Code: easyuo
  1. ; set up your times tables
  2. for %x 1 12
  3. {
  4.   for %y 1 12
  5.   {
  6.     set %times %x * %y
  7.     gosub AddToArray times_table %times %x %y
  8.   }
  9. }
  10.  
  11. gosub GetFromArray times_table 11 12
  12. display ok 11 times 12 is , #SPC #RESULT
  13.  
  14. gosub GetFromArray times_table 5 7
  15. display ok 5 times 7 is , #SPC #RESULT
  16.  
  17. gosub GetFromArray times_table 8 9
  18. display ok 8 times 9 is , #SPC #RESULT
  19.  
  20. stop
  21. ; %1 = Arrayname
  22. ; %2 = Value to add
  23. ; %3 = index 1
  24. ; %4 = index 2
  25. ; ...
  26. sub AddToArray
  27.   namespace push
  28.   namespace local Array , _ , %1
  29.   set !var
  30.   for !index 3 %0
  31.      set !var % . !index , _ , !var
  32.   set ! . !var %2
  33.   namespace pop
  34. return
  35. ; %1 = Arrayname
  36. ; %2 = index 1
  37. ; %3 = index 2
  38. ; ...
  39. sub GetFromArray
  40.   namespace push
  41.   namespace local Array , _ , %1
  42.   set !var
  43.   for !index 2 %0
  44.      set !var % . !index , _ , !var
  45.   set #RESULT ! . !var
  46.   namespace pop
  47. return #RESULT
  48.  
« Last Edit: May 05, 2017, 04:59:53 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!