• 🏆 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] O.o Errors

Status
Not open for further replies.
Level 3
Joined
Dec 27, 2008
Messages
56
JASS:
function SE takes string SpecialEffect location Loc real Duration returns nothing
 local effect Effect
 
 call AddSpecialEffectLocBJ(Loc,SpecialEffect)
 set Effect=GetLastCreatedEffectBJ()
 PolledWait(Duration)
 call DestroyEffect(effect)
 call RemoveLocation(Loc)
endfunction

I got in JC 29 errors....
Can u tell me correct function, please?
 
Level 19
Joined
Nov 16, 2006
Messages
2,165
1) Use the WE Newgen and you will find your mistakes.
2) BJ is mostly converted from GUI to JASS.
3) erhm? Why not 'function SE takes nothing returns nothing' ?

Oh and by the way, you didn't defined your 'Duration' and 'Loc'.
And you 'SpecialEffect' needs to be a "string".
 
Level 14
Joined
Nov 23, 2008
Messages
187
@Razoron
Function is totally incorrect
JASS:
// Where are commas between function arguments?
function SE takes string SpecialEffect, location Loc, real Duration returns nothing

  // that is just bad coding style, because:
  // 1. It uses BJ functions
  // 2. It does not set local variable at init
  //    (your variant would also work, but it's lame, seriously)
  
  //local effect Effect
  //call AddSpecialEffectLocBJ(Loc,SpecialEffect)
  //set Effect=GetLastCreatedEffectBJ()

  // the right way to go is:
  local effect Effect = AddSpecialEffectLoc(SpecialEffect, Loc)
 
  // function call needs "call" keyword before function name
  // also, I don't recommend to use PolledWait and TriggerSleepAction,
  // since they are can cause bugs and are not precise (at least).
  // Use timers instead.
  call PolledWait(Duration)
  call DestroyEffect(Effect)
  call RemoveLocation(Loc)
 
  // nullifying Effect variable to prevent "leaks"
  set Effect = null
endfunction


I would recommend to take a look at this: Moyack's TimedEffects Library
 
Level 14
Joined
Nov 18, 2007
Messages
816
You dont use timers there. Let other systems do that for you. TimedHandles should be enough for your needs.

JASS:
function SE takes string path, location loc, real duration returns nothing
    call DestroyEffectDelayed(AddSpecialEffectLoc(path, loc), duration)
endfunction

Note that TimedHandles requires JassHelper to parse your code. You should use JassNewGenPack to use this code.
 
Level 14
Joined
Nov 23, 2008
Messages
187
Ensure you have latest JassNewGenPack (5b) and JassHelper (0.9.G.1). Also "Enable JassHelper" should be checked, "DIsable vJass syntax" should be unchecked (in the menu "JassHelper")

And please do not create another topic with almost the same question.
 
Status
Not open for further replies.
Top