script error. Sprite number wrong. <-- As soon as I delete the latest attached sprite it works fine again. I don't know what the problem here is, but I figured I might prevent this by using a connector script in which I can define a list of sprites to which each script applies. for example, like this ---- Connector script----- on beginsprite me set mysprite to the spritenum of me set cbob to 18 -- sprite channel number of 'player' bob set cbill to 19 -- sprite channel number of 'player' bill set tblock to [23, 30, 31, 33] -- the sprite channels that should be handled with a top intersect script set bblock to [26, 27, 28, 29, 32, 33] -- the sprite channels that should be used in .... set rblock to [21,25,35,36,37,38,39,41] -- etc... set lblock to [22,23] -- etc... sendallsprites #storeShared, [#bob:cbob,#bill:cbill,#topBlock:tblock,#bottomBlock:bblock,#rightBlock:rblock,#leftBlock:lblock] end --- intersect scripts--- I was planning on attaching this script to the 'player' sprites Bob and Bill ---instead of to all objects that they weren't supposed to pass. thus reducing the number of ---scripts ---from many to just 2... property mySprite property bob -- de sprite van Bob property bill -- de sprite van Bill property topBlock property bottomBlock property leftBlock property rightBlock on beginsprite me set mySprite to the spritenum of me end on storeShared me, gameSprites set bob to the bob of gamesprites -- bobs channel in de score, opgehaald in connection script set bill to the bill of gameSprites -- idem, maar dan voor Bill set topBlock to the topblock or gameSprites set bottomBlock to the bottomBlock of gameSprites set leftBlock to the leftBlock of gameSprites set rightBlock to the rightBlock of gameSprites end on exitframe me if sprite bob intersects sprite leftBlock then --- sprite leftBlock should, the way i thought it would, make sure that every sprite defined in the connector script as lBlock, in this case [22,23] sprite (bob) .locH = sprite (bob) .locH -10 end if if sprite bill intersects sprite leftBlock then sprite (bill).locH = sprite (bill) .locH -10 end if --- repeat for top, bottom and right intersects --- end Would anybody know either a: why I can't use my intersect scripts in a lot of different sprites or b: how I can create but one script in which I make sure all the appropriate sprites are effected... Thanks for taking your time to even read through this... [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => irwhistle webforumsuser@macromedia.com [ip] => "irwhistle" web [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> To many intersect scripts make Macro a sad panda - Macromedia Director Lingo

To many intersect scripts make Macro a sad panda - Macromedia Director Lingo

Hello there, I'm trying to create a 2d game. To prevent my 'player' from walking through objects I am using intersect scripts like the following : if sprite (18) intersects sprite mySprite then sprite (18) .locH = sprite (18) .locH -10 This for example is the script to prevent the 'player' from entering from the left. I made a script for this and attached it to all objects that shouldn't be passed through the left. I have seperate scripts for the right, top and bottom. Each script is attached to the objects they belong to. However... after placing these scripts ...

  1. #1

    Default To many intersect scripts make Macro a sad panda

    Hello there,

    I'm trying to create a 2d game. To prevent my 'player' from walking through objects I am using intersect scripts like the following :

    if sprite (18) intersects sprite mySprite then
    sprite (18) .locH = sprite (18) .locH -10

    This for example is the script to prevent the 'player' from entering from the left. I made a script for this and attached it to all objects that shouldn't be passed through the left.
    I have seperate scripts for the right, top and bottom.
    Each script is attached to the objects they belong to. However... after placing these scripts on about 20 occasions I start receiving errors.

    --> script error. Sprite number wrong. <--

    As soon as I delete the latest attached sprite it works fine again. I don't know what the problem here is, but I figured I might prevent this by using a connector script in which I can define a list of sprites to which each script applies.
    for example, like this


    ---- Connector script-----

    on beginsprite me

    set mysprite to the spritenum of me
    set cbob to 18 -- sprite channel number of 'player' bob
    set cbill to 19 -- sprite channel number of 'player' bill
    set tblock to [23, 30, 31, 33] -- the sprite channels that should be handled with a top intersect script
    set bblock to [26, 27, 28, 29, 32, 33] -- the sprite channels that should be used in ....
    set rblock to [21,25,35,36,37,38,39,41] -- etc...
    set lblock to [22,23] -- etc...

    sendallsprites #storeShared, [#bob:cbob,#bill:cbill,#topBlock:tblock,#bottomBloc k:bblock,#rightBlock:rblock,#leftBlock:lblock]

    end

    --- intersect scripts--- I was planning on attaching this script to the 'player' sprites Bob and Bill
    ---instead of to all objects that they weren't supposed to pass. thus reducing the number of
    ---scripts
    ---from many to just 2...

    property mySprite
    property bob -- de sprite van Bob
    property bill -- de sprite van Bill
    property topBlock
    property bottomBlock
    property leftBlock
    property rightBlock


    on beginsprite me

    set mySprite to the spritenum of me

    end

    on storeShared me, gameSprites

    set bob to the bob of gamesprites -- bobs channel in de score, opgehaald in connection script
    set bill to the bill of gameSprites -- idem, maar dan voor Bill
    set topBlock to the topblock or gameSprites
    set bottomBlock to the bottomBlock of gameSprites
    set leftBlock to the leftBlock of gameSprites
    set rightBlock to the rightBlock of gameSprites

    end

    on exitframe me

    if sprite bob intersects sprite leftBlock then --- sprite leftBlock should, the way i thought it would, make sure that every sprite defined in the connector script as lBlock, in this case [22,23]
    sprite (bob) .locH = sprite (bob) .locH -10
    end if

    if sprite bill intersects sprite leftBlock then
    sprite (bill).locH = sprite (bill) .locH -10
    end if

    --- repeat for top, bottom and right intersects ---
    end



    Would anybody know either a: why I can't use my intersect scripts in a lot of different sprites
    or b: how I can create but one script in which I make sure all the appropriate sprites are effected...

    Thanks for taking your time to even read through this...


    irwhistle webforumsuser@macromedia.com Guest

  2. #2

    Default Re:question about using a lists to define multiple sprites in a script

    well there is a lot to work through there

    I cannot provide the answer but one thing you have done is to hard code the sprite numbers. eg sprites 18 and 19. Its easy to then accidently move these sprites. Check on the score to see if they are still in the same position. the same goes for the sprites which need to intersect.








    HAIRYBOBBY - why didn't I choose a really cool name like the vulcanpimp

    [url]http://www.geocities.com/hairybobby2000[/url]

    Photography section

    [url]http://www.geocities.com/hairybobby2000/px1.html[/url]

    Photoshop section

    [url]http://www.geocities.com/hairybobby2000/photo1.html[/url]
    hairybobby webforumsuser@macromedia.com Guest

  3. #3

    Default Re:question about using a lists to define multiple sprites in a script

    Nope, I fear that isn't it.
    The example code was hard coded but in the script itself i'm setting properties like in the second example.

    property bob
    property bill

    on beginsprite
    set property bob **
    set property bill **

    The code works fine until I use it for the 20 somethingth time. Might it be that i'm using the same script on to many different sprites?

    Thanks anyway.



    irwhistle webforumsuser@macromedia.com Guest

  4. #4

    Default Re: Re:question about using a lists to define multiple sprites in a script

    "irwhistle" <webforumsusermacromedia.com> wrote in message
    news:bi7vtq$dpt$1forums.macromedia.com...
    >
    > The example code was hard coded but in the script itself i'm setting
    > properties like in the second example.
    I suggest you post the *actual* script you're using as this will save people
    guessing what might be wrong without being able to see.

    - Robert


    Robert Tweed Guest

  5. #5

    Default Re:question about using a lists to define multiple sprites in a script

    SOLVED!!!! YIHAA!!!!

    For those even remotely interested. I found the problem.
    It turned out the reason my script didn't work after a certain sprite was because of the connector script I used.
    The connector script where I had placed all the definitions of my properties was located in Sprite Frame 72. When I started using it all sprites between 23 and 72 had been empty so I had at that time enough room to work in. However, after placing more and more sprites suddenly some scripts were placed in sprite frame 73 and +, and since the connector script needs to be the last script used all scripts beyond 72 didn't connect properly. I'v placed the connector scipt in spriteframe 150 now so I should be able to work fine from now on. Phew... what a way to solve a problem a day before the deadline.

    So for those ever encountering such a problem.

    Make sure your connection scripts are LAST in line! :)


    irwhistle webforumsuser@macromedia.com Guest

  6. #6

    Default Re:question about using a lists to define multiple sprites in a script

    sendAllSprites has no hiearchy rules on the score this is why we, or atleast me, where confused about. Meaning at the time before you figured this out, your script looked perfectly fine. HOWEVER, what was causing this was because you where tring to initialize all of the sprites before some of the evened called on beginSprite. For example,

    Here is an example of why sendAllSprites would work in any sprite channel...

    lets say you attach this script to sprite channel 1, and this script would be for allowing the user to drag sprite 1. Then on mouseUp, checks if the user is placeing sprite 1 onto another sprite by calling sendAllSprites with the #didItCollide. Then if any other sprites have the #didItCollide, will check if sprite 1 did collide and if so, then it will display an alert message "sprite 1 collided with such and such sprite".

    -- this is the script that has the command sendAllSprites(#didItCollide) which is in sprite channel 1
    property pSprite
    property pDrag
    property pOffset
    property sp

    on beginSprite me
    sp = sprite(me.spriteNum)
    pDrag = FALSE
    end

    on mouseDown
    pOffset = the mouseloc - sp.loc
    pDrag = TRUE
    end mouseUp

    on mouseUp
    if not pDrag then exit
    pDrag = FALSE
    sendAllSprites(#didItCollide)
    end mouseUp

    on mouseUpOutside me
    mouseUp(me)
    end mouseUpOutside


    on exitFrame
    if pDrag then
    sp.loc = the mouseLoc - pOffset
    end if
    end exitFrame

    .... and this is the script that has the #didItCollide whicb is attached to sprite channel 2

    on didItCollide me
    if sprite(1).intersects(sprite(me.spriteNum)) then
    alert "Sprite 1 has collided with sprite" && me.spriteNum
    end if
    end didItCollide

    and then I added a frame script to have the frame loop like this...

    on exitFrame
    go to the frame
    end exitFrame

    as you can see sendAllsprites(#didItCollide) was not called inside of on beginSprite, and thats why hiearchy wouldn't matter.


    Roofy webforumsuser@macromedia.com Guest

Similar Threads

  1. Question what strategy should adopt to brand after panda and penguin update?
    By williampritchard in forum RSS, APIs & Web Services
    Replies: 0
    Last Post: May 8th, 09:08 AM
  2. Makefile: set macro once (Solaris make, GNU make)
    By Heiner Steven in forum UNIX Programming
    Replies: 2
    Last Post: June 25th, 09:30 PM
  3. intersect sprites on still down: how?
    By george in forum Macromedia Director Lingo
    Replies: 1
    Last Post: August 14th, 11:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139