Stealing double values

Posted by Kelson on Sun 08 Dec 2002 01:43 AM — 3 posts, 13,967 views.

#0
Magnum once made a database program for saving his equipment sets. Using his work (and very, very heavily modifying it...ie, using only his notecolor function now) I made a vbscript plugin that takes all the characterists of an item spit out from the mud. It takes this data, checks if the file exists first (if it does it adds a few of the changing variables to it) and if it doesn't it makes a .txt file. The problem comes with lines with two variables in it. For instance:

Value: 5 gold 3 silver Level: 5

Currently, I have a work around in place. Using the file-system object, I create a .txt file, write the entire line in, then selectively read and store parts of the line, ending up by deleting the file. Since I can't double up triggers for the line (which is how I'm capturing information).

The system, basically, match Value: * and save in value_object. Then write value_object to blerb.txt. Read first part of file then store in value then read second part (level part) and store in level.

If someone could tell me how to double up the take without doing this, it'd be appreciated.

(btw, actually matches, Value: * Level: * and prints %1 %2)
USA #1
Well... Since I assume it could be anything from:

Value: 5 gold 3 silver Level: 5

to

Value: 5 gold Level: 5

to

Value: 5 gold 3 silver 1 copper Level: 5

this is not terribly easy. There is no separator to easilly tell which parts belong to which item.. However.. One option would be something like:

dim temp
temp = split(wildcard(1)," ")

Now as to what this does is, if you match on a line like 'Value: 5 gold 3 silver Level: 5' and it returns two wildcards>

wildcard 1: 5 gold 3 silver
wildcard 2: 5

The above code split the first wildcard into an array:

temp(0) = 5
temp(1) = gold
temp(2) = 3
temp(3) = silver

You can then step through the array to get the actually amounts like:
gold = 0
silver = 0
for count = 0 to ubound(temp)
  if isnumeric(temp(count)) then
    tval = temp(count)
  else
    if temp(count) = "gold" then
      gold = tval
    else if temp(count) = "silver" then
      silver = tval
    end if
  end if
next
Amended on Sun 08 Dec 2002 06:27 PM by Shadowfyr
Australia Forum Administrator #2
Quote:

Since I can't double up triggers for the line ...


What do you mean by that? You can have more than one trigger, if you check the "keep evaluating" flag. Then you can have multiple triggers do a pass over a single line.