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
964
> 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
964
> 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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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