TriggerHappy
...
- Reaction score
- 341
vJASS Resources for GUI users
TriggerHappy187
Prelude
Many GUI users tend to ask for systems, spells, snippets or any resource made via triggers.
Now many of these resources have already been made, but they were created in vJASS. GUI'ers they to think 'I don't know vJASS so I can't use this'. That is totally wrong.
If you are one of these people who don't know vJASS but think you need to in order to be able to use a lot of systems written in it, then this tutorial is for you.
Before we get started, I want to clarify that there are systems written in vJASS made specifically for people who use vJASS. Things like custom events for example.
Requirements/Importing
When you see a vJASS resource there are generally requirements.
One requirement is always the same, you need to download Jass New Gen Pack.
It contains a tool called JassHelper which parses vJASS so it's required.
Next it may require external systems. Your going to need to copy those systems into your map. Once all that is done you can copy the script into your map.
This part is important, whenever you have vJASS in your map you must save before you test it (every time).
Configuring
The last part is configuring the code to fit your needs. Any good vJASS resource will contain a globals block. You will be able to edit the values in that block to fit your needs.
Below is an example system. It allows a player to type -kick # and a player will be kicked.
JASS:
library Kick initializer onInit
globals
private constant string KICK_STRING = "-kick " // the kick string
private constant boolean SHOW_SCORE_SCREEN = true // Show score screen for player?
private constant player HOST = Player(0) // player 1 is player 0 in jass
endglobals
private function Actions takes nothing returns boolean
local string s = GetEventPlayerChatString()
local player p = Player(S2I(SubString(s, StringLength(KICK_STRING), StringLength(s)))+1)
if p != null then
if GetLocalPlayer() == p then
call EndGame(SHOW_SCORE_SCREEN)
endif
endif
return false
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, HOST, KICK_STRING, false)
call TriggerAddCondition(t, Condition(function Actions))
endfunction
endlibrary
Looks confusing, don't it? Well it's not, the only part you need to worry about is this;
JASS:
As of now if the HOST (Player 1) types -kick # then a player will be removed from the game. Now what if you wanted the keyword to be -boot #?
Easy, just change
JASS:
private constant string KICK_STRING = "-kick " // the kick string
JASS:
private constant string KICK_STRING = "-boot " // the kick string
You usually only need to modify anything after the equal sign.
The same goes for the rest of the configurables, usually there will be a comment next to them explaining what they do.
Once you have modified everything to your needs, save the map and your system should work.