• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Sub string issue

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Hello. I was trying to detect if a part of string A matches string B. Somehow it bugs a lot.

  • Settings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set colors[1] = |c00FF0303
      • Set commands[1] = [red]
      • Set endCommand = [/end]
      • Set count = 1
JASS:
hook TransmissionFromUnitWithNameBJ x
  • System
    • Events
    • Conditions
    • Actions
      • Custom script: endfunction
      • Custom script: function x takes force toForce, unit whichUnit, string unitName, sound soundHandle, string message, integer timeType, real timeVal, boolean wait returns nothing
      • Custom script: local string udg_message = message
      • For each (Integer message_loop) from 1 to (Length of message), do (Actions)
        • Loop - Actions
          • For each (Integer command_loop) from 1 to count, do (Actions)
            • Loop - Actions
              • For each (Integer character_loop) from 1 to (Length of commands[command_loop]), do (Actions)
                • Loop - Actions
                  • Set s1 = (Substring(message, message_loop, message_loop))
                  • Set s2 = (Substring(commands[command_loop], character_loop, character_loop))
                  • Game - Display to (All players) the text: s1
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • s1 Equal to s2
                    • Then - Actions
                      • Game - Display to (All players) the text: ss
                    • Else - Actions
  • test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Cinematic - Send transmission to (All players) from Paladin 0001 <gen> named Chaos: Play No sound and display hej. Modify duration: Set to 2.00 seconds and Don't wait
eb649193d262b41f36f73b1f9f36cfaa.png


None of these characters exist in the string "hej"

it should look like:
h
e
j
 
Last edited:
Level 12
Joined
Oct 16, 2010
Messages
680
  • Game - Display to (All players) the text: ss
i don't really get why are u do this as you do but if ss is a variable then you never set it
or you wanted s2?

  • Custom script: local string udg_message = message
and here u made a local named udg_message :/ u wanted set udg_message = message

Edit: and i think you shouldn't check equivalency char by char.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
ss is just raw data to see if I get pass the condition.

also that local variable is not a fail. It works. If I use:
  • Game - Display to (All players) the text: message
it displays "hej"

edit: as far as I know, I need to.

if I got:

string a = "asklosda"
string b = "box"

in order to check if string b contains string a i need to check every character.
 
Level 12
Joined
Oct 16, 2010
Messages
680
hmm I looked in it a bit and it seems it works like GUI predefined strings are locally allocated and saved as TRIGSTR_XXX. Not sure if that is the problem that bugs with substring, but try this.

save the actual message (hej) in a local udg_variable before using it in the Transmission. maybe that prevents the saving of the TRIGSTR
 
Status
Not open for further replies.
Top