• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Some problems seting string

Status
Not open for further replies.
Level 7
Joined
Jan 29, 2010
Messages
213
SOLVED


Hi all, I have a problem here with setting strings.
Here some examples:
  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(0)))))
I cant understand why when Im setting simple text or number it isn't working, but when Im setting number with Integer A I get it working. Is that is some kind of we bug?
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Hi all, I have a problem here with setting strings.
Here some examples:
  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(0)))))
I cant understand why when Im setting simple text or number it isn't working, but when Im setting number with Integer A I get it working. Is that is some kind of we bug?

Could you perhaps show the entire trigger and tell us which save/load code system your using? Or are you using a custom made one by yourselve?
 
Level 7
Joined
Jan 29, 2010
Messages
213
Im trying to make my own one save/load system only with numbers (conwerting letters to numbers)
Here's trigger:
  • save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), 1, 1))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(0)))))
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), (Length of (Name of Hero[(Player number of (Triggering player))])), (Length of (Name of Hero[(Player number of (Triggering player))]))))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2)))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (-load + (String(save_code[(Player number of (Triggering player))])))
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • Set Hero[(Player number of (Triggering player))] = No unit
I added "game display" before actions (setting) and got that conditions are 100% working properly.
So the problem is in action.

  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + ((String(0)) + (String((Integer A)))))))
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
well, first of all get rid of Do Nothing as that's an extra, unneeded process that's run. Just leaving it blank is sufficient, the language is smart enough to know to do nothing.
 
Level 9
Joined
Nov 19, 2011
Messages
516
I don't understand this:

Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))

won't substring return a/b/c.. and what with A=52? (which is end of loop)
I suppose it will be null and if you hero name is not null then it won't work.

and this:

Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), 1, 1))

Are you sure that it will return anything? It's hard to help if you won't atach any map coz I can't see init. Try to debug this way to know if some variable is not ititialized:

  • save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), 1, 1))
      • quest - message <<hero_name>>}
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • quest - message <<string(integer A)>>}
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                  • quest - message <<save_code>>}
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(0)))))
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
                  • quest - message <<save_code>>}
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), (Length of (Name of Hero[(Player number of (Triggering player))])), (Length of (Name of Hero[(Player number of (Triggering player))]))))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2)))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (-load + (String(save_code[(Player number of (Triggering player))])))
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • Set Hero[(Player number of (Triggering player))] = No unit
 
Level 7
Joined
Jan 29, 2010
Messages
213
well, first of all get rid of Do Nothing as that's an extra, unneeded process that's run. Just leaving it blank is sufficient, the language is smart enough to know to do nothing.

I know that they arent needed at all, but I always get comments like: add "Do nothing" at the "else-actions" if theres no other actions...
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Check out this tutorial:

http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/essentials-tutorial-141191/

Read chapter g. and please confirm me that you are sure that it's got nothing to do with that.

Also: you might find some usefull tips in that tutorial ;)

EDIT: Sorry I haven't really got the time to look into this enormous trigger, have to create a report of 30 pages -,-"
I can only give some guidelines on analysis of your problem. I can't go into detail at this moment :(
 
Level 7
Joined
Jan 29, 2010
Messages
213
I don't understand this:

Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))

won't substring return a/b/c.. and what with A=52? (which is end of loop)
I suppose it will be null and if you hero name is not null then it won't work.

and this:

Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), 1, 1))

Are you sure that it will return anything? It's hard to help if you won't atach any map coz I can't see init. Try to debug this way to know if some variable is not ititialized:

  • save
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), 1, 1))
      • quest - message <<hero_name>>}
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • quest - message <<string(integer A)>>}
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                  • quest - message <<save_code>>}
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(0)))))
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
                  • quest - message <<save_code>>}
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), (Length of (Name of Hero[(Player number of (Triggering player))])), (Length of (Name of Hero[(Player number of (Triggering player))]))))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Set Hero_name[(Player number of (Triggering player))] = (Substring((Name of Hero[(Player number of (Triggering player))]), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2), ((Length of (Name of Hero[(Player number of (Triggering player))])) / 2)))
      • For each (Integer A) from 1 to 53, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_name[(Player number of (Triggering player))] Equal to (Substring(abc, (Integer A), (Integer A)))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Length of (String((Integer A)))) Equal to 2
                • Then - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String((Integer A))))))
                • Else - Actions
                  • Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (0 + (String((Integer A)))))))
            • Else - Actions
              • Do nothing
      • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (-load + (String(save_code[(Player number of (Triggering player))])))
      • Unit - Remove Hero[(Player number of (Triggering player))] from the game
      • Set Hero[(Player number of (Triggering player))] = No unit

From your comment as I can see u have not much expierence with variables and some of actions, pls do not go out of theme. I want this problem to be solved as fast as it can be. Later Ill explain everything...
 
Level 7
Joined
Jan 29, 2010
Messages
213
Level 9
Joined
Nov 19, 2011
Messages
516
You just didn't show init. Action that you pointed as wrong looks good. If it is bug you can try to avoid it seting var tmp and doing it this way:

tmp = 0;
Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(tmp)))));

If with Integer A works, this should too.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
You just didn't show init. Action that you pointed as wrong looks good. If it is bug you can try to avoid it seting var tmp and doing it this way:

tmp = 0;
Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(tmp)))));

If with Integer A works, this should too.

I don't think this got anything to do with parsing a variable to String() since
Integer A is a pre-defined global variable which does already work.
In theory using 0 or a variable would not make any difference.

D0W3R could you perhaps tell us where the variable String is defined, or is this just a conversion from integer to string?
 
Level 7
Joined
Jan 29, 2010
Messages
213
You just didn't show init. Action that you pointed as wrong looks good. If it is bug you can try to avoid it seting var tmp and doing it this way:

tmp = 0;
Set save_code[(Player number of (Triggering player))] = (Integer(((String(save_code[(Player number of (Triggering player))])) + (String(tmp)))));

If with Integer A works, this should too.

I tried setting with variable "Integer = 0" allready. The result is: [Not working...]
 
Level 7
Joined
Jan 29, 2010
Messages
213
I don't think this got anything to do with parsing a variable to String() since
Integer A is a pre-defined global variable which does already work.
In theory using 0 or a variable would not make any difference.

D0W3R could you perhaps tell us where the variable String is defined, or is this just a conversion from integer to string?

This is just conversation from Integer to string, I tried both writing "0", as Integer and as a sting, both of them isnt working.

If anyone want's to check map the download is here: save.w3x
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I tried setting with variable "Integer = 0" allready. The result is: [Not working...]

Have you tryed displaying Integer A already? to see which values it has?

Maybe it doesn't work because Integer A starts at 1 and not at 0?

EDIT: sorry bro, I just really have no time to fix this, still got 26 pages of text to write for my studies -,- How much I hate reports...

EDIT 2: try editing your posts before double posting, when moderators see this, they might ban you ^.o
 
Level 7
Joined
Jan 29, 2010
Messages
213
I just need simple fing like this:
set a = a+12
set a = a+0
set a = a+41
Display to all players txt: "a"

In game it would look like this:
12041
but now it looks like this:
1241
..........

Why isn't "0" wroking??? :(((
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
That might be because an integer that's 0 can be seen as being empty (don't know about Jass though...), however when converting 0 to a string this should work fine so that's what bothers me.

So your saying this does work when using Integer A but not when your setting it to 0??

So if your using Integer A it shows 12041 but with 0 it shows 1241?
Are you sure it's got nothing to do with how you concatenate the string?
 
Level 7
Joined
Jan 29, 2010
Messages
213
That might be because an integer that's 0 can be seen as being empty (don't know about Jass though...), however when converting 0 to a string this should work fine so that's what bothers me.

So your saying this does work when using Integer A but not when your setting it to 0??

So if your using Integer A it shows 12041 but with 0 it shows 1241?
Are you sure it's got nothing to do with how you concatenate the string?

Ugh
I tried changing number to 3 and it worked perfectly:
set a = a + 12
set a = a + 3
set a = a + 41
result:
12341
(LOL)

Sow how May I now to get number "0" is this possible?
Couse I need all letters to have 2 numbers.
The real problem is almost solved, thenks to Hashjie :)

Thread is solved!!! First number of integer can't be ZERO......... ><
So I just put big letters at the and of string. (cose names starting with capital letters...)


Thenks to all who spend so much time to such reckless thread :)
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Ugh
I tried changing number to 3 and it worked perfectly:
set a = a + 12
set a = a + 3
set a = a + 41
result:
12341
(LOL)

Sow how May I now to get number "0" is this possible?
Couse I need all letters to have 2 numbers.
The real problem is almost solved, thenks to Hashjie :)

Thread is solved!!! First number of integer can't be ZERO......... ><
So I just put big letters at the and of string. (cose names starting with capital letters...)


Thenks to all who spend so much time to such reckless thread :)

Hehe, not to mention I didn't really look at the trigger at all, nor did I go into the world editor to solve this :p
Want to know how I figured it out? If Integer = 0 is considered to be empty then that means when converting empty to string the string = ""

So now you need a way of showing 0 right?
Have you tryed creating a string variable which contains "0" and then use that instead of the actual 0 integer..?
This would mean you'd have to not convert integer to string and use the string variable which contains "0"...
Or just manually type in the 0 as a string instead of integer...
 
Level 9
Joined
Nov 19, 2011
Messages
516
Its becouse of you int() conversion. Try to concentrate all strings before convert.

Thats my idea:

change type of save_code to string.

Do you realy need to have it integer?

EDIT
If so then just check this:

length_of(string(save_code) mod 2 = 0

if false then just add "0" when showing.
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
Its becouse of you int() conversion. Try to concentrate all strings before convert.

Thats my idea:

change type of save_code to string.

Do you realy need to have it integer?

EDIT
If so then just check this:

length_of(string(save_code) mod 2 = 0

if false then just add "0" when showing.

In my previous post i gave a solution on how to add 0 as a string to the variable. Since converting an 0 integer becomes an empty string, the string needs to contain 0 instead of an integer. He should be abled to fix it but I haven't heared from him so far :)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Yes but looks like he can only check it at end of trgger, so he needs mod. By the way, maby he sloved it alredy?

He used capital letters to check for names of players inside his save/load code since adding 0 to the beginning means

01240 which is basically 1240 when being an integer. Your right he should've concatenated strings instead of using integers.

concentration is different then concatenation b.t.w. See the subtle difference ;)?

When concentrating on strings your focussing on them, when concatenating your merging them.
 
Status
Not open for further replies.
Top