HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Substring trouble

06-26-2007, 02:10 AM#1
Castlemaster
I'm trying to make a unique item system that will only allow one weapon, one shield etc. For the portion where it checks to see if a unit has an item already, I decided that the item type would be in the name as well, and just check for doubling via a string comparison rather than a gaggle of if/then/else statements

Problem is that it won't read substrings correctly.
Take the following function
Trigger:
Collapse Events
Unit - A unit Acquires an item
Conditions
Collapse Actions
Game - Display to (All players) the text: (Substring((Name of (Item being manipulated)), ((Integer((Name of (Item being manipulated)))) - 9), ((Integer((Name of (Item being manipulated)))) - 3)))
If I use this in conjunction with the following names
Champion's Chain Guard - [|c00ffd700Armor|r]
Gladiator's Leather Tunic - [|c00ffd700Armor|r]
Pit Fighter's Cloth Jerkin - [|c00ffd700Armor|r]
Then the following function should give me "Armor" for the string. Instead it gives me the full name plus something like "BU@" or "tu@" anyone know what's going on or if this is a viable method for item exclusion?

Thanks ahead of time
06-26-2007, 03:49 AM#2
Earth-Fury
(Integer((Name of (Item being manipulated)))) - 9)

Is it just me, or do you want Length of (Name of (Item being manipulated)) ? (its been a while since i did GUI)
06-26-2007, 12:38 PM#3
Castlemaster
Ah, so I was using the wrong command. I suspected that. I would imagine that "length of string" would be an integer value. Do you know where I would find this command in GUI, (or the JASS command since I'm trying to teach it to myself).

Thanks for the help.
06-26-2007, 01:28 PM#4
Earth-Fury
Collapse JASS:
native StringLength takes string s returns integer

Thats a native decliration. (a function implimented internally in the WC3 engine, but which still requires a definition for a JASS script to be able to use it)

as for GUI, should be pretty easy to find with a little bit of looking.
06-26-2007, 01:41 PM#5
blu_da_noob
It's near the top of the list. It's called 'String Length'.