Two problems

wilze

Active Member
Reaction score
3
Hi, my noobish ass is back with yet more problems. I did search the tutorial section before posting here.

Problem 1:
How do I refer to something a player writes in a chat message? For example a command in my map is, spawn X footmen. The X being a number from 01-12. Is it possible to set a variable to that number? Or do I have to make a trigger for all possible outcomes?

Problem 2: Is there any way to use player variables in the event - player events? Cause when I look at a player event it says there are no variables available.

Super thank you for any help! :D
 

Solu9

You can change this now in User CP.
Reaction score
216
Problem 1:
I am pretty sure you have to trigger all outcomes. But don't take my word for it.

Problem 2:
Your best bet is either A: A periodic timer which checks if a variable has changed, or B: Run the trigger in another trigger by using the "Action - Trigger - Run (Checking/Ignoring Conditions).

These are my best solutions/answers. I hope someone else can give you some better. But until then, try this out.
 

wilze

Active Member
Reaction score
3
For the first problem I actually want to be able to set a units life value with a chat command.

I think you would do this with substring.

Edit: Removed pic.

Could anyone tell me what's wrong with the trigger in the image above?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
You can post triggers directly. Select the trigger, right click and choose Copy As Text, then paste it here between [noparse]
Trigger:
[/noparse] tags.

Is there a space after "setlife" in your triggers and when you enter it? Because that string only has 7 characters, and if there isn't a space, you should be using (Substring ((Entered chat string), 1, 7)) in the conditions.

I would also suggest changing
Code:
(Substring ((Entered chat string), 9, 14))
to
Code:
(Substring ((Entered chat string), 9, (Length of (Entered chat string))))
 

wilze

Active Member
Reaction score
3
Thanks for your response, but it still doesn't work. I'm really confused :D

Anyway this is what I have now:

Trigger:
  • Set Life
    • Events
      • Player - Player 1 (Red) types a chat message containing setlife as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 8)) Equal to setlife
    • Actions
      • Set String_Value = (Real((Substring((Entered chat string), 9, (Length of (Entered chat string))))))
      • Unit Group - Pick every unit in Group_A and do (Unit - Set life of (Picked unit) to String_Value)


How do I make this work?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
You don't seem to have a blank space after "setlife", which means the string only has 7 characters. The condition should be
Trigger:
  • (Substring((Entered chat string), 1, 7)) Equal to setlife
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Could you upload your map to take a look? There doesn't seem to be any other problems in the trigger itself, maybe something else is interfering.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
The setlife command works now. I also added a single trigger to replace all your spawn triggers, Spawn General. I'm still confused as to your goals for this map, though.

Also, you don't clear your point variables after you use them. This can lead to major leaks later on. Always remember to clear your point variables if you don't intend to use them again. The following is the code to clear a variable named TempPoint:
Code:
call RemoveLocation (udg_TempPoint)
 

Attachments

  • RPExpriment Changed.w3x
    109.5 KB · Views: 116

wilze

Active Member
Reaction score
3
Thank you for your help.

I changed the numbers in your spawn trigger and got it working like I wanted it to. It only spawns up to 9 of each unit though. Here it is with the changes (only peasant):

Trigger:
  • Spawn General
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 5)) Equal to spawn
    • Actions
      • Set TempPoint_A = (Position of Spawner_A)
      • -------- Peasant --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 10, 16)) Equal to peasant
        • Then - Actions
          • Set Temp_Integer = (Integer((Substring((Entered chat string), 8, 9))))
          • Unit - Create Temp_Integer Peasant for Player 1 (Red) at TempPoint_A facing Default building facing degrees
        • Else - Actions


Now the setlife trigger does work but not like I want it to. It now changes the units current hp, yes. But I want it to change the base hp of the unit so that you can give a footman 10000 hp if you want. Is it possible?

And yet again, thank you so much.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
1). The line
Trigger:
  • Set Temp_Integer = (Integer((Substring((Entered chat string), 8, 9))))
should be
Trigger:
  • Set Temp_Integer = (Integer((Substring((Entered chat string), 8, (Length of (Entered chat string))))))
That's why the number appears at the end, so there's no limit to the number you want to spawn.

2). For that, I recommend this thread.

Also, bumping is only allowed 24 hours after the last response. :thup:
 

wilze

Active Member
Reaction score
3
Ahh sorry bout' the bump thing. I will read the rules over again.

Anyhow I changed the thing you told me to change, but if i type spawn 25 peasant it spawns 5 like it responds to the second number (5). I also tried: spawn 25 peasant (two spaces) but then it spawned nothing.

Trigger:
  • Spawn X Y
    • Events
      • Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 5)) Equal to spawn
    • Actions
      • Set TempPoint_A = (Position of Spawner_A)
      • -------- Peasant --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 10, 16)) Equal to peasant
        • Then - Actions
          • Set Temp_Integer = (Integer((Substring((Entered chat string), 8, (Length of (Entered chat string))))))
          • Unit - Create Temp_Integer Peasant for Player 1 (Red) at TempPoint_A facing Default building facing degrees
        • Else - Actions

And thanks for linking that thread. Will check it out.

Edit: setlife works now with the system from that thread. Thank you bro!
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Looks like I forgot to mention one thing. The number of units to spawn has to appear at the end of the string, while the unit-type appears in the middle, like so:
Code:
spawn peasant 25 -- 25 peasants
spawn footman 9 -- 9 footmen
spawn gryphonrider 289 -- 289 gryphon riders
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top