Author Topic: Placing misc words into an array  (Read 6966 times)

0 Members and 1 Guest are viewing this topic.

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Placing misc words into an array
« on: January 28, 2017, 06:46:17 PM »
0
Lets say I have a half dozen words(or more) I'd like to place into an %array, how would I best do that?

Example: apple, monitor, computer, bike, kleenex and camera...\
set %array apple_monitor_computer_bike_kleenex_camera

That doesn't seem to work like it does for itemtypes, should it? After I perform an event property check I'd like to to run an if against the %array to find out if any of them are in there before I buy...

I know I can do individual checks such as if apple in #property || if...etc but that gets unwieldly if there are a couple dozen+ words in there. Suggestions?

edit: I am already running a loop on, for example, 125 items in a chest and during each item check I'd like to see if it has any of the words in it's property... without having an endless line of "if apple is in #property || monitor is in #property || etc."
« Last Edit: January 28, 2017, 06:52:43 PM by Gemviper »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Placing misc words into an array
« Reply #1 on: January 28, 2017, 09:56:55 PM »
0
You could so something like this:

Code: [Select]
set %array0 apple
set %array1 monitor
set %array2 bike
set %array3 kleenex
set %array4 camera

for %i 0 4
{
  set %item %array . %i
  display ok %item
}

stop

Then you just reference each of the items with the index reference %array . %i

if you just want to use a string to build upon so you can use the "in" function, you can just do something like:

Code: [Select]
set %array0 apple
set %array1 monitor
set %array2 bike
set %array3 kleenex
set %array4 camera

set %string
for %i 0 4
{
  set %string %string , _ , %array . %i
}

display ok %string
stop
« Last Edit: January 28, 2017, 10:01:08 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #2 on: January 28, 2017, 10:10:29 PM »
0
It might help if I'm more specific, I'm hoping it's possible to tighten up this particular sub a bit. It deals with 210 "words", each belonging to a different itemtype.

set %itemtypes AAA_BBB_CCC_DDD_EEE_ETC...
finditem %itemtypes etc

but instead of proceeding from there I need to confirm that a particular word is found in the #property of every %itemtypes found, which is itself in a loop that itterates through each result, among other things. Is it not possible to create a single, albeit long, "set" of words instead of creating a lot of arrays? I don't want to return a positive unless an %itemtypes and "word" combo is found. CHecking each result against a long list of arrays, or if statements, doesn't feel optimal for my specific needs with this.

Just to confirm, it's not possible to create a single "set" of many words and return a positive if any one word is in that set ?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Placing misc words into an array
« Reply #3 on: January 28, 2017, 11:01:48 PM »
0
It might help if I'm more specific, I'm hoping it's possible to tighten up this particular sub a bit. It deals with 210 "words", each belonging to a different itemtype.

set %itemtypes AAA_BBB_CCC_DDD_EEE_ETC...
finditem %itemtypes etc

but instead of proceeding from there I need to confirm that a particular word is found in the #property of every %itemtypes found, which is itself in a loop that itterates through each result, among other things. Is it not possible to create a single, albeit long, "set" of words instead of creating a lot of arrays? I don't want to return a positive unless an %itemtypes and "word" combo is found. CHecking each result against a long list of arrays, or if statements, doesn't feel optimal for my specific needs with this.

Just to confirm, it's not possible to create a single "set" of many words and return a positive if any one word is in that set ?

Sure, that's actually easy (assuming I understand your question)

Given your example:

Code: [Select]
set %array _apple_monitor_computer_bike_kleenex_camera_

EasyUO has the two operators "in" and "notin"  so you can do something like this:

Code: [Select]
set %array _apple_monitor_computer_bike_kleenex_camera_
set %test1 _raptor_
set %test2 _computer_

if %test1 notin %array ; notice the usage of "notin"
{
  display %test1 is not in %array
}

if %test2 in %array ; notice the usage of "in"
{
  display ok %test2 is in %array
}

stop
« Last Edit: January 28, 2017, 11:04:07 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline BobOzarius

  • Full Member
  • ***
  • Posts: 103
  • Activity:
    0%
  • Reputation Power: 2
  • BobOzarius has no influence.
  • Respect: +26
  • Referrals: 0
    • View Profile
Re: Placing misc words into an array
« Reply #4 on: January 29, 2017, 01:16:25 AM »
0
If you've already broken apart the #property into sections, you can name your variables what you're searching for, and set them to #true. Like if you're looking for very specific things.

Code: [Select]
set %arrayMonitor #true
set %arrayBike #true
set %arrayKleenex #true
set %arrayCamera #true

Then when you break apart your #property string, or you could even use the whole #property, and you get your result from each part, you can do some code like this:

Code: [Select]
for %I 1 %numberOfStringChunks
{
  gosub breakStringApartRight
  set %stringChunk n/a
  if %array . #result = #true
    set %stringChunk #result
  if %stringChunk = n/a
    display The variable is not in the #property.
  if %stringChunk <> n/a
    display The variable is in the #property.
}

Then you can use the %stringChunk variable if it's found to be in the #property in any way you like, in a variable to find what you are looking for in #property, or perform an action based on that item because it's the #result from earlier in the script, and it's in the #property.

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: Placing misc words into an array
« Reply #5 on: January 29, 2017, 01:26:51 AM »
0
Take a look at the BOD filterer I just posted.  It does exactly what you want.

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #6 on: January 29, 2017, 09:12:53 AM »
0
Thanks guys
« Last Edit: January 29, 2017, 04:47:14 PM by Gemviper »

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #7 on: January 29, 2017, 05:05:57 PM »
0
One last question,

set %group200 AAA_BBB
set %group450 CCC_DDD

During the sub calculations are made against itemtypes and a final value number is generated(ie: 200). The next section of the script requires that I check to make sure that the itemtype is indeed in the group bearing the final value number(ie: if the final value is 200 then that item's itemtype is in %group200).

Sounds simple, and I'm sure it is, but I'm drawing a brain fart on the syntax. Example:

set %finalvalue 200
IF #FINDTYPE in %group200

I don't want to repeat the above check for each of the 210 groups and obviously "IF #FINDTYPE in %group%finalvalue" won't work(example to give you an idea of what I'm after)... so how can I I append the %finalvalue number to the %group to come up with %group200 ?


Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Placing misc words into an array
« Reply #8 on: January 29, 2017, 05:13:57 PM »
0
I you're just looking to append whatever is in %group to %group_200, this is probably what you're looking for:

Code: [Select]
set %group_200 %group_200 , _ , %group
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #9 on: January 29, 2017, 05:15:53 PM »
0
I am... sorta. 1 of the values I will not know in advance however. A simplified example...

Code: [Select]
set %group200 KWI_AAA_BBB_ETC

finditem KWI C_ ;example
event property #findid
set %nametotal 200 ;ommited the math that came up with value for simplicity sake
IF #FINDTYPE in %group%nametotal ; <---- brainfart here, I don't want to add anything to the group, only check against %group200
display ok %nametotal is accurate

I know the item type values in %group200 but will not know the %nametotal in advance and I want it to check on the group that corresponds with the %nametotal only. Hope that makes sense
« Last Edit: January 29, 2017, 06:30:06 PM by Gemviper »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Placing misc words into an array
« Reply #10 on: January 29, 2017, 06:42:45 PM »
0
Oh, are you trying to build the variable "%group200"?

If so, this bit of test code might help:

Code: [Select]
set %group200 test
set %nametotal 200
set %val % . group . %nametotal
display ok %val

stop

Run that and see if it does what you want.
« Last Edit: January 29, 2017, 06:46:36 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #11 on: January 29, 2017, 06:53:14 PM »
0
Bingo. With php you can print the literal of any variable within the code itself, my brain was stuck trying to do the same here, lol.

Thanks TM.
« Last Edit: January 29, 2017, 07:00:08 PM by Gemviper »

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • 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: Placing misc words into an array
« Reply #12 on: January 29, 2017, 06:58:13 PM »
0
Yeh, EUO operator precedence rules are a bit wonky.  In all honesty, when I have to use the "," and "." operators, I generally write a bit of sample code to be sure they are executing in the correct order.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline GemviperTopic starter

  • Sr. Member
  • *
  • Posts: 481
  • Activity:
    0%
  • Reputation Power: 0
  • Gemviper hides in shadows.
  • Respect: +57
  • Referrals: 2
    • View Profile
Re: Placing misc words into an array
« Reply #13 on: January 29, 2017, 06:59:49 PM »
0
edit: my bad, it works... I had another brain fart. Time for bed I think.

Thanks TM
« Last Edit: January 29, 2017, 07:09:08 PM by Gemviper »

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: Placing misc words into an array
« Reply #14 on: February 05, 2017, 03:32:19 AM »
0
What is it that you're doing, Gemviper?

Tags: