>> NOW...i CAN keep track of when these ovens reaches 150 but i cant get the
>> value to decrese once it does so...(or increse when it reaches 1)
> 
> Don't add or subtract 1, instead add a variable that you change when
> it gets to the end:
> 
> if you use lists, one of them could be to hold the change value for
> each oven, and would start with a value of 1
> 
> ovens[whichoven] = ovens[whichoven] + tempchange[whichoven]
> if ovens[whichoven] = 0 or ovens[whichoven] = 150 then
> tempchange[whichoven] = tempchange[whichoven] * -1

Now that I've thought about this a bit more, this is a good example of how
you can use objects to simplify things. If you make a parent script for an
oven, and feed it a random temperature on initiation, then each "oven" can
keep track of its own temperature and either have its own internal methods
for dealing with that temperature (say, changing the color of its oven
sprite) or report its current temperature to another object that will do the
work. For example:

--------------------
property pTemp
property pTempChangeValue

on new me, temp
  pTemp = temp
  pTempChangeValue = 1
end

on mUpdateTemp me
  pTemp = pTemp + pTempChangeValue
  if pTemp = 150 then
    pTempChangeValue = -1
  else if pTemp = 1 then
    pTempChangeValue = 1
  end if
end

on mGetTemp me
  return pTemp
end
--------------------
If you create a number of instances of the script, and send all of them
mUpdateTemp calls at the same time, each will step up to 150 independently,
then down to 1, then back up. Each carries its own individual temperature,
which can be retrieved through the mGetTemp call. How you structure that
information depends on what you want to do with it. If you are simply
cycling a sprite's graphics to reflect an "oven"'s temperature, then you
might want to make the above a behavior, have each instance update the
temperature on exitFrame, and swap graphics by adding a method to the
behavior. Or, if you want to control them globally, you might want another
object that sends mUpdateTemp calls to all of the objects on exitframes, and
retrieves each instance's temp through the mGetTempCall to do whatever you'd
like it to do (getting back to lists, you could store each instance's
pointer in a list in the controlling object).

The main point is that you can make small objects that will update their
internal values, and report the values when asked, which will take the
"increase to 150, then decrease to 1" math out of the control mechanism.

2 more cents,
Kurt



[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to