• 🏆 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!

Custom Scripts to compare Presets with a variable?

Status
Not open for further replies.
Level 3
Joined
Nov 3, 2008
Messages
44
SOLVED

Hey, there.
Right now I am playing around with generalizing my command-system. Here is a part of it:

  • Command = "" <String[10]>
  • Variable - Set Command[1] = "minerals"
  • Variable - Set Command[2] = "vespene"
  • Trigger:
    • Events
      • Game - Player Any Player types a chat message containing "-", matching Partially
    • Local Variables
      • A = 0 <Integer>
    • Conditions
    • Actions
      • General - For each integer A from 1 to 2 with increment 1, do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Substring((Entered chat string), 2, ((Length of Command[A]) + 1))) == Command[A]
            • Then
              • General - If (Conditions) then do (Actions) else do (Actions)
                • If
                  • Or
                    • Conditions
                      • A == 1
                      • A == 2
                • Then
                  • Player - Modify player (Triggering player) Minerals: Set To (Integer((Substring((Entered chat string), ((Length of Command[A]) + 2), (Length of (Entered chat string))))))
                • Else
            • Else
With this I want to avoid changing the substring locations everytime I change the commands.

My problem/question is wether you people know a possibility to get the preset "Minerals" replaced by a string, so I can use the Loop-A to define the kind of ressource I want to modify.
The only way to realize that is using a custom script and I'm totally new to it.
If you can post some good tutorials or even such a script, do so please! :psmile:

Uhm... Nvm, Im doing it this way. *lol*

  • Trigger:
    • General - If (Conditions) then do (Actions) else do (Actions)
      • If
        • A == 1
      • Then
        • Player - Modify player (Triggering player) Minerals: Set To (Integer((Substring((Entered chat string), ((Length of Command[A]) + 2), (Length of (Entered chat string))))))
      • Else
        • General - If (Conditions) then do (Actions) else do (Actions)
          • If
            • A == 2
          • Then
            • Player - Modify player (Triggering player) Vespene: Set To (Integer((Substring((Entered chat string), ((Length of Command[A]) + 2), (Length of (Entered chat string))))))
          • Else
How to close/mark a thread as solved?
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
To mark a thread as solved you just have to say it was solved. Near the top is recommended to avoid people reading unnescescarilly but the bottom also works.

For your knowledge, the resource constants have these values...
const int c_playerPropMinerals = 0;
const int c_playerPropVespene = 1;
const int c_playerPropTerrazine = 2;

As such A-1 as the input for the resource type would give you exactly what you are after. You would logically then need to check that it is in the correct range (and if not, then do not run code).
 
Last edited:
Level 3
Joined
Nov 3, 2008
Messages
44
To mark a thread as solved you just have to say it was solved. Near the top is recommended to avoid people reading unnescescarilly but the bottom also works.

For your knowledge, the resource constants have these values...
const int c_playerPropMinerals = 0;
const int c_playerPropVespene = 1;
const int c_playerPropTerrazine = 2;

As such A-1 as the input for the resource type would give you exactly what you are after. You would logically then need to check that it is in the correct range (and if not, then do not run code).

Thanks, Dr.
Edited and done. :)

@ Rispetto: Forgive me, but I will add the [Solved] at the top of the post and not quote you, alright? But I make it green and gigantic... and i could give you credits for it. ;)
 
Status
Not open for further replies.
Top