• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Function in Custom script

Status
Not open for further replies.

3an

3an

Level 1
Joined
Jan 25, 2018
Messages
3
Hello , i would like to ask if its possible to have "Jass" functions defined in custom scripts? i got triggers like this :

  • int changes init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: endfunction
      • Custom script: function addblood takes integer pid, integer kolik returns nothing
      • Custom script: set udg_player_blood[pid] = udg_player_blood[pid] + kolik
      • Custom script: endfunction
      • Custom script: function lowerblood takes integer pid, integer kolik returns nothing
      • Custom script: set udg_player_blood[pid] = udg_player_blood[pid] - kolik
      • Custom script: endfunction
      • Custom script: function addhunger takes integer pid, integer kolik returns nothing
      • Custom script: set udg_hunger[pid] = udg_hunger[pid] + kolik
      • Custom script: endfunction
      • Custom script: function lowerhunger takes integer pid, integer kolik returns nothing
      • Custom script: set udg_hunger[pid] = udg_hunger[pid] - kolik

But whenever i call one of those functions outside the trigger like this :

  • Blood add
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff80ff80 Meat
        • Then - Actions
          • Custom script: call BJDebugMsg("meat")
          • Custom script: call addblood(1,2)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to |cff80ff80 Chips
            • Then - Actions
              • Custom script: call BJDebugMsg("chips")
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to |cff80ff80 Apple
                • Then - Actions
                  • Custom script: call BJDebugMsg("apple")
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item being manipulated)) Equal to BloodBag
                    • Then - Actions
                      • Custom script: call BJDebugMsg("bloodbag")
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item-type of (Item being manipulated)) Equal to Canned fish
                        • Then - Actions
                          • Custom script: call BJDebugMsg("cANNED FISH")
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Item-type of (Item being manipulated)) Equal to Rasputin Beer
                            • Then - Actions
                              • Custom script: call BJDebugMsg("BEER")
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Item-type of (Item being manipulated)) Equal to Baked Beans
                                • Then - Actions
                                  • Custom script: call BJDebugMsg("beans")
                                • Else - Actions
It throws me a compile error that functions is not declared

LzWI.png


Any suggestions ? thanks in advance
 

3an

3an

Level 1
Joined
Jan 25, 2018
Messages
3
it's just i cant use jass scripts those whom will need to be compiled , thats the problem :p but thanks , gon' try your solution guys
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,198
Well another solution would be to put those init functions in the header.
Only downside is that it removes the option for GUI actions.

I think I've read that you can copy-paste the trigger you want below in order to put it at the bottom of the script since it is the latest addition of the map.
But I am not sure if that works.
 

3an

3an

Level 1
Joined
Jan 25, 2018
Messages
3
Actualy, KILLCIDE's solution worked , didnt tested if the function works as it should have to , but it compiles now even if usin' the funciton outside the trigger , so im okay for now :) thanks guys
 
Status
Not open for further replies.
Top