brand new jass beginner +rep for help

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
hi i was following this tutorial and it just isnt working, the text is supposed to display hello for 30 seconds but i cant seem to get it to work, i know this is a totally newbish question but i am serious about learning jass, i have been using gui up until now and can do almost anything mui in it but i want to broaden what im capable of doing, heres my trigger:

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 call DisplayTimedTextToForce(GetPlayersAll(), 30, "Hello")
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
 

tooltiperror

Super Moderator
Reaction score
231
Is it not displaying anything, or is it giving you a syntax error?
 

Dirac

22710180
Reaction score
147
His trigger never fires, you must add an event to it.
If you want the text to be displayed at init just do
JASS:
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    call DisplayTimedTextToForce(GetPlayersAll(), 30, "Hello")
endfunction
Also, are you using JNGP v1.5 with JassHelper? Makes JASS a lot more understandable / friendly
 

tooltiperror

Super Moderator
Reaction score
231
>His trigger never fires, you must add an event to it.
Triggers set to run at init are run at init.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
the only syntax error says that gg_trg_untitled_trigger_001 hasnt been declared as a variable, but i thought you didnt have to declare a variable for the trigger, that was like that when i converted it to custom text

using newgen

EDIT: Dirac cant +rep you cuz i have to spread it around, but it still doesnt work
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
This happens because trigger "gg_trg_Untitled_Trigger_001" is being declared after your code:
See the steps of jass coding evolution from noob to pro
JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
 call DisplayTimedTextToForce(GetPlayersAll(), 30, "Hello")
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction


JASS:
function Display_Actions takes nothing returns nothing
 call DisplayTimedTextToForce(GetPlayersAll(), 30, "Hello")
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    local trigger tt = CreateTrigger(  )
    call TriggerAddAction( tt, function Display_Actions )
    call TriggerExecute(tt)
    set tt = null
endfunction


JASS:
scope Display Message initializer Init
    function Display_Actions takes nothing returns nothing
        local force all = GetPlayersAll()
        call DisplayTimedTextToForce(all, 30, "Hello")
        call DestroyForce(all)
        set all = null
    endfunction

//===========================================================================
    function Init takes nothing returns nothing
        call Display_Actions( )
    endfunction
endscope


JASS:
scope Display Message initializer Init
    function Init takes nothing returns nothing
        call BJDebugMsg("Hello")
    endfunction
endscope


JASS:
struct DisplayMessage
    static method OnInit takes nothing returns nothing
        local integer i = 0
        loop
            call DisplayTimedTextToPlayer(Player(i),0,0,30,"Hello")
            set i = i + 1
            exitwhen i == bj_MAX_PLAYERS
        endloop
    endmethod
endstruct
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I don't think struct is an elegant way to do initialization as it can screw up some initialization order.
I don't think blank between scope's name is allowed.
Scopes are bad to begin with. Use library for your map, forget about scope.
JASS:
library DisplayMsg initializer OnInit
    private function OnInit takes nothing returns nothing
        call DisplayTimedTextToPlayer(GetLocalPlayer(),0.0,0.0,30.0,"Hello, clever initialization.")
    endfunction
endlibrary

More clever.
 

Romek

Super Moderator
Reaction score
963
> Scopes are bad to begin with. Use library for your map, forget about scope.
Ermm... No?
Using scopes for anything without a huge initialization function, that doesn't need priority initializing, is fine (ie, almost everything)

JASS:
scope DisplayMsg initializer OnInit
    private function OnInit takes nothing returns nothing
        call BJDebugMsg("Bye-bye, stupid initialization.")
    endfunction
endscope
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
The shortest hello world script in vJass =), also "destroys" your map.

JASS:
//! inject main
    call BJDebugMsg("Hello, world") 
    //! dovjassinit
//! endinject


Here's a nice way to "beat" module initialization =):
JASS:
//! inject main
    call SetCameraBounds(- 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call CreateAllUnits()
    call InitBlizzard()

    call ExecuteFunc("useless_cleverness_for_initing_that_beats_module_initialization_=)")
    //! dovjassinit

    call InitGlobals()
    call InitCustomTriggers()

//! endinject


And here's a fun fact: the config function runs before the main one =)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
that doesn't need priority initializing, is fine (ie, almost everything)
Personally, I found scope can be evil sometimes, for this purpose.
So, I completely wiped scope out. :)
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
what is the use of a library if in your trigger you can call the actions in an order?
and btw sgqvur, please speak in my language, i have not learned Jassanese yet

EDIT: and in a scope should i make the functions private so that i can re-use the name of the function if i want?
 

Laiev

Hey Listen!!
Reaction score
188
With [ljass]library[/ljass] you can order your things, with [ljass]scope[/ljass] you can't...

Is better you do this
[ljass]library MyLib initializer onInit requires MyRequires, MyOtherRequires[/ljass]
then
[ljass]scope MyScop initializer onInit //requires MyRequires, MyOtherRequires[/ljass]

Sorry but I agreed with KingKing.
 

Romek

Super Moderator
Reaction score
963
> Personally, I found scope can be evil sometimes, for this purpose.
Use a library whenever this 'evil' occurs.

> With library you can order your things, with scope you can't...
Use a library whenever you need ordering. Why would you need to change the order of say, spells? They're always going to be below the libraries they need.

> [ljass]scope MyScop initializer onInit //requires MyRequires, MyOtherRequires[/ljass]
Or just [ljass]scope MyScop initializer onInit[/ljass] - No hassle needed to specifically put it below other libraries if it doesn't export any functions.
 

Laiev

Hey Listen!!
Reaction score
188
That was a example of some resource made for public ^_^ some people put requirements of the scope like in library but commented
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
what is the difference between a scope and a library other than ordering? is the order of a scope just random? and cant you just put:
function myfunc requires myfuncthatgoesbeforeit
 

tooltiperror

Super Moderator
Reaction score
231
No, functions can not require other functions. Scopes can not require things, either. The only thing that can make requirements is libraries, and unto other libraries to boot.

The advantage of libraries is 1) requirements and 2) execution. In Jass, there is an operation limit. When one thread runs on for too long, it eventually quits. You can open a new thread by using the function [LJASS]ExecuteFunc[/lJASS] rather than calling a function directly. Libraries are, theoretically, big systems that need a lot more power, so library intializers use ExecuteFunc, while scopes are just called directly.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Speaking jassanese again but I think I understand this time, scopes are better for smaller functions because they can be executed without problems and are much simpler, but libraries, while being larger and more complex can have an order of functions, correct?

But why have multiple functions? Isn't a function just a set of actions?
 

Dirac

22710180
Reaction score
147
@GFreak45
Remember this: Libraries and Scope's mutual objective is encapsulation.
Libraries differ from Scopes because you can arrange them (functions that need other functions). Scopes are placed randomly across the code (after libraries).

Lets say you want to code an ability, and it uses all of the libraries you have in your map, you use a scope.
Lets say you want to code a system that moves units downhill when they stand on cliffs, you use a library.

Map initializing functions follow this order (if you don't know what this is then you probably have to read another tutorial, but its basically when you write this [ljass]scope Test initializer onInit[/ljass])

inject -> module -> library -> scope

Using libraries is almost the best thing to do always (to keep track of the other libraries it needs), but sometimes it's not necessary.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
but why would you use a library to code something sliding over a scope? i wouldnt understand why that would require a library over an ability that uses all libraries
 

Ayanami

칼리
Reaction score
288
but why would you use a library to code something sliding over a scope? i wouldnt understand why that would require a library over an ability that uses all libraries

That's why generally spells can be coded in scopes. However for systems and snippets, you need to use a Library.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top