Author Topic: Attempting to capture the changestate state to a global variable  (Read 975 times)

0 Members and 1 Guest are viewing this topic.

Offline Cloudee1

Attempting to capture the changestate state to a global variable
« on: November 12, 2013, 09:31:03 AM »
Ok, so I have a global variable declared in the main script, rememberState. I have an actor who is being controlled in it's own script, passingBy which just consists of a changestate. The actor walks from off screen all the way across offscreen and back. I have a local variable whichWalker set up so that the view is randomly selected.

Code: [Select]
(instance passerBy of Act(properties x -10 y 133 view 504 loop 0))

(instance passingBy of Script
(properties)
  (method (changeState newState)
  = state newState
    (switch (state)
      (case 0  = whichWalker Random(504 505)
             (passerBy:view(whichWalker))
             = seconds Random(4 12)
               )
      (case 1  (passerBy:setCycle(Walk) setMotion(MoveTo 330 133 passingBy)))
      (case 2 = whichWalker Random(504 505)
             (passerBy:view(whichWalker))
             = seconds Random(8 16)
               )
      (case 3 (passerBy:setCycle(Walk) setMotion(MoveTo -10 133 passingBy)))
      (case 4 (self:changeState(0)))
    ) // switch end
  ) // method end
) // instance end

I am trying to capture the current state number of the passingBy script to the global variable so that I can leave the room and start the actor back up where it left off upon return. I had thought that this would work

Code: [Select]
= rememberState (passingBy:changeState)

Unfortunately I was wrong. Anyone have any ideas on how I can accomplish this



Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline gumby

Re: Attempting to capture the changestate state to a global variable
« Reply #1 on: November 12, 2013, 03:16:32 PM »
Yes, create a property called 'state', then you should be able to do this:

Code: [Select]
=rememberState (passerBy:state)
In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.083 seconds with 23 queries.