• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Very noobish question

Status
Not open for further replies.
Level 19
Joined
Feb 25, 2009
Messages
2,004
Well, as I procced to the next level (Learning JASS), I was searching for a proper tutorial, and here is one: Vexorian's Introducing to JASS tutorial.

As I was reading it and trying to do what he explains in the tutorial and hit a part where I can't procced (eg. I can't make the script work), sadly I tryed everything (everything that I know) but the true is I can't make it work...

So here's is the script:

JASS:
globals
private constant integer R2 = 0
private constant integer D2 = 0
endglobals

function Msg takes string s returns nothing
  call DisplayTextToForce( GetPlayersAll(), s)
endfunction
  
function AddSubstract takes integer a, integer b returns nothing
  set udg_R2 = a+b
  set udg_D2 = a-b
endfunction
  
function JASS takes nothing returns nothing
  local integer a = 14
  local integer b = 56
  call AddSubstract(a,b)
  call Msg("a= "+I2S(a))
  call Msg("b= "+I2S(b))
  call Msg("The addition is "+I2S(udg_R2))
  call Msg("The substraction is "+I2S(udg_D2))
endfunction

All the problem is in the R2 and D2 integers which I can't figure out to make them via the globals handle.

So if theres someone who can help, it will be realy nice.

Link to the tutorial: click here

PS: I'm using JassCraft v1.1.3 for writting the script, and then copy/paste it into converted JASS trigger in WE.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Check attachment to see what happens when I hit "Syntax Check" in JassNewGenPack.
After that, when I click "Test Map" it only opens my WC3 game and stays in first menu (Single Player, Multiplayer, etc.)

TriggerHappy187 said:
BJDebugMsg should work better than your Msg function.
So your saying to replace it with this?
JASS:
call BJDebugMsg( GetPlayersAll(), s)

So at the end, the code must look like this:
JASS:
globals
private constant integer R2 = 0
private constant integer D2 = 0
endglobals

function Msg takes string s returns nothing
  call BJDebugMsg( GetPlayersAll(), s)
  endfunction
  
function AddSubstract takes integer a, integer b returns nothing
  set udg_R2 = a+b
  set udg_D2 = a-b
  endfunction
  
function JASS takes nothing returns nothing
  local integer a = 14
  local integer b = 56
  call AddSubstract(a,b)
  call Msg("a= "+I2S(a))
  call Msg("b= "+I2S(b))
  call Msg("The addition is "+I2S(R2))
  call Msg("The substraction is "+I2S(D2))
  endfunction

By the way, is this JASS only or vJASS? Cause Im realy, realy new and I don't know whats the difference...

PS: Im going to sleep, will check the answers tommorow. GN.
 

Attachments

  • WTFHAX.JPG
    WTFHAX.JPG
    66.1 KB · Views: 156
Level 19
Joined
Feb 25, 2009
Messages
2,004
Ok.. ok.. So basically, I open my JNGP WE, create a new map, then create a trigger and convert it to custom text. Then I write my code, then how I can test if my code is alright or it has mistakes?

Whats the difference between JASS and vJASS ?

Is the script going to work in the way is written in my above post or it still has something missing?

Thanks again for your help.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Well, as long as I keep these 2 lines:

JASS:
globals
private constant integer R2 = 0
private constant integer D2 = 0
endglobals

JASS:
  call BJDebugMsg( GetPlayersAll(), s)

It will consider it as a vJass script.

But from the link you gave me I still didn't understand how to test my maps...
So I made a little search and I found out that this does not support any version further than 1.21 for develooping... (that also answers my question - why I can't test my map)

So now my question is, do I need to install a second instance of Warcraft 3 with patch v1.21 and put the newgen things there and so, is this going to work with my v1.24b patch?
 
Nope.

JNGP automaticly creates an v.1.21 WE with install.
While running JNGP WE, the 1.21 WE will be opened and hooked.
All new options are available then.

In order to save the script, you have to use Save(Control + S).
You have to do Save everytime you want to recompile your script.

BE WARNING: Saving with Save as also DOES not compile it!
Everytime you save the map as another file, you have to recompile it after.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Well OK, then why when I try to start my map into Warcraft III it doesn't run?
You know that issue, when its saved on different version (it doesn't show players) ...

Should I edit the script and then compile it into the JNGP and then move it into the normal WE then save it and test it?

Also what about this line:
JASS:
globals
private constant integer R2 = 0
private constant integer D2 = 0
endglobals
When I try to enable my trigger into the noraml WE with these lines it always gives me errors. Also as far as I know the normal WE does not support the "call BJDebugMsg" ...
 
BJDebugMsg is a native, so I think it should be supported.

You can't save vJass maps once you have included vJass.

Free global declaration is a vJass feature, so you can't do such thing as
JASS:
globals
private constant integer R2 = 0
private constant integer D2 = 0
endglobals

without needing vJass.

You have to use the newest JNGP and JassHelper in order to use it for the latest wc3 patch.

There are version issuses, so you should only run the maps in the version they are saved in.
 
JASS:
globals
    //Drop the private because that's only useable inside scopes and libraries
    //Drop the constant because that means you can never change the variables,
    //so you get syntax errors when you try to set them.
    integer R2 = 0
    integer D2 = 0
endglobals

//The message function isn't needed - BJDebugMsg does exactly the same job as 
//your function

//function Msg takes string s returns nothing
  //call DisplayTextToForce( GetPlayersAll(), s)
//endfunction

function AddSubstract takes integer a, integer b returns nothing
    //Removed the udg_ prefix as this is only necessary for referring to globals
    //declared with the GUI variable editor
    set R2 = a+b
    set D2 = a-b
endfunction

function JASS takes nothing returns nothing
    local integer a = 14
    local integer b = 56
    call AddSubstract(a,b)
    //replaced "Msg" with "BJDebugMsg", a function which already exists
    call BJDebugMsg("a= "+I2S(a))
    call BJDebugMsg("b= "+I2S(b))
    call BJDebugMsg("The addition is "+I2S(udg_R2))
    call BJDebugMsg("The substraction is "+I2S(udg_D2))
endfunction
 
Status
Not open for further replies.
Top