Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   help with parseing? (https://forums.graalonline.com/forums/showthread.php?t=49100)

MrGannondorf 11-12-2003 12:57 AM

help with parseing?
 
I'm working on a script that involves checking the current weapon of the player, and some other weapons based on the index of the current weapon. The only problem is, weaponscount apears to include the -"hidden" weapons in its count, as do they have thier own weapons index. My script doesn't like hidden weapons.
To what I know there isn't any equivalent of visibleweaponscount or such, so my solution involves checking the first character of the weapon name to figure out if its hidden or not, wich leads me to my scripting problem:

I can't get the engine to parse/check the first character :(
I've tried the statswith flag, tokenize2, etc, but all to no avail. (and I'm not gonna rename every weapon for the sake of compatibility, thank you very much).

any helpfull ideas? (a minor emphisis on 'helpfull' and 'ideas', btw)

ForgottenLegacy 11-12-2003 01:02 AM

Use #e(startindex,length,string);
NPC Code:

message #e(0,5,#n);


That would make the NPC say the first 5 letters of your name. Spaces also count as letters.

DustyPorViva 11-12-2003 01:11 AM

I guess you can try something like:

NPC Code:

if (strequals(#e(0,1,#w(i)),-))



Or something along the means of that.

MrGannondorf 11-12-2003 01:15 AM

woah, nifty! thanks alot! I realy apreciate it.

mhermher 11-12-2003 01:19 AM

use if (startswith(#w,-)) { i think it was that

Loriel 11-12-2003 01:37 AM

Quote:

Originally posted by mhermher
use if (startswith(#w,-)) { i think it was that
Agreed pretty much, #e is kind of overkill here. Although you need to reverse the order of the parameter so it is startswith(-,#w(i)) :)

DustyPorViva 11-12-2003 02:18 AM

Quote:

Originally posted by Loriel

Agreed pretty much, #e is kind of overkill here. Although you need to reverse the order of the parameter so it is startswith(-,#w(i)) :)

Maybe, but sometimes it bugs for me. That's why I don't use it anymore.

Lance 11-12-2003 04:20 AM

startswith(partstr,str)

You people've got it backwards.

haunter 11-12-2003 04:43 AM

Quote:

Originally posted by Lance
startswith(partstr,str)

You people've got it backwards.

Yeah, why it was inversed from strcontains is beyond me. @_@ Any explination?

Dach 11-12-2003 06:01 AM

Quote:

Originally posted by haunter


Yeah, why it was inversed from strcontains is beyond me. @_@ Any explination?

to confuse newbie scripters? hehe, crap I hope that doesn't make me a newb scripter...

but yeah, I used that kinda thing in the weaponselect systems i've made and it works just fine

MrGannondorf 11-15-2003 01:52 AM

I wonder if startswith works anymore. regardless, I like #e better. Why? I can get it to work ^^

The script is still broken, but for different reasons now. (for the inquisitive, the reason is lazyness)

ForgottenLegacy 11-15-2003 04:20 AM

I have not used strcontains much anymore, I use a #T on a #e, in a loop that checks every letter of the message.

Lance 11-15-2003 04:24 AM

Quote:

Originally posted by ForgottenLegacy
I have not used strcontains much anymore, I use a #T on a #e, in a loop that checks every letter of the message.
Overkill? Using indexof suffices

Kaimetsu 11-15-2003 04:25 AM

Quote:

Originally posted by ForgottenLegacy
I have not used strcontains much anymore, I use a #T on a #e, in a loop that checks every letter of the message.
Why?

ZeLpH_MyStiK 11-15-2003 04:38 AM

Quote:

Originally posted by Kaimetsu


Why?

Yes, why? Wouldn't it be easier to use just one command, strcontains, instead of putting #T or #e in a loop?

ForgottenLegacy 11-15-2003 06:30 AM

Quote:

Originally posted by ZeLpH_MyStiK

Yes, why? Wouldn't it be easier to use just one command, strcontains, instead of putting #T or #e in a loop?

Because for some reason, strcontains does not work for me, nor do I trust it with most things.

Kaimetsu 11-15-2003 06:55 AM

Then it would be better to figure out how it works than to use such an inefficient solution.

Dach 11-15-2003 09:05 AM

you use
if (strcontains(#s(yourstring),partstring))
yes?

mhermher 11-15-2003 04:33 PM

Quote:

Originally posted by Dach
you use
if (strcontains(#s(yourstring),partstring))
yes?

No.
strcontains is if the partstring is existant at all... what he need is that if the partstring is the start of the string..

therefore, if(startswith(-,#w(i)) { }
is the correct way to do.

And yes i do suck on scripting.

Kaimetsu 11-15-2003 05:25 PM

Quote:

Originally posted by mhermher
No.
strcontains is if the partstring is existant at all... what he need is that if the partstring is the start of the string..

Chad wasn't talking to the creator of the thread.

mhermher 11-16-2003 01:24 AM

Quote:

Originally posted by Kaimetsu


Chad wasn't talking to the creator of the thread.

Allright, my appoligies.


All times are GMT +2. The time now is 11:44 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.