priest170234
New Member
- Reaction score
- 0
Hi all! I am new to JASS and a new member to this forum
Apparently, i started learning JASS just yesterday. So I might be unsure of almost everything.
Anyways, I am having a little problem with this:
Can I use a global variable for this function? I tried but to no luck.
This is my whole trigger:
Global variables:
udg_RandomString[1] = .......
udg_RandomString[2] = .......
udg_RandomInteger = Random Integer between 1 and 2
Help would be appreciated
EDIT (I solved it! With help from Laiev, DioD and Troll-Brain):
These triggers is to enable those maps that require to think what's the password. (Like in Impossible Map, if you played it)
Your unit enters the region, creates a random string as password. This password is 'hidden' inside the quest description. (If the player is smart to think of that he would see the password). Then the player have to type that password in order to advance to the next stage.
I didn't use GUI because it doesn't allow me to do so. (Add the Player types a string "" as an exact match)
TRIGGER ONE [Global Declaration]
TRIGGER TWO[PW]
TRIGGER THREE [p]
Apparently, i started learning JASS just yesterday. So I might be unsure of almost everything.
Anyways, I am having a little problem with this:
JASS:
TriggerRegisterPlayerChatEvent( gg_trg_TRIGGER, Player(0), udg_STRING, true)
Can I use a global variable for this function? I tried but to no luck.
This is my whole trigger:
Global variables:
udg_RandomString[1] = .......
udg_RandomString[2] = .......
udg_RandomInteger = Random Integer between 1 and 2
JASS:
function Trig_TRIGGER_Actions takes nothing returns nothing
------ALL MY CODE HERE
endfunction
//===========================================================================
function InitTrig_TRIGGER takes nothing returns nothing
set gg_trg_TRIGGER = CreateTrigger( )
set udg_STRING = udg_RandomString[udg_RandomInteger]
call TriggerRegisterPlayerChatEvent( gg_trg_TRIGGER, Player(0), udg_STRING, true )
call TriggerAddAction( gg_trg_TRIGGER, function Trig_TRIGGER_Actions )
endfunction
Help would be appreciated
EDIT (I solved it! With help from Laiev, DioD and Troll-Brain):
These triggers is to enable those maps that require to think what's the password. (Like in Impossible Map, if you played it)
Your unit enters the region, creates a random string as password. This password is 'hidden' inside the quest description. (If the player is smart to think of that he would see the password). Then the player have to type that password in order to advance to the next stage.
I didn't use GUI because it doesn't allow me to do so. (Add the Player types a string "" as an exact match)
TRIGGER ONE [Global Declaration]
JASS:
scope global initializer init
globals
string STRING
integer RANDOM_INTEGER
string array RANDOM_STRING[2]
endglobals
private function init takes nothing returns nothing
set RANDOM_STRING[0] = "lol"
set RANDOM_STRING[1] = "lolol"
set RANDOM_INTEGER = GetRandomInt(0,1)
set STRING = RANDOM_STRING[RANDOM_INTEGER]
endfunction
endscope
TRIGGER TWO[PW]
JASS:
scope pw initializer onInit
private function pw_Conditions takes nothing returns boolean
if ( not ( GetEnteringUnit() == udg_ChosenHero ) ) then
return false
endif
return true
endfunction
function pw_Actions takes nothing returns nothing
call DisableTrigger( GetTriggeringTrigger() )
call IssueImmediateOrder( udg_ChosenHero, "stop" )
call CreateQuestBJ( bj_QUESTTYPE_REQ_DISCOVERED, "PASSWORD", ( "The password is : " + STRING ), "ReplaceableTextures\\WorldEditUI\\Editor-Random-Unit.blp" )
call EnableTrigger(gg_trg_p)
call DisplayTextToForce( GetPlayersAll(), STRING )
call DestroyTrigger(GetTriggeringTrigger())
endfunction
//===========================================================================
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterEnterRectSimple( t, gg_rct_PasswordQuest )
call TriggerAddCondition( t, Condition( function pw_Conditions ) )
call TriggerAddAction( t, function pw_Actions )
endfunction
endscope
TRIGGER THREE [p]
JASS:
function Trig_p_Actions takes nothing returns nothing
call DisableTrigger( GetTriggeringTrigger() )
set udg_TempPoint[1] = GetRectCenter(gg_rct_PaswordQuestTerain)
call SetTerrainTypeBJ( udg_TempPoint[1], 039;Ydrt039;, -1, 1, 0 )
call DestroyQuest( GetLastCreatedQuestBJ() )
call DisplayTimedTextToForce( GetPlayersAll(), 5.00, "Correct" )
call RemoveLocation(udg_TempPoint[1])
endfunction
//===========================================================================
function InitTrig_p takes nothing returns nothing
set gg_trg_p = CreateTrigger( )
call TriggerRegisterPlayerChatEvent(gg_trg_p, Player(0), STRING, true)
call TriggerAddAction( gg_trg_p, function Trig_p_Actions )
endfunction