| 09-04-2007, 07:15 AM | #1 |
Hey guys, learnin me some JASS, and I ran into some problems. Here's my code... JASS:function Trig_Jass_Pathable_Actions takes nothing returns nothing if IsLocPathable(OffsetLocation(GetUnitLoc(udg_Player1Hero), -180.00, 180.00)) then call CreateNUnitsAtLoc( 1, 'h000', Player(0), OffsetLocation(GetUnitLoc(udg_Player1Hero), -180.00, 180.00), bj_UNIT_FACING ) set udg_Player1MovementArray[1] = GetLastCreatedUnit() endif endfunction //=========================================================================== function InitTrig_Jass_Pathable takes nothing returns nothing set gg_trg_Jass_Pathable = CreateTrigger( ) call TriggerAddAction( gg_trg_Jass_Pathable, function Trig_Jass_Pathable_Actions ) endfunction I get errors on this Expected a name: f IsLocPathable(OffsetLocation(GetUnitLoc(udg_Player1Hero), -180.00, 180.00)) then Expected a code statement: set udg_Player1MovementArray[1] = GetLastCreatedUnit() Anyone know what my noob ass is doing wrong? |
| 09-04-2007, 07:25 AM | #2 |
for one you have a leak "OffsetLocation(GetUnitLoc(udg_Player1Hero..." should be set to a point variable then destroyed. Also the udg_Player1MovementArray[1] a Unit array? |
| 09-04-2007, 07:30 AM | #3 |
Yeah Basically, it check's if the point based on a units position and offset is Pathable then creates a unit from an array at that spot. Well that's what its is supposed to do. Any chance you know how to fix it? ok I edited the code to use a variable Still getting the same error's though. JASS:function Trig_Jass_Pathable_Actions takes nothing returns nothing local location L set L = udg_TopLeft if IsLocPathable(L) then call CreateNUnitsAtLoc( 1, 'h000', Player(0), OffsetLocation(GetUnitLoc(udg_Player1Hero), -180.00, 180.00), bj_UNIT_FACING ) set udg_Player1MovementArray[1] = GetLastCreatedUnit() endif endfunction //=========================================================================== function InitTrig_Jass_Pathable takes nothing returns nothing set gg_trg_Jass_Pathable = CreateTrigger( ) call TriggerAddAction( gg_trg_Jass_Pathable, function Trig_Jass_Pathable_Actions ) endfunction |
| 09-04-2007, 09:32 AM | #4 |
Your avatar is scary. There is no "IsLocPathable" function; the correct function would be IsTerrainPathable... and I'm pretty sure that it returns true if it isn't pathable and false if it is. Thus, you'd need to do this: if not(IsTerrainPathable(L, PATHING_TYPE_WALKABILITY)) then. Additionally, you're not checking if the correct location is pathable or not. You need to offset the location before you check to see if it's pathable. This is the part that leaks: OffsetLocation(GetUnitLoc(udg_Player1Hero), -180.00, 180.00), but you could fix it by using X/Y values instead of locations: JASS:function Trig_Jass_Pathable_Actions takes nothing returns nothing local real X = GetUnitX(udg_Player1Hero)-180.00 local real Y = GetUnitY(udg_Player1Hero)+180.00 if not(TerrainPathable(X, Y, PATHING_TYPE_WALKABILITY)) then set udg_Player1MovementArray[1] = CreateUnit(Player(0), 'h000', X, Y, 270.00) endif endfunction //=========================================================================== function InitTrig_Jass_Pathable takes nothing returns nothing set gg_trg_Jass_Pathable = CreateTrigger( ) call TriggerAddAction( gg_trg_Jass_Pathable, function Trig_Jass_Pathable_Actions ) endfunction |
| 09-04-2007, 10:05 AM | #5 |
Awesome thanks, I get what you're talking about now. But i'm still seeming to get that "Expected Name" error at the 'if not(TerrainPathable(X, Y, PATHING_TYPE_WALKABILITY)) then' section. Is there something in my map that I'm doing wrong? Currently for the jass Im just making a blank trigger and typing the code into there. |
| 09-04-2007, 10:21 AM | #6 |
JASS:if not(IsTerrainPathable(X, Y, PATHING_TYPE_WALKABILITY)) then set udg_Player1MovementArray[1] = CreateUnit(Player(0), 'h000', X, Y, 270.00) endif |
| 09-04-2007, 02:38 PM | #7 |
Alright, that fixed the error I was getting when writing the code. Now when I try to save it pops up A TON of errors that don't give me any damn way of knowing wtf is wrong with it, just a string of "Expected a Name" "Expected a code Statement" "Expected a Function Name" |
| 09-04-2007, 02:58 PM | #8 |
Look at the first error, it's likely that all the rest are caused by the compiler loosing itself on the first. |
| 09-04-2007, 04:48 PM | #9 |
Download JassNewGenPack, it contains a better and safer parser than blizzards. |
