ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: _C2_ on November 16, 2012, 11:53:24 AM

Title: strings
Post by: _C2_ on November 16, 2012, 11:53:24 AM
checked the tutorials here and there wasn't one... checked easy uo and they were too simple.

how do i separate lines in a string after i event property a multi-line item.  id love to just make a string out of the first line only.

is there some way to do it with the $?
Title: Re: strings
Post by: TrailMyx on November 16, 2012, 03:12:53 PM
you can use my split string subs for that.

http://www.scriptuo.com/index.php?topic=1101.msg8823#msg8823

Then you just use the "$" as the delimiter:

Code: [Select]
set %test_string THIS$IS$A$TEST$
gosub TM_SplitString %test_string $
gosub TM_SubstringCount
set %count #RESULT - 1
for %i 0 count
{
  gosub TM_GetIndex %i
  display OK %i , #SPC , #RESULT
}
stop
Title: Re: strings
Post by: NObama on November 16, 2012, 03:18:37 PM
TM HAS A SUB FOR EVERYTHING!

(It's like he seeds these threads so we can boggle at his awesomeness)
Title: Re: strings
Post by: _C2_ on November 16, 2012, 03:23:51 PM
alright... I'll check it out.  first glance it makes my head hurt.  there isnt a simple command to take character one up to the $ i guess.
Title: Re: strings
Post by: freddy on November 16, 2012, 06:05:24 PM
check out my snippet here: http://www.scriptuo.com/index.php?topic=8886.msg77353#msg77353

you would do something like this:

event property %itemid
gosub separate_string #property $ ($ is the delimiter in this situation - my sub can handle any character as the delimiter)

%return1 would be the first line of text before the $


Edit:i failed to read trailmyx's post. looks like our subs do the same thing
Title: Re: strings
Post by: Guinness on November 16, 2012, 10:00:06 PM
lol....Honestly, why else would he have this site if it were not for his *Flashing AWESOMENESS Flashing*


Brought to you by
Twinkies
Oh *bleep*
Bye Bye Twinkies
Title: Re: strings
Post by: manwinc on November 17, 2012, 07:43:22 AM
Event Property (id)
Str Pos #Property $ 1
Str Left #Property #strres
Display #Strres
Halt
Title: Re: strings
Post by: _C2_ on November 17, 2012, 12:59:45 PM
Event Property (id)
Str Pos #Property $ 1
Str Left #Property #strres
Display #Strres
Halt

That was the basis of what I needed to learn.  That wasn't in the tutorials that I read.  Thank you everyone!
Title: Re: strings
Post by: manwinc on November 17, 2012, 01:27:20 PM
He asked how to do it. NOT HOW TO USE EVERYONE ELSES SUBS TO DO IT! *Cries*

Lol
Title: Re: strings
Post by: TrailMyx on November 17, 2012, 01:42:53 PM
heh, yeh I didn't catch that when I first read it for some reason.... 
Title: Re: strings
Post by: Endless Night on November 17, 2012, 01:54:04 PM

I guess its to late to throw my version of these subs out thier then .. dam .. late for the party once again.
Title: Re: strings
Post by: manwinc on November 17, 2012, 02:01:12 PM
ahahahaha, Its good to see the Community whipping out what they've got whenever someone asks for help. Wait.....
Title: Re: strings
Post by: _C2_ on November 17, 2012, 08:54:05 PM
Yeah, I am psyched so many folks jumped in.  I need to learn strings in more depth.  i've only used them in basic form.  thx again all!
Title: Re: strings
Post by: manwinc on November 17, 2012, 10:52:41 PM
Yeah,


str len (String)
-> sets #Strres to the Length of the String

str Count (String) (Sub String)
-> sets #Strres to the # of Sub Strings in the String ; so if you Did a count of the # of "resist" in The property of  Most armor, it would return 5

Str Pos (String) (Sub String) (Index)
-> Sets #Strres to the Numeric Location of the Indexed Sub String.
Str Pos _This_ _ 2 ; Would Find the Location of the Second _ in the String "_This_ "
Str Pos is Usually used in Conjunction with  Str Count to determine how many instances or to Increment the Index's

Str Left (String) (Length)
-> Sets #Strres to the Part of the String from 1 to "Length"
Str Left This 2
-> #Strres = Th


Str Right (String) (Length)
-> Sets #Strres to the part of the String from the End in (Length) distance
Str Right This 2
-> #Strres = is

Str Mid (String) (Start) (Length)
-> Sets #Strres to the Part of the string from the Start to Start + Length
Str Right and Str Left become obsolete as you learn to use Str Mid

Str Lower (String)
-> Turns Penguins into llamas. Or Something like that... Honestly Never Used it. I'd Imagine it Forces everything to Lower Case

Str Ins (String) (Sub String) (Start)
-> Inception of a string inside a string.....

Str Del (String) (Start) (Length)
-> Sets #Strres to the Leftover String after you Chop it into Pieces

Those are all the Commands Described in a fairly basic way....

Some Handy Pointers when it comes to handling Property Strings.

#Property isn't the same as Journal. You don't have _ instead of Spaces. Instead you have actual Spaces. So Physical Resist becomes Physical , #Spc , Resist in EUO.

Learn to Use Str Count, Str Pos, Str Mid and you can Pull just about any Data you want out of a string.
Title: Re: strings
Post by: NObama on November 18, 2012, 12:15:14 PM
Also:

Str Hokey Pokey
Where you turn it all around
Title: Re: strings
Post by: Endless Night on November 18, 2012, 02:18:38 PM
ahahahaha, Its good to see the Community whipping out what they've got whenever someone asks for help. Wait.....

that is one suspect statement.