| 09-24-2008, 07:31 AM | #1 |
Sup everyone, i've finally decided to start learning jass, simply because i need it to modify bonus mod... Even though i have a mental block against it. The main problem i'm having is the syntax and no matter how many tutorials i read i can't quite grasp it. Is there a tool that tells you exactly whats wrong with your syntax, and how to fix it. Everything i've tried simply says syntax error, and no matter how much i fiddle i can't get it right. |
| 09-24-2008, 08:33 AM | #2 |
Posting the code that gives you a syntax error would be helpful. |
| 09-24-2008, 08:33 AM | #3 |
u need to learn basic programming, cus those syntaxes are similar. Or u can post an example of ur code here and we ma tell u. The program tat tells u syntax error is the one u need. And u already got it (WE). I recommend newgen cus it give a better syntax detection. And i think maybe u get syntax error cus ure using a code with vjass while u have normal we only. Then u get error no matter how hard u try. get Jass New Gen Pack and jasshelper latest versions |
| 09-24-2008, 08:42 AM | #4 |
I'm using newgen, the bonus mod is implemented and everything. The problem is that although the code is highlighted and i know which line is giving shit. I'm not sure whats wrong with it. I'll post the code when i get home. Its probably a hectic mistake because i'm a noob at jass. |
| 09-24-2008, 05:48 PM | #5 |
okay so heres the code... please don't rip me to shit about this but like i said I'm very new to jass. From what I understand you have to use this whole function evry single time you want a unit to recieve a certain bonus. JASS:function UnitAddBonus takes unit (GetTriggerUnit), integer (0), integer (+0256) returns boolean local integer x local boolean b local real l local string s local real min local real mod if amount==0 then return true endif if t>1 then set amount= (amount/BonusHPManaFactor())*BonusHPManaFactor() endif if t>=2 then if t==2 then set l=GetWidgetLife( who ) set mod=ModuloReal(l,BonusHPManaFactor()) set s="BonusModLeftHP" if mod>=1 then set min=0 else set min=BonusHPManaFactor() endif else set l=GetUnitState( who, UNIT_STATE_MAX_MANA ) set mod=ModuloReal(l,BonusHPManaFactor()) set s="BonusModLeftMana" set min=0 endif set amount=amount+GetAttachedInt(who,s) if (amount < 0) and ( l + amount < 1 ) then set x=R2I(min+mod-l) set b= UnitSetBonus(who,t,UnitGetBonus(who,t)+x) call AttachInt(who,s, (amount-x) ) else call AttachInt(who,s,0) set b= UnitSetBonus(who,t,UnitGetBonus(who,t)+amount) endif return b endif return UnitSetBonus(who,t,UnitGetBonus(who,t)+amount) endfunction I've probably gone way off course. Secondly must the unit, integers etc be stated at the beginning of the function. If not then when and if so why is it giving me a syntax error (along with an ass load of other errors that i don't understand). Thanks in advance. |
| 09-24-2008, 06:16 PM | #6 |
Put that code into [jass] and [ /jass] tags please. until you do that, people might want to look at this instead: http://peq.bplaced.de/code.php?id=1014 Edit: what does the function-declaration function UnitAddBonus takes unit (GetTriggerUnit), integer (0), integer (+0256) returns boolean do? I mean all that () stuff, is that new vJass syntax I didn't notice or just your way of telling us the values you used? in that case please put your values into a comment, and then put the original line into the script again, or we won't know the names of those variables inside the function. Edit2: actually this already seems to be your syntax error, lol. |
| 09-24-2008, 06:33 PM | #7 |
Where exactly do you get the syntax errors? A screenshot would be useful. |
| 09-24-2008, 07:26 PM | #8 | |
Editted The code is used to add bonus's to units in game. It is part of the Bonus Mod system. The unit is given the bonusses, the first integer defines what bonus it is, damage(0); armour(1); HP(2); Mana(3), and the last integer is the amount added. I get the syntax errors on the first line of code. Quote:
|
| 09-24-2008, 07:34 PM | #9 |
replace the first line of the function, the line function UnitAddBonus takes unit (GetTriggerUnit), integer (0), integer (+0256) returns boolean with the first line of the original function. then see if it saves. If not, give screenshot of the error. |
| 09-24-2008, 07:46 PM | #10 |
yes it saves... so now where would I define the unit and two integers if not in the first line of code? The original readme simply gave this function JASS:function UnitAddBonus takes unit who, integer t, integer amount returns boolean |
| 09-24-2008, 08:17 PM | #11 |
you use that function like this: JASS:function ThisFunctionDoesSomething takes nothing returns nothing call UnitAddBonus(GetTriggeringUnit(), 2, 256) endfunction that would add a bonus of 256 of type 2(whatever that is) to the triggering unit. |
| 09-24-2008, 08:26 PM | #12 |
Ouch. I really have nothing else to say. Just ouch. |
| 09-24-2008, 08:45 PM | #13 |
Thanks Blubb and Anartif. Peace +rep |
| 09-24-2008, 10:15 PM | #14 |
I think TESH natives list would help both of you... It's GetTriggerUnit()... |
