• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help with Jass Script compile Errors

Status
Not open for further replies.
Level 3
Joined
Oct 10, 2017
Messages
32
So iam a noob in Jass/GUI, however i'am starting to get it.. slowly but steadily..

However, now to my question : As a practise I want to make a Chat Message for all Players (in Jass ofc)
that shows a result of a math problem. In Pic 1 you can see my script. In Pic 2 u can see the error I get when I try to activate the Trigger/save the map. So what am I doing wrong?


I've got another Picture (Pic 3) and my next question is if I have to put the Functions I make inside of that Folder (the one that is marked with blue) and the initializer into the trigger?

and also do I have to make a new Trigger for each Spell/System (whatever) I want to make or can I just put it all in the same Trigger. I hope whoever reads this gets what I mean because I'm a bit confused aswell.
 

Attachments

  • 1.png
    1.png
    67.8 KB · Views: 156
  • 2.png
    2.png
    23.5 KB · Views: 156
  • 3.png
    3.png
    54.1 KB · Views: 127
Level 39
Joined
Feb 27, 2007
Messages
5,012
The problem is you tried to set a function name (LoopTestA) equal to a trigger before adding an action to it, which causes a few errors. You need to create a new trigger and add events, conditions, and actions to it. It also doesn't have an event attached so there's nothing yet that will run LoopTestA().

You want to do:
JASS:
scope LoopA initializer Init

function LoopTestA takes nothing returns nothing
    //Do your shit
endfunction

function Init takes nothing returns nothing
    // This function is automatically called on map init because of the "initializer" line in the library definition above
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT) //put your event here instead of this random event that I picked.
    call TriggerAddAction(t, function LoopTestA)
endfunction

endscope
The vanilla WE automatically runs the InitTrig function associated with each trigger, but vJASS scopes with initializers have the same functionality: you need something to run the function that adds an event and an action.

You can put things into the Custom Script section of the map, but WEX/JNGP (the editor you're using) allow you to put your code in libraries in any trigger instead,which are automatically moved to the CS section when the map is compiled. You can put it all in one trigger if you want but I usually split up systems/sub-systems for ease of reading.

The only thing you can't put in a blank trigger are functions outside of all libraries/scopes. for example:
JASS:
library whatever
    function a takes nothing returns nothing
      //...
    endfunction

    function b takes nothing returns nothing
      //...
    endfunction
endlibrary
Above jass is good, below jass is bad.
JASS:
//not in a library or a scope!
function a takes nothing returns nothing
  //...
endfunction

function b takes nothing returns nothing
  //...
endfunction
 
Level 3
Joined
Oct 10, 2017
Messages
32
So, I tried fixing my mistakes but I still get 1 error. What am I missing?
 

Attachments

  • Unbenannt.png
    Unbenannt.png
    63.7 KB · Views: 134
Level 39
Joined
Feb 27, 2007
Messages
5,012
You didn't replace LoopTestA with t for the trigger in your TriggerRegisterAnyUnitEventBJ call. Also you might not be able to use the name Init for your scope's initializer, so if you still get errors try changing both instances of Init in your code to some other name.

Usually the JASSHelper compiler will only show you one or a couple errors when it finds them, not everything at once. That's usually because an error in a steuct definition causes more errors anywhere you atrmeat to use that struct with the errors in it.
 
Level 3
Joined
Oct 10, 2017
Messages
32
Code:
scope LoopA initializer Test_Loop

function LoopTestA takes integer n returns nothing
local integer n = 10
set n = n / 2
call DisplayTextToForce (GetPlayersAll, "n = "+I2S(n) )
set n = n / 5
call DisplayTextToForce (GetPlayersAll, "n = "+I2S(n) )
endfunction

function Lopa takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerKeyEventBJ (t, GetPlayersAll, bj_KEYEVENTKEY_LEFT, null)
    call TriggerAddAction(t, function LoopTestA)
endfunction

endscope

Still the same Error. Must be something with the Scope at the very top
 
Level 3
Joined
Oct 10, 2017
Messages
32
Code:
scope LoopA initializer Test_Loop

function LoopTestA takes integer u returns nothing
local integer n = 10
set n = n / 2
call DisplayTextToForce (GetPlayersAll, "n = "+I2S(n) )
set n = n / 5
call DisplayTextToForce (GetPlayersAll, "n = "+I2S(n) )
endfunction

function Lopa takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerKeyEventBJ (t, GetPlayersAll, bj_KEYEVENTKEY_LEFT, null)
    call TriggerAddAction(t, function LoopTestA)
endfunction

endscope

still the same.. its rly frustrating ._. such a simple code... why cant anyone help me xD I want to move on aswell. I read tons of tutorials but still cant find out what is wrong here.
 
Level 39
Joined
Feb 27, 2007
Messages
5,012
If you read the error message you got you would see that it's telling you your scope initializer doesn't exist. At the top of the scope you have "initializer Test_Loop" but lower down the function is actually called "function Lopa". You need to resolve this error by changing one of these so they're both the same.

If you don't get why this error is happening you really need to reread the JASSHelper Manual section about scopes and libraries. Google it you'll find it.


You also have written GetPlayersAll a few times eithout the () to indicate it's a function call. They all should be GetPlayersAll().
 
Level 3
Joined
Oct 10, 2017
Messages
32
Yeah, that is because I tried quite alot of things now and it still does'nt seem to work. In my tryings I must've forgotten to change it back (which is understandeble if u ask me). Also if I read the error message it tells me that there is an UNKNOWN compile error (syntax error) and how am I supposed to know what that is? Im pretty sure I told u at the beginning that im a noob trying to learn jass. PS : I changed it so they both have the same name but it still shows me the same error.

Code:
scope FirstJassTry initializer TextTestInit

private function TextTestA takes integer u returns nothing
local integer n = 10
set n = n/2
call DisplayTextToForce (GetPlayersAll(), "n = "+I2S(n) )
set n = n/5
call DisplayTextToForce (GetPlayersAll(), "n = "+I2S(n) )
endfunction

private function TextTestInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerKeyEventBJ (t, GetPlayersAll(), bj_KEYEVENTKEY_LEFT, null)
    call TriggerAddAction(t, function TextTestA)
    set t = null
endfunction

endscope

Dont get me wrong, I'm grateful for the amount of help I get, its just frustrating that it still won't work and no matter what I do it shows me this message. As I said im re-reading alot of tutorials the whole time but I just cant find my mistake which is why im seeking for help here.
 
Level 39
Joined
Feb 27, 2007
Messages
5,012
Just noticed now that your trigger action function TectTestA takes integer u but doesn't use it. As I understand trigger action functions cannot have arguments, which is probably the problem. You're right that it does say "unknown" in the error dialog... but it's not unknown like no idea what's going on but there's SOME sort of error here. Some THING you typed is unknown: the problem is it says it has is "unknown function called 'Test_Loop'" which means it doesn't know what that function is. So it either was improperly defined or has some sort of naming problem. Either way go look at the function definition where you think it is and see what's different.
 
Level 3
Joined
Oct 10, 2017
Messages
32
Code:
scope FirstJassTry initializer FirstJassTryInit

private function FirstJassTry_Actions takes nothing returns nothing
local integer n = 10
set n = n/2
call DisplayTextToForce(GetPlayersAll(), "n = "+I2S(n) )
set n = n/5
call DisplayTextToForce(GetPlayersAll(), "n = "+I2S(n) )
endfunction

private function FirstJassTryInit takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ(t, GetPlayersAll(), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction (t, function FirstJassTry_Actions )
endfunction

endscope

Still no work. Also tried what "ZiBitheWand3r3r" suggested (changing the Player from Event into Player 1 instead of allplayer) still no work :/
 
Level 39
Joined
Feb 27, 2007
Messages
5,012
It is MUCH easier to troubleshoot on the internet from across the world if you describe exactly what error you are given. Ths reason I keep missing things and noticing/correcting them a few posts later. When you call a function you need to make sure you give it the right arguments. It it's expecting a unit and you give it a boolean, it'll throw an error.

Where ZiBitheZand3r3r suggested you put Player(0) you have GetPlayersAll(). Now if you look at the Player() and GetPlayersAll() functions (you can use the function list browser TESH added to yoir trigger window) you'll notice the former returns player and the latter returns force. A force is not a player so giving the all players force to TriggerRegisterPlayerKeyEventBJ() will throw a type mismatch error. If you want that event to work for all players you will have to loop a variable from 0 to 11 (or 23) and call that event register-er for Player(0) to Player(11).


It's much easier to troubleshoot code in [code=jass][/code] instead of [code][/nocode] tags.
Edit: I tried compiling this code and it works.
JASS:
scope FirstJassTry initializer FirstJassTryInit

private function FirstJassTry_Actions takes nothing returns nothing
local integer n = 10
set n = n/2
call DisplayTextToForce(GetPlayersAll(), "n = "+I2S(n) )
set n = n/5
call DisplayTextToForce(GetPlayersAll(), "n = "+I2S(n) )
endfunction

private function FirstJassTryInit takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterPlayerKeyEventBJ(t, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
call TriggerAddAction (t, function FirstJassTry_Actions )
endfunction

endscope
I also attached a picture of the error screen from when you have the GetPlayersAll() in place of a player, with descriptions to help you understand what pjass is trying to tell you. If it's a pjass error it's a problem with some basic JASS code, like function definitions or type mismatch or syntax. If it's a JASSHelper error then it's a problem with something new in vJASS; perhaps that helps you narrow down future errors. In this case "cannot convert force to player" means that you gave it a force where it was expecting a player... in the line it highlighted.

Also I was wrong about the initializer naming conventions and you can actually call them Init or init.
 

Attachments

  • err.png
    err.png
    36 KB · Views: 99
Last edited:
Level 3
Joined
Oct 10, 2017
Messages
32
Well.. the Error u get is quite different from what I get. With the Error in your Picture I could understand what the problem is, however that was not the case. Pretty sure I uploaded Pics already that show that my Error only shows "unknown compile error (syntax error)" or smthng like this. How comes it shows "cannot convert force to player ... " in your picture? are you using another world editor or smthng?


Edit : I've got another Problem aswell with a Code I made (its much longer and its a Spell). Should I Create a new Topic for that one or is it fine if I just post it here aswell?
 

Attachments

  • 1.png
    1.png
    28.5 KB · Views: 143
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,012
You're right, you totally did post an error screenshot that I didn't look at too closely. It's pretty weird that it's not running through pjass or JASSHelper when I see the TESH buttons in your trigger window. (Unless those were added natively to the editor by 1.29?)Which of the following world editors are you using when you open and save your map?

1. Vanilla World Editor (the one that came with the game)
2. World Editor Extended (WEX)
3. JassNewGenPack (JNGP)

1 will probably work fine after 1.30 drops but that's not happening in the immediate future. You should be using 2, as 3 hasn't been updated for new patches. Is your game updated to 1.29, and if not what patch are you running? Perhaps reinstalling the game and WEX might fix the problem.
 
Level 3
Joined
Oct 10, 2017
Messages
32
Im using the second, and I just reinstalled WEX and now theres no error anymore :3 with both of the codes I made

Edit : Ok when I tried to test the map I get an more acurate Error with the same Window that was in ur pic, so i guess I just had to reinstall it
 
Status
Not open for further replies.
Top