Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-12-2003, 12:57 AM
MrGannondorf MrGannondorf is offline
Teh Lunpa
Join Date: Apr 2002
Location: usa, alas
Posts: 395
MrGannondorf is on a distinguished road
Send a message via AIM to MrGannondorf
Question 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)
__________________
Reply With Quote
  #2  
Old 11-12-2003, 01:02 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #3  
Old 11-12-2003, 01:11 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I guess you can try something like:

NPC Code:

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



Or something along the means of that.
Reply With Quote
  #4  
Old 11-12-2003, 01:15 AM
MrGannondorf MrGannondorf is offline
Teh Lunpa
Join Date: Apr 2002
Location: usa, alas
Posts: 395
MrGannondorf is on a distinguished road
Send a message via AIM to MrGannondorf
woah, nifty! thanks alot! I realy apreciate it.
__________________
Reply With Quote
  #5  
Old 11-12-2003, 01:19 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
use if (startswith(#w,-)) { i think it was that
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #6  
Old 11-12-2003, 01:37 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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))
Reply With Quote
  #7  
Old 11-12-2003, 02:18 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #8  
Old 11-12-2003, 04:20 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
startswith(partstr,str)

You people've got it backwards.
Reply With Quote
  #9  
Old 11-12-2003, 04:43 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
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?
Reply With Quote
  #10  
Old 11-12-2003, 06:01 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #11  
Old 11-15-2003, 01:52 AM
MrGannondorf MrGannondorf is offline
Teh Lunpa
Join Date: Apr 2002
Location: usa, alas
Posts: 395
MrGannondorf is on a distinguished road
Send a message via AIM to MrGannondorf
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)
__________________
Reply With Quote
  #12  
Old 11-15-2003, 04:20 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to 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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #13  
Old 11-15-2003, 04:24 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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
Reply With Quote
  #14  
Old 11-15-2003, 04:25 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
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?
__________________
Reply With Quote
  #15  
Old 11-15-2003, 04:38 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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?
__________________
Reply With Quote
  #16  
Old 11-15-2003, 06:30 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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.
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
Reply With Quote
  #17  
Old 11-15-2003, 06:55 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Then it would be better to figure out how it works than to use such an inefficient solution.
__________________
Reply With Quote
  #18  
Old 11-15-2003, 09:05 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
you use
if (strcontains(#s(yourstring),partstring))
yes?
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #19  
Old 11-15-2003, 04:33 PM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
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.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #20  
Old 11-15-2003, 05:25 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
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.
__________________
Reply With Quote
  #21  
Old 11-16-2003, 01:24 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
Quote:
Originally posted by Kaimetsu


Chad wasn't talking to the creator of the thread.
Allright, my appoligies.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:17 PM.


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