animated spot control Q

Post new topic   Reply to topic Scripting Questions View previous topic :: View next topic  
Author Message
Cheiron



Joined: 21 Apr 2005
Posts: 388
Location: Copenhagen, Denmark

PostPosted: Sun Jul 08, 2007 1:56 pm    Post subject: animated spot control Q Reply with quote

I want to do this:

a spot has two active states, with different pictures in it... creating an animation set with a timing device for each spotstates duration.

but I also want a trigger to turn it off and on... so ... a spotstate 0 with no picture or action at all... then spotstate 1 is first frame of picture, spotstate 2 is second frame.

to trigger spotstate 1 is simple...no problem

spotstate 1 and 2 you can make alternate back and forth with simple interface controls.

however if I want to turn the spot animation off and trigger spotstate 0 again (no spotpicture)... it can't due to the timer thing... cause it might go to spotstate 0 but due to timer... that script is still in function and will revert to spotstate 1 or 2 depending on when I tried to trigger spotstate 0, and spotstate 1 and 2 are of course set to alternate between them in a loop.

Clear to anyone out there? hehe
and any suggestions?
_________________
Cheiron
______________________________
"Any scientist with respect for himself should start
the day by rejecting his own pet hypotheses".
(Konrad Lorenz)

"Wir müssen wissen
Wir werden wissen"
(David Hilbert)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Studio 12
Site Admin


Joined: 04 Aug 2004
Posts: 67

PostPosted: Sun Jul 08, 2007 6:40 pm    Post subject: Reply with quote

Are you controlling everything with the script?

From reading what you wrote it sounds like you may be using a script and the timing features in the room editor for spot states. That would be the hard way and would end up with issues just like you spoke of.

Typically you need to create a animation loop with a script and then add break points. Possibly even a few different animation loops depending on what your doing. Probable not in this case.

Then comes the tricky part. Do you want the animations local or global? Also there are gworld features in The Manor where you do not have to use spot states. Yes totally dynamic images. Meaning you can rotate, move and resize images. Yes that is the more advance way of dealing with images but you gain much more control over them.

Sounds like your script can be done easier with spot states than with the gworld stuff seeing how it has only 3 frames (off, frame 1 , frame 2).

Have you got a script that your working with? If so can you post it so I can see what you have so far?
_________________
Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic.
Back to top
View user's profile Send private message
Cheiron



Joined: 21 Apr 2005
Posts: 388
Location: Copenhagen, Denmark

PostPosted: Sun Jul 08, 2007 11:33 pm    Post subject: Reply with quote

Well I actually got two spots... and need three.. but well... however so far working with two. The following script is triggers to set animation loops in two other spots. So in this case spot 10 contains below script and spots 11 and 12 each have 3 spotstates: spotstate 0 does nothing, spotstate 1 has a picture and is set to increment spotstate to 2 with timer on, spotstate 2 is set same way but decrements.

Code:

import manor

def mnr_outchat(chatText):
    if chatText == "anim1on":
        chatText = ""
        manor.setSpotState(12, 1, 1)
    if chatText == "anim1off":
        chatText = ""
        manor.setSpotState(12, 0, 1)
    if chatText == "anim2on":
        chatText = ""
        manor.setSpotState(11, 1, 1)
    if chatText == "anim2off":
        chatText = ""
        manor.setSpotState(11, 0, 1)
    return chatText


Also to add: seems it works first time you turn on and off... but then not again !

and yes... I want it global... the spots for pictures are set global, as well as the parameter in script, as you see.

hmmm you say that either it is script or editor to make it in huh or issues will occur?
_________________
Cheiron
______________________________
"Any scientist with respect for himself should start
the day by rejecting his own pet hypotheses".
(Konrad Lorenz)

"Wir müssen wissen
Wir werden wissen"
(David Hilbert)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Scotsman
Site Admin


Joined: 03 Aug 2004
Posts: 705
Location: MadWolf Software

PostPosted: Mon Jul 09, 2007 7:57 am    Post subject: Reply with quote

Just to clarify something before you get into trouble, DO NOT make animations global via the spot parameter. If you do every person in the room will be trying to override everybody elses spot state as the animations run locally for each user.
Back to top
View user's profile Send private message Visit poster's website
Studio 12
Site Admin


Joined: 04 Aug 2004
Posts: 67

PostPosted: Mon Jul 09, 2007 2:27 pm    Post subject: Reply with quote

Give this script a whirl. Be sure all the spots and spot states
in this script are using their default control setting which is all
off. The script takes care of the switching and timing of the animation.
Let me know how it works.

Code:
import manor

# Globals need to be declared when passing variables between all
# entry points and custom definitions.
# These globals are for switching the animations on and off.

global anim1Switch, anim2Switch

# After declaring the globals you need to set them. These are set
# to off. 0 is off and 1 is on.


anim1Switch = 0
anim2Switch = 0

# This custom definition is for changing the spot states. It has a timer
# set to 60 ticks. That is equal to one second. You can adjust the speed
# by changing the tick value.

def anim1Timer(param):
    global anim1Switch
    if anim1Switch == 1:
        anim1frame = manor.getSpotState(11)
        if anim1frame == 2:
            anim1frame = 0
        manor.setSpotState(11, anim1frame + 1, 1)
        manor.setTimer(manor.tickcount() + 60, anim1Timer, 0)

def anim2Timer(param):
    global anim2Switch
    if anim2Switch == 1:
        anim2frame = manor.getSpotState(12)
        if anim2frame == 2:
            anim2frame = 0
        manor.setSpotState(12, anim2frame + 1, 1)
        manor.setTimer(manor.tickcount() + 60, anim2Timer, 0)



def mnr_outchat(chatText):
    global anim1Switch, anim2Switch

    if chatText == "1on":
        chatText = ""
        anim1Switch = 1
        manor.setTimer(manor.tickcount() + 10, anim1Timer, 0)

    if chatText == "1off":
        chatText = ""
        anim1Switch = 0
        manor.setSpotState(11, 0, 1)

    if chatText == "2on":
        chatText = ""
        anim2Switch = 1
        manor.setTimer(manor.tickcount() + 10, anim2Timer, 0)

    if chatText == "2off":
        chatText = ""
        anim2Switch = 0
        manor.setSpotState(12, 0, 1)
    return chatText

_________________
Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic.
Back to top
View user's profile Send private message
Cheiron



Joined: 21 Apr 2005
Posts: 388
Location: Copenhagen, Denmark

PostPosted: Tue Jul 10, 2007 7:09 am    Post subject: Reply with quote

Yep it works ! thanks Studio.

however....

we do get random bouts of "exception calling timer callback".

and as Carl said: the control of animation is handled locally...so if two people start to mess with it, it goes nuts. -- on that note if the person triggering the animation leaves room, animation stops for everybody. It can however be turned off by another person in room and then turned on again.

on the happy side: if the animations are in action and a new person enters room, they will see it.. I couldn't make that work before.
_________________
Cheiron
______________________________
"Any scientist with respect for himself should start
the day by rejecting his own pet hypotheses".
(Konrad Lorenz)

"Wir müssen wissen
Wir werden wissen"
(David Hilbert)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Studio 12
Site Admin


Joined: 04 Aug 2004
Posts: 67

PostPosted: Tue Jul 10, 2007 7:29 am    Post subject: Reply with quote

Cool glad it is working. From what your saying it sounds like some more code is needed to control stuff so it doesn't mess up. I think the broadcasting features may overcome those issue if done correctly.

I haven't done much of that kinda of code, I mostly do stuff that is local. I can give it a shot to see if i can get it to work but I need to find time to do so. I should be able to post something in a few days.

If you want to give it a try also you can check the Star Hawk script, it uses all the broadcasting features to ping infomation back and forth to everyone in the room which keeps things in sync.
_________________
Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic All times are GMT - 6 Hours
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum