Welcome, Guest. Please login or register.
Did you miss your activation email?

Username: Password:


Pages: [1]   Go Down

Author Topic: Randomizing Pleo  (Read 4744 times)

Getorix

  • Following the footsteps
  • * Posts: 12
  • Male
Randomizing Pleo
« on: November 30, 2009, 01:34:38 AM »

TASK:
Make Pleo to behave in a different way according to random number generator value.

SOLUTION:
Add the following code to the main.p file:
Code: [Select]
#include <Time.inc>
#include <Util.inc>

then add this code to public init() function:
Code: [Select]
seed(time());
Add the following code to the sensors.p file:
Code: [Select]
#include <Sound.inc>
#include <Util.inc>

#include "sounds.inc"

then add this code to public on_sensor(time, sensor_name: sensor, value) function:
Code: [Select]
   new snd_num = rand(2);    

    switch (sensor)
    {
        case SENSOR_TOUCH_HOLD:
        {
            if (sensor_name:value == SENSOR_HEAD)
            {
if (snd_num == 0)
{
         sound_play(snd_bite);
            
                  // Wait for the sound to complete.
                  while (sound_is_playing(snd_bite))
                  {
                     sleep;
                  }
                }

if (snd_num == 1)
{
         sound_play(snd_moo);
            
                  // Wait for the sound to complete.
                  while (sound_is_playing(snd_moo))
                  {
                     sleep;
                  }
                }

if (snd_num == 2)
{
         sound_play(snd_kisses);
            
                  // Wait for the sound to complete.
                  while (sound_is_playing(snd_kisses))
                  {
                     sleep;
                  }
                }

            }
        }    
    }

Please find these project files in attach [random.rar]

Enjoy.

P.S. This is my first project for Pleo, so sorry for the random.upf file content, I am not quite sure how to create them by now (have to read manual).
P.P.S. I look forward for any ideas how to use it in interesting way :)
« Last Edit: November 30, 2009, 01:50:00 AM by Getorix »
Logged


InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Randomizing Pleo
« Reply #1 on: November 30, 2009, 01:44:56 AM »

That is great!!! Just what I needed :) I plan on using that information to create a mini personality (or two :P) a Christmas one for now and later I can redo the sleepy time personality that I made earlier :)
Logged
Eagerly awaiting Vector and Blue!

Getorix

  • Following the footsteps
  • * Posts: 12
  • Male
Re: Randomizing Pleo
« Reply #2 on: November 30, 2009, 01:54:40 AM »

No worries :)
If you (or someone else) have anything else to "code" just ask.
Logged

InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Randomizing Pleo
« Reply #3 on: November 30, 2009, 03:15:15 PM »

There are a few people that will be very interested but I haven't seen most of them in a while, I know that one is very ill :( Not sure about the others, hopefully they turn up soon :)
Logged
Eagerly awaiting Vector and Blue!

InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Randomizing Pleo
« Reply #4 on: December 20, 2009, 09:11:57 PM »

Woohoo!!! Hehe. It worked spot on, thank you, thank you, THANK YOU!!!

Teehee can't wait to unveil my little pet project :D
Logged
Eagerly awaiting Vector and Blue!

InmemoryofRomeo

  • Global Moderator
  • Pleo Grand Master RB
  • * Posts: 6903
  • au Female
  • Pleo(s): Lilo, Stitch, Pleakley, Jumba, Nani, Yuki, Angus, Pluto
  • : 2011 winner2009 winnerTomato Harvest Festivals
  • SAVE THE EARTH It's the only planet with chocolate
    • Professor
    • Wile_E_Coyote
    • Marcie
Re: Randomizing Pleo
« Reply #5 on: December 20, 2009, 10:48:58 PM »

Question though, does anyone know how to use the TIMER sensor, ie: getting Pleo to play sounds/motions without physical imput like touching the head. I have it working fine by touching the back but would much prefer to have Pleo just play random skits like in the Holiday personality.
Logged
Eagerly awaiting Vector and Blue!

Getorix

  • Following the footsteps
  • * Posts: 12
  • Male
Re: Randomizing Pleo
« Reply #6 on: December 23, 2009, 04:27:09 PM »

I've created new topic for this issue: Using SENSOR_TIMER
Logged
Pages: [1]   Go Up
 

SimplePortal 2.3.5 © 2008-2012, SimplePortal