Author Topic: Walking on Control Colours  (Read 8037 times)

0 Members and 2 Guests are viewing this topic.

Offline MusicallyInspired

Walking on Control Colours
« on: June 17, 2007, 02:03:30 PM »
I think I have a working code I just don't know where to put it to get it to work. Everything I've tried does nothing to the game. I have two versions of the code I want to use, here they are. I think the second one is the best one to use.

Code: [Select]
(if (== (send gEgo:onControl()) ctlGREEN)
(send gEgo:view(3))
)
(if (== (send gEgo:onControl()) ctlTEAL)
(send gEgo:view(4))
)
(if (== (send gEgo:onControl()) ctlGREEN)
(send gEgo:view(5))
)
(if (== (send gEgo:onControl()) ctlBLACK)
(send gEgo:view(0))
)
And
Code: [Select]

(if (== (send gEgo:onControl()) ctlGREEN)
(send gEgo:view(3))
)(else
(if (== (send gEgo:onControl()) ctlTEAL)
(send gEgo:view(4))
)(else
(if (== (send gEgo:onControl()) ctlGREEN)
(send gEgo:view(5))
)(else
(send gEgo:view(0))
)
)
)

I saw another code somewhere here that showed a code like this in a doit method. Where does that doit method go? I put it in both the Roomscript and public rm001 Instances but neither does anything in game when walking over control lines. Is there another instance I need to make or am I doing something wrong?


Brass Lantern Prop Competition

Offline troflip

Re: Walking on Control Colours
« Reply #1 on: June 17, 2007, 02:18:03 PM »
It goes in the doit method of the RoomScript, as
shown here.

You need to check if the ego is on a control colour every game cycle (30 or 60 times a second, I forget), and the doit method of a Script gets executed every game cycle - so that's why it has to go there.

You might want to use & instead of ==, for reasons shown here

btw, you have 2 ctlGREENs in your code.  The second one will never get hit.
« Last Edit: June 17, 2007, 02:25:59 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Walking on Control Colours
« Reply #2 on: June 17, 2007, 05:04:56 PM »
Thanks, I fixed the colour error.

Ok. I put it in where you said and even used & instead of == but it still does nothing ingame. Could it have something to do with the altered walk code I implemented a while back? The one that makes him switch to another stopped view when he's not moving?

EDIT: I think that's the case. I put in a code that turns him into a different view when you type "wade" and it didn't do anything. There must be a code somewhere that's disallowing the ego from changing views somewhere.

This is my Walk/Stop code in the Main script. Does this have anything to do with it?

Code: [Select]
(class StopWalk of Fwd
   (properties
      client 0
      caller 0
      cycleDir cdFORWARD
      cycleCnt 0
      completed 0
      vWalking 0
      vStopped 0
   )
   (method (init newClient walking stopped)
      (= vWalking walking)
      (= vStopped stopped)
      (super:init(newClient))
      (send client:view(vStopped)) // this avoids the "flicker" when the ego first appears

   )
   (method (doit)
      (if(not (send client:isStopped))
         (send client:view(vWalking))
         (super:doit())
      )
      (else
         (send client:view(vStopped))
      )
   )
)
« Last Edit: June 17, 2007, 05:38:15 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Walking on Control Colours
« Reply #3 on: June 17, 2007, 05:54:37 PM »
I'm not quite sure I follow you, but if you switch the ego's view, it's possible his footprint (what is used to check which control colours he is on) will be different, and so he'll be on different colours.  I don't think that would really end up mattering though.

What I do when I'm having trouble diagnosing onControl problems, is print out the control mask in the menu bar (since I don't want a Print dialog coming up every game cycle).  I make a function called FormatStatus, which works like FormatPrint, but prints to the menubar instead.  I have it in Controls.sc, but you can put it in the room where you're having trouble for the time being, that way you don't need to recompile everything.

Code: [Select]
(procedure public (FormatStatus textorstring textid params)
(var temps[50])
(if(<u textorstring 1000)
Format(@temps textorstring textid rest params)
)(else
Format(@temps rest textorstring)
)
DrawStatus(@temps)
)

Then in your doit method, have something like
Code: [Select]
FormatStatus("ego is on: %04x   " (send gEgo:onControl()))

Then compare the value you see in the menubar with those in the 2nd link I provided above.  That should tell you exactly which colours the ego is on.  (assuming you know how to work with hexadecimal)

If you see
"ego is on: 0046"

then you know the ego is on
ctlBROWN      ($0040)
ctlNAVY          ($0002)
ctlGREEN        ($0004)




« Last Edit: June 17, 2007, 05:57:44 PM by troflip »
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Walking on Control Colours
« Reply #4 on: June 17, 2007, 06:03:37 PM »
Actually I don't know how to work with hexadecimals.  :-\

What I meant, though, is that instead of using control colours I tried implementing the...
Code: [Select]
(send gEgo:view(3))
...code in a said statement and it still wouldn't change.
« Last Edit: June 17, 2007, 06:05:09 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Walking on Control Colours
« Reply #5 on: June 17, 2007, 06:55:05 PM »
Oh yes, your StopWalk thing is stomping whatever you do (since it sets the ego's view in its doit method, which is executed every game cycle).

The fix is easy, but you've got a bit of a design problem here.  You're saying "when the ego walks use this view, and when he stops use this one", but then you're also saying "when he's on this colour, use this one".  What's the game supposed to do?

I guess if you want to use both the same view for walking and stopped for now, then instead of
Code: [Select]
(send gEgo:view(3))

you can just do:

Code: [Select]
(send gEgo:setCycle(StopWalk 3 3))


Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Walking on Control Colours
« Reply #6 on: June 17, 2007, 07:26:11 PM »
Yeah, I figured this would be a problem when I came to this part. My whole idea is I want ego to change views as he goes deeper into water (to ankles, to knees, to waist, then swimming).

Is there any way I can make the StopWalk code only work when the ego's view is set to 0? For instance if I changed the ego's view to 4 instead of 0 it wouldn't need a stop view since I'm perfectly happy with it using the same view for wading or swimming when the ego isn't moving (like the old style "freeze-frame" like walk code). But when ego's view is changed to 0 again then the StopWalk code is activated. I wonder how I would go about that. I suspect I'll have to alter my StopWalk code in the Main script.

EDIT: Oh! Never mind that code you put there works perfectly. I forgot you could just alter the views since StopWalk is a class. Thanks!
« Last Edit: June 17, 2007, 07:29:08 PM by MusicallyInspired »
Brass Lantern Prop Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.038 seconds with 18 queries.