2 Replies Latest reply on Nov 10, 2009 3:34 PM by greek_dude247

    Can someone explain to me how this line of code works?

    greek_dude247 Level 1

      My friend put in this code to my game script

       

      if CollisionDistance < 2 then

       

      else if "pMushroom" = string(collisionModel).char[8..16] then

      pInfo = member("Info") 
            pInfo.Text = "Press 'F' to consume Mushroom"

       

      else

       

      end if

       

      else
          pInfo = member("Info") 
          pInfo.Text = ""
        end if

       

      So this is used in my game so that when a ray is less than 2 units away to hits an object named pMushroom, instructions would come up that say "Press 'F' to consume Mushroom" (I'm sure you already knew that though).

       

      I have a bunch of mushrooms out lebed pMushroom01 - pMushroom09

       

      I tried to use this for other models like:

       

      else if "pStick" = string(collisionModel).char[8..16] then

      pInfo = member("Info") 
             pInfo.Text = "Press 'F' to take Stick"

       

      But the instructions do not pop up. I've checked that I was the right distance away with my collision detection.

       

      Could someone explain to me the code and what could possibly be wrong?

       

      "char[8..16]" is what I really don't get.