SphereCommunity
strcmpi issue - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: strcmpi issue (/Thread-strcmpi-issue)



strcmpi issue - Mordaunt - 11-15-2012 10:35 AM

Looking at world gembits with spawn groups attached.

This:

if !(strcmpi(*<more1>*,*spawn*))

Never returns true while:

if (strcmpi(*<more1>*,*spawn*))

returns true even when it's not.

<more1> contains "spawn_<dungeonname><lvl>"
So with the wildcards it should technically return true if the word spawn appears under more1.
So why doesn't it?


RE: strcmpi issue - Skul - 11-15-2012 10:48 AM

try:
Code:
if (<serv.spawn.<more1>>) //true if it's a [spawn x] block
  //code
else
  //code
endif



RE: strcmpi issue - RanXerox - 11-15-2012 11:30 AM

The value in MORE1 is numeric... you cant compare a string to a numeric result.


RE: strcmpi issue - Mordaunt - 11-15-2012 11:51 AM

And yet returns a string on t_spawn_char gembits


RE: strcmpi issue - RanXerox - 11-15-2012 12:06 PM

Think of it like a defname which maps a name to a number... Things like spawn_orcs will resolve to a number of some sort... but spawn_* cannot be looked up.


RE: strcmpi issue - Ben - 11-15-2012 10:02 PM

I thought I told you this before... you can't use a wild card with strcmpi!
Have a look at this page http://wiki.sphere.torfo.org/index.php/Intrinsic_Functions

what you need is strmatch or strregex.


RE: strcmpi issue - Mordaunt - 11-15-2012 10:58 PM

Strmatch also doesn't function on it


RE: strcmpi issue - Ben - 11-16-2012 09:08 AM

IF (STRMATCH("*spawn*","<more1>")) should be what you are looking for.


RE: strcmpi issue - Skul - 11-16-2012 01:14 PM

well if <more1> is giving you some hex like number, why not resolve it?
Code:
if (strmatch(*spawn*,<serv.spawn.<more1>.defname>))



RE: strcmpi issue - Mordaunt - 11-16-2012 11:05 PM

It never was giving a number...
Ben's method resolved it anyway