calling a function from text.

Ask a Question related to Macromedia Director 3D, Design and Development.

  1. #1

    Default calling a function from text.

    simply, I am making a 3d game. You have a weapon. It shoots stuff, which reacts differently. I want a system where I can call a function based on some text, so if the object you hits name is "grassFloor" then how can I go from that to calling function grassFloor(). I can't use if statements because I want this engine to be really expandable, so I can add objects and functions for them and thats that, they should work. What I'm asking is how can you call a function based on text, so if I had the text "grassFootsteps" I could turn that into a function call to the function grassFootsteps(). Thanks, I hope I have been clear enough, Will Hogben.


    Will Hogben webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Calling a function within a function registered to an event
      Hey, Just registered and tried to search through the forum for a solution to my problem, but I haven't found anything that could help me. I've...
    2. name of calling function
      Hi folks, In the back of my mind I seem to think that you can find out where a function was called from. What I'm after is: my...
    3. Function calling from url
      Good morning! I would like to call a function from a <FORM>'s ACTION attribute. This is what I'm trying to do: <FORM...
    4. Function/Global var to return name of calling function?
      I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name...
    5. calling c function from php app
      Did you get vertex tax integrated? I am trying to implement that for a client right now. Any help would be great. Thanks, Chris ...
  3. #2

    Default calling a function from text.

    simply, I am making a 3d game. You have a weapon. It shoots stuff, which reacts differently. I want a system where I can call a function based on some text, so if the object you hits name is "grassFloor" then how can I go from that to calling function grassFloor(). I can't use if statements because I want this engine to be really expandable, so I can add objects and functions for them and thats that, they should work. What I'm asking is how can you call a function based on text, so if I had the text "grassFootsteps" I could turn that into a function call to the function grassFootsteps(). Thanks, I hope I have been clear enough, Will Hogben.


    Will Hogben webforumsuser@macromedia.com Guest

  4. #3

    Default Re: calling a function from text.

    I don?t know how to convert text to a function but I think there might be another way around your problem:
    What about dynamic ancestors?

    Make ?stuff you shoots? have a property list containing different ancestor scripts
    (MyAncestors) which control ?stuff you shoot? accordingly.

    Whenever ?stuff you shoot? hits something get a property from the thing its hit(reactionID).

    Set ?stuff you shoot?s ancestor = MyAncestors(reactionID)

    Des.



    Desmond22 webforumsuser@macromedia.com Guest

  5. #4

    Default Re: calling a function from text.

    sorry to dissapoint you will but i just wanted to know if des had msn or aim, do you des.. its kinda hard to talk over this.. and you could probably help me loads with a 5 min chat


    xaplax webforumsuser@macromedia.com Guest

  6. #5

    Default Re: calling a function from text.

    Hi


    I do like this:

    Obj1 = an Object like bullet
    Obj1 = an object like Pig

    if obj1 and obj2 collide then

    obj1.CheckCollide(obj2)

    obj2.CheckCollide(obj1)

    In every object a have a CheckCollide(inObj) function and from there i can do different things in every object depending on what in object that comes in. And you can call on functions in the inObj.

    ---the Bullet
    On CheckCollide me , InObj

    InObj.DoStuffOnHit --Pig obj


    inObj.Armour =inObj.Armour - Damage
    if inObj.Armour<0 then inObj.Alive = 0

    End

    If its to some help?

    I did like this in my last game and it did work out well.

    /M






    MosseMilk webforumsuser@macromedia.com Guest

  7. #6

    Default Re: calling a function from text.

    In article <beuthi$8oo$1@forums.macromedia.com>, "Will Hogben"
    [email]webforumsuser@macromedia.com[/email] wrote:
    >thats that, they should work. What I'm asking is how can you call a
    function >based on text, so if I had the text "grassFootsteps" I could
    turn that into a >function call to the function grassFootsteps().

    -- assuming "on grassFootsteps" is a handler in a movie script
    thestring = "grassFootsteps"
    do thestring & "()"

    Gretchen Macdowall
    [url]http://www.updatestage.com/[/url]
    Gretchen Macdowall Guest

  8. #7

    Default Re: calling a function from text.

    Er, no, actually I don't want to have to make a load of objects in code. What I want to do is just have the 3d models in my scene, and knowing ony what the name of the model is, ie: stoneBlock, determine what kind of shrapnel to blow from the bullet hole. Basicly I want to write functions with the names of the models, and have the code find them on its own knowing only the model names. I don't want to have a parent script for every object in the level, or a complex if statement system that checks to see if the model name contains stone and then calls a stoneBits() function. I want it to start with this data, a single string of characters, and call a function by the same name. is there no way to turn ("punchMe") into a call to function punchMe()?


    Will Hogben webforumsuser@macromedia.com Guest

  9. #8

    Default Re: calling a function from text.

    look up the lingo command 'do'

    'do ( ;-D )



    Aldo Hoeben Guest

  10. #9

    Default Re: calling a function from text.

    I think I know what you mean - I'm not sure I know the answer but I've seen people do something like this. I think it uses a "Do command" or "do code" . Check out everything under "do " in help.

    sorry I can't be more specific but no one elses answered the question

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

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

    see my photos of the sunrise eclipse

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

  11. #10

    Default Re: calling a function from text.

    As I understand it, you want to preprocess the scene so that your groups of models are kept in lists: terrainobjects, targetobjects, etc... This way when you do your ray casting the modelname that is returned can be compared to the lists to determine what "class" it belongs to and react accordingly. you don't have to use an if statement, but you will need some condition operator such as the case statement.

    case (modeltype) of:
    terrainobj:
    grassfootsteps(modelname)
    targetobj:
    explodeobject(modelname)
    otherwise:
    nothing
    end case

    you will need to name the objects in your scene using some convention so that when you preprocess the scene you can use lingo's string comparison functions to extract some portion of the modelname to determine its type. i.e., prefix all terrain objects with "terrain", and store it in the terrainobj list.



    flashjedi webforumsuser@macromedia.com Guest

Posting Permissions

  • You may not post new threads
  • You may 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