| 09-22-2006, 04:52 AM | #1 |
lol, XD my jass makes me crash during load of the map... anyone see my error? JASS:function Msg takes string a returns nothing local string s call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) endfunction function ShowMsg takes nothing returns nothing call Msg("Hello") endfunction function ShowSum takes integer a, integer b returns nothing local integer r = a+b call Msg("r = "+I2S(r)) endfunction function Jass takes nothing returns nothing call ShowMsg() call ShowSum(33,45) endfunction //=========================================================================== function InitTrig_Msg takes nothing returns nothing set gg_trg_Msg = CreateTrigger( ) call TriggerAddAction( gg_trg_Msg, function Msg ) endfunction |
| 09-22-2006, 05:20 AM | #2 |
JASS:local string s call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) You're trying to display an unitialized string. That would be a bad thing to try to do. Consider instead of 'local string s' typing... JASS:local string s = "MY MAP!" Of course, that's all quite pointless as it is. I imagine you're just experimenting with stuff, which is okay -- But try this instead if you want to keep experimenting... JASS:function Msg takes string a returns nothing call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS, 30, a) endfunction |
| 09-22-2006, 05:30 AM | #3 |
thanks, im actually copying off a tutorial... http://www.wc3campaigns.net/showthread.php?t=74894 It said function Msg takes string a returns nothing call DisplayTextToForce( GetPlayersAll(), s ) endfunction But there was no s? so i added "local string s" nothing appeared, added a value to it, then realized how it works... But It doesnt work the actual trigger is this (without the local string s = "Blah" it does nothing... JASS:function Msg takes string s returns nothing local string s = "Doesnt work ooomg soo not fair" call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) endfunction function ShowMsg takes nothing returns nothing call Msg("This is a message") endfunction function ShowSum takes integer a, integer b returns nothing local integer r = a+b call Msg("r = "+I2S(r)) endfunction function Jass takes nothing returns nothing call ShowMsg() call ShowSum(33,45) endfunction //=========================================================================== function InitTrig_Msg takes nothing returns nothing call TimerStart(CreateTimer(), 1.00, true, function Jass ) endfunction The above works, but duplicates "Doesnt work omg soo not fair" lol, uhh why iis this, its suppost to show "This is a message", and below it 78, all it does is duplicate doesnt work omg sooo not fair lol... thing different between my trigger, and the tutorial, is his had no timer..., and his had no local string s = "Bahbah" can anyone tell me what I am doing wrong? |
| 09-22-2006, 06:41 AM | #4 |
Didn't find where you are exactly in Tut, but here's your fault. When you call a function with a value inside the () you set a Value inside takes xxx. Btw. a variable in takes xxx count as local in this part: JASS:function Msg takes string s returns nothing call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) endfunction function ShowMsg takes nothing returns nothing call Msg("This is a message") endfunction But you change the name of the takes string s to takes string a, but didn't changed this part: JASS:function Msg takes string s returns nothing call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) endfunction JASS:function Msg takes string a returns nothing call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, a ) endfunction |
| 09-22-2006, 06:43 AM | #5 |
You don't need to declare a local, s is already a parameter of the function. You know, "...takes string s...". JASS:function Msg takes string s returns nothing call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,30, s ) endfunction |
| 09-22-2006, 01:35 PM | #6 |
The reason of the crash in the first is that you are using Msg as code argument for the TimerStart native, that native expects you to use a [takes nothing] function and when you use a function that takes an argument it will crash. You are just screwing up the whole tutorial, cause it was supposed to run using these functions: JASS:function Trig_JASS_test_Actions takes nothing returns nothing call DisplayTextToForce( GetPlayersAll(), "This is a message" ) endfunction //=========================================================================== function InitTrig_JASS_test takes nothing returns nothing set gg_trg_JASS_test = CreateTrigger( ) call TriggerRegisterPlayerEventEndCinematic( gg_trg_JASS_test, Player(0) ) call TriggerAddAction( gg_trg_JASS_test, function Trig_JASS_test_Actions ) endfunction It is too soon to try to use timers, to handle the code type you would have to look at my other tutorial 'triggers in JASS' |
| 09-23-2006, 02:18 AM | #7 |
Ok, Thanks alot XD I see... |
