1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Why won't this "custom script" working?

Discussion in 'Triggers & Scripts' started by Dinodin, Mar 1, 2014.

  1. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I have copied an ability that works with triggers and it seems to work as it should on the original map but I tried to copy that ability into another map and I copied exactly everything the ability needs to work correct but I always get the error with the trigger
    • Custom script: set udg_Boolean = IsTerrainWalkable(udg_Temp_Loc_2)
    and I can't seem why that "custom script" wont work in the new map, it works on the old map like it should but I always get this error when I added it on a new map. What could be wrong? I just can't find anything missing of the triggers, variables and ability/buffs I copied exactly everything the ability needs to work correct into the new map and I still get that error in the triggers.
     
  2. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    7,941
    Resources:
    29
    Packs:
    1
    Maps:
    8
    Spells:
    18
    Tutorials:
    2
    Resources:
    29
    Does the following global variables exist like this :
    Boolean : Boolean
    Temp_Loc_2 : Point
     
  3. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Yes they do :-/
     
  4. Solu9

    Solu9

    Joined:
    Jan 25, 2011
    Messages:
    2,165
    Resources:
    47
    Models:
    26
    Icons:
    16
    Skins:
    1
    Tools:
    1
    Maps:
    3
    Resources:
    47
    As Daffa asked.
    Do you actually have a boolean variable simply called "boolean"?
    It just seems a bit odd.
     
  5. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Yes I do but I didn't make the triggers at all.
     
  6. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,261
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    What kind of error is it? Please paste the error message.
     
  7. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,427
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    You probably forgot to include the script that declares
    IsTerrainWalkable
    (it is not a built-in function). Check two things:
    • In the original map where you copied the abilities from, is there a trigger that has the script
      IsTerrainWalkable
      ? If so, make sure you copy that trigger over to your map (and any other scripts it requires).
    • If not, then check the map's header (for the original map). You can do this by opening the trigger editor, and the clicking on the name of the map shown on the left side where all the triggers are listed. When you click it, you should see a box for text appear on the right. The IsTerrainWalkable() script might be declared there. If so, just copy the necessary text over into your map's header.

    EDIT: Here is a picture showing how to access a map's header, in case you're stuck. I just stole it from some other thread:
    Image
    [​IMG]
     
    Last edited: Mar 2, 2014
  8. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    lol, how did no one see that.

    Anyway, if you can't find the
    IsTerrainWalkable
    resource, then I just grabbed this from PnF's sig:

    IsTerrainWalkable
    Code (vJASS):

    library TerrainPathability initializer Init
    //******************************************************************************
    //* BY: Rising_Dusk
    //*
    //* This script can be used to detect the type of pathing at a specific point.
    //* It is valuable to do it this way because the IsTerrainPathable is very
    //* counterintuitive and returns in odd ways and aren't always as you would
    //* expect. This library, however, facilitates detecting those things reliably
    //* and easily.
    //*
    //******************************************************************************
    //*
    //*    > function IsTerrainDeepWater    takes real x, real y returns boolean
    //*    > function IsTerrainShallowWater takes real x, real y returns boolean
    //*    > function IsTerrainLand         takes real x, real y returns boolean
    //*    > function IsTerrainPlatform     takes real x, real y returns boolean
    //*    > function IsTerrainWalkable     takes real x, real y returns boolean
    //*
    //* These functions return true if the given point is of the type specified
    //* in the function's name and false if it is not. For the IsTerrainWalkable
    //* function, the MAX_RANGE constant below is the maximum deviation range from
    //* the supplied coordinates that will still return true.
    //*
    //* The IsTerrainPlatform works for any preplaced walkable destructable. It will
    //* return true over bridges, destructable ramps, elevators, and invisible
    //* platforms. Walkable destructables created at runtime do not create the same
    //* pathing hole as preplaced ones do, so this will return false for them. All
    //* other functions except IsTerrainWalkable return false for platforms, because
    //* the platform itself erases their pathing when the map is saved.
    //*
    //* After calling IsTerrainWalkable(x, y), the following two global variables
    //* gain meaning. They return the X and Y coordinates of the nearest walkable
    //* point to the specified coordinates. These will only deviate from the
    //* IsTerrainWalkable function arguments if the function returned false.
    //*
    //* Variables that can be used from the library:
    //*     [real]    TerrainPathability_X
    //*     [real]    TerrainPathability_Y
    //*
    globals
        private constant real    MAX_RANGE     = 10.
        private constant integer DUMMY_ITEM_ID = 'wolg'
    endglobals

    globals    
        private item       Item   = null
        private rect       Find   = null
        private item array Hid
        private integer    HidMax = 0
        public  real       X      = 0.
        public  real       Y      = 0.
    endglobals

    function IsTerrainDeepWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction
    function IsTerrainShallowWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction
    function IsTerrainLand takes real x, real y returns boolean
        return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
    endfunction
    function IsTerrainPlatform takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction

    private function HideItem takes nothing returns nothing
        if IsItemVisible(GetEnumItem()) then
            set Hid[HidMax] = GetEnumItem()
            call SetItemVisible(Hid[HidMax], false)
            set HidMax = HidMax + 1
        endif
    endfunction
    function IsTerrainWalkable takes real x, real y returns boolean
        //Hide any items in the area to avoid conflicts with our item
        call MoveRectTo(Find, x, y)
        call EnumItemsInRect(Find ,null, function HideItem)
        //Try to move the test item and get its coords
        call SetItemPosition(Item, x, y) //Unhides the item
        set X = GetItemX(Item)
        set Y = GetItemY(Item)
        static if LIBRARY_IsTerrainWalkable then
            //This is for compatibility with the IsTerrainWalkable library
            set IsTerrainWalkable_X = X
            set IsTerrainWalkable_Y = Y
        endif
        call SetItemVisible(Item, false)//Hide it again
        //Unhide any items hidden at the start
        loop
            exitwhen HidMax <= 0
            set HidMax = HidMax - 1
            call SetItemVisible(Hid[HidMax], true)
            set Hid[HidMax] = null
        endloop
        //Return walkability
        return (X-x)*(X-x)+(Y-y)*(Y-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction

    private function Init takes nothing returns nothing
        set Find = Rect(0., 0., 128., 128.)
        set Item = CreateItem(DUMMY_ITEM_ID, 0, 0)
        call SetItemVisible(Item, false)
    endfunction
    endlibrary
     


    Either put it in the map header or create a new trigger, Edit, Convert to Custom Text, and put it in there.
     
  9. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    7,941
    Resources:
    29
    Packs:
    1
    Maps:
    8
    Spells:
    18
    Tutorials:
    2
    Resources:
    29
    ^that only works with JNGP I suppose?
    Globals doesn't exist in normal WE
     
  10. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Oh I forget to copy that script from the original map, now I did but now I still get about 100 of errors o_O
    I just can't see whats wrong at all. Maybe someone can take a look at my map try to find out? I really can't see anything wrong at all :-/
     
  11. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,261
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
  12. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
  13. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,261
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    I doubt it can not work on normal World Editor. :p
     
  14. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    So why does it work on the original map?
     
  15. DysfunctionaI

    DysfunctionaI

    Joined:
    Mar 6, 2006
    Messages:
    281
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Because it was saved with JNGP.
     
  16. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I can't remember I have saved anything with a JNGP version. I've always used the normal World Editor only :-/
     
  17. Dinodin

    Dinodin

    Joined:
    Jul 19, 2007
    Messages:
    492
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I would be glad if someone could take a look at my map and try found out why it isn't working like it should.. I just can't see why it gets all these errors :-/