wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 01-25-2007, 05:24 PM   #1
StockBreak
User
 
StockBreak's Avatar
 
Join Date: Apr 2006
Posts: 313

StockBreak will become famous soon enough (28)

Question Transfering Functions - JASS Help

Hi all, I am trying to tidy up my Custom Script Code functions (expecially the heroes abilities) and so I wanted to move some functions from the core to blank triggers. Basically something like this:

Collapse JASS:
function Function takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Trigger takes nothing returns nothing
endfunction

and then another trigger

Collapse JASS:
function Trig_Caller_Actions takes nothing returns nothing
    call Function(  )
endfunction

//===========================================================================
function InitTrig_Caller takes nothing returns nothing
    set gg_trg_Caller = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Caller, function Trig_Caller_Actions )
endfunction

However it doesn't work, because when I call the function Function in another trigger (which must be below the first trigger, right?), the WE gives me the "Expected a function name" error. It can be a newbie question, but can someone explain to me why the compiler can't find my function? Is there a better way to move functions from the Custom Script Core to another place?

EDIT: viewing the Map Script, I saw that the trigger trigger Caller is written before the function Function and maybe this causes the error; this is strange because the trigger Caller which calls the dummy function is BELOW (I mean, its folder is below) the first trigger containing the function.
__________________
More nightmares will come to me now. More than I previously had.

Last edited by StockBreak : 01-25-2007 at 05:57 PM.
StockBreak is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-25-2007, 06:08 PM   #2
shadow1500
STARCRAFT II OMFG
 
shadow1500's Avatar
 
Join Date: Jul 2004
Posts: 1,004

Submissions (9)

shadow1500 is just really nice (306)shadow1500 is just really nice (306)shadow1500 is just really nice (306)

Send a message via ICQ to shadow1500 Send a message via AIM to shadow1500 Send a message via MSN to shadow1500
Default

WE arranges them based on the time they were created/enabled.
You must use preprocessors (WEHelper/JASSHelper) so that they arrange the code the way you need it to be.
shadow1500 is offline   Reply With Quote
Old 01-25-2007, 06:29 PM   #3
StockBreak
User
 
StockBreak's Avatar
 
Join Date: Apr 2006
Posts: 313

StockBreak will become famous soon enough (28)

Default

Quote:
Originally Posted by shadow1500
WE arranges them based on the time they were created/enabled.
You must use preprocessors (WEHelper/JASSHelper) so that they arrange the code the way you need it to be.
Thank you very much.
What do you mean with "enabled"? Is there any way to enable/disable them so that they can be arranged without using a 3rd part program? Thanks.
__________________
More nightmares will come to me now. More than I previously had.
StockBreak is offline   Reply With Quote
Old 01-25-2007, 06:33 PM   #4
shadow1500
STARCRAFT II OMFG
 
shadow1500's Avatar
 
Join Date: Jul 2004
Posts: 1,004

Submissions (9)

shadow1500 is just really nice (306)shadow1500 is just really nice (306)shadow1500 is just really nice (306)

Send a message via ICQ to shadow1500 Send a message via AIM to shadow1500 Send a message via MSN to shadow1500
Default

I am not sure exactly. What I do remember is that it is quite tedious to do it every time.
shadow1500 is offline   Reply With Quote
Old 01-25-2007, 06:48 PM   #5
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

becaus eof stuff like this, I wish you could prototype functions on JASS. You wouldn't have to worry about this stuff.
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 01-25-2007, 06:59 PM   #6
StockBreak
User
 
StockBreak's Avatar
 
Join Date: Apr 2006
Posts: 313

StockBreak will become famous soon enough (28)

Default

Creating new triggers and then pasting the old code will do the job but it's very time consuming... For example I have a function that calls all the other functions and so I need to delete/replace it every time I make a new function... Isn't there any other way (apart from 3rd part programs)? Thanks.
__________________
More nightmares will come to me now. More than I previously had.
StockBreak is offline   Reply With Quote
Old 01-25-2007, 07:31 PM   #7
PipeDream
Moderator
 
PipeDream's Avatar


Code Moderator
 
Join Date: Feb 2006
Posts: 1,405

Submissions (6)

PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)PipeDream is a glorious beacon of light (463)

Default

Prototyping is silly, if the function is defined anywhere and there's no REPL then it should just work.
__________________
PipeDream is offline   Reply With Quote
Old 01-25-2007, 08:14 PM   #8
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

I like prototyping because I can plaster a lot of documentation there.
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 01-25-2007, 09:45 PM   #9
Mapz_Maker
User
 
Mapz_Maker's Avatar
 
Join Date: Nov 2006
Posts: 198

Submissions (1)

Mapz_Maker is on a distinguished road (12)

Default

IT IS 3rd Party programs NOT 3rd part programs!!
__________________
Trigger:
Rep Mapz_Maker
Events
WC3C - Mapz_Maker makes a post!
Conditions
Actions
Custom Script: loop
Custom Script: exitwhen 1 = 2
Custom Script: set Mapz_Maker's Rep = Mapz_Maker's Rep + 1
Custom Script: endloop
Mapz_Maker is offline   Reply With Quote
Old 01-25-2007, 10:05 PM   #10
StockBreak
User
 
StockBreak's Avatar
 
Join Date: Apr 2006
Posts: 313

StockBreak will become famous soon enough (28)

Default

Quote:
Originally Posted by Mapz_Maker
IT IS 3rd Party programs NOT 3rd part programs!!
...
Very useful answer.
__________________
More nightmares will come to me now. More than I previously had.
StockBreak is offline   Reply With Quote
Old 01-26-2007, 01:35 AM   #11
wyrmlord
User
 
wyrmlord's Avatar
 
Join Date: Feb 2006
Posts: 399

Submissions (2)

wyrmlord has a spectacular aura about (77)wyrmlord has a spectacular aura about (77)wyrmlord has a spectacular aura about (77)

Default

Functions that you want to call must be above the function you're calling it from. If you want to call a function anywhere, you have to use ExecuteFunc which works for functions which take no arguments and return nothing. It also runs the function in another thread.
__________________
A member of Clan TDG - Quality mapmaking and playtesting.

Tired of boring old GUI? Want to learn JASS? Take a look at these tutorials.
wyrmlord is offline   Reply With Quote
Old 01-26-2007, 09:41 AM   #12
StockBreak
User
 
StockBreak's Avatar
 
Join Date: Apr 2006
Posts: 313

StockBreak will become famous soon enough (28)

Default

Quote:
Originally Posted by wyrmlord
Functions that you want to call must be above the function you're calling it from. If you want to call a function anywhere, you have to use ExecuteFunc which works for functions which take no arguments and return nothing. It also runs the function in another thread.
Yes, I have read a Blade's tutorial about the ExecuteFunc, but I have many functions taking and returning something. Anyway, with ExecuteFunc, can I call a function anywhere on my script even if this function is not above the caller?
Actually I moved all my functions "prototyping" them (thanks to PipeDream for the word :) ), but every time I make a new function I have to retype a function to call them all (lol, seems LOTR). Thanks.
__________________
More nightmares will come to me now. More than I previously had.

Last edited by StockBreak : 01-26-2007 at 09:42 AM.
StockBreak is offline   Reply With Quote
Old 01-26-2007, 05:31 PM   #13
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

...

You can always use an struct and an static method (zomg 3rd party stuff stay away)

like

Collapse JASS:
function something takes nothing returns nothing
    call BJDebugMsg(" 3 = "+I2S(whyastruct.waht(2,1)))
endfunction


struct whyastruct
     static method waht takes integer a, integer b returns integer
          return a+b
     endmethod
endstruct


__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 12:58 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services