Could anyone please check with this script that is fine to use?
It's just a simple script.
MAIN.P
//
// Rehatching script. *** USE WITH CAUTION. IT MAY CAUSE YOUR PLEO MALFUNCTION!!!***
//
// save space by packing all strings
#pragma pack 1
#include <Log.inc>
#include <property.inc>
#include <Script.inc>
#include <Sound.inc>
//#include "ages.inc"
#include "user_properties.inc"
#include "sounds.inc"
public init()
{
print("main::init() enter\n");
print("main::init() exit\n");
}
public main()
{
print("main::main() enter\n");
for (;;)
{
// give some time back to the firmware
while (property_get(property_age) > 2)
{
// Sounds are referred to by their filename,
// minus the extension, with a prefix of "snd_".
sound_play(snd_moo);
if (property_get(property_front_left_tapped))
{
// Reset the head tapped property, to indicate
// that we've taken action.
property_set(property_front_left_tapped, 0);
// Set age to hatch stage.
// NOW I'M STILL NOT SURE 1 OR 2 IS THE HATCHLING STAGE.
// AS IN INCLUDE IT SAY BIRTHING AND HATCHLING.
property_set(property_age = age_hatchling) // 2
}
}
// give some time back to the firmware
yield();
}
// left in, this generates an 'unreachable code' Pawn warning
//print("main::main() exit\n");
}
public close()
{
print("main:close() enter\n");
print("main:close() exit\n");
}
SENSORS.P
//
// sensors.p
// Properties Example
//
// This sensors.p script runs in the Sensors VM. It
// watches sensors and sets properties to notify the
// other scripts of certain events.
//
// The sensors used in this example are derived sensors
// and they may require that you use special methods to
// modify them. See the PDK documentation for more details.
//
// save space by packing all strings
#pragma pack 1
#include <Log.inc>
#include <Script.inc>
#include <Sensor.inc>
#include <Property.inc>
#include "user_properties.inc"
public init()
{
print("sensors:init() enter\n");
print("sensors:init() exit\n");
}
public on_sensor(time, sensor_name: sensor, value)
{
new name[32];
sensor_get_name(sensor, name);
printf("sensors:on_sensor(%d, %s, %d)\n", time, name, value);
switch (sensor)
{
// SENSOR_TOUCH_TAP tells us that a sensor
// has been tapped - the value passed by SENSOR_TOUCH_TAP
// is equal to the sensor that is being held.
case SENSOR_TOUCH_TAP:
{
if (sensor_name:value == SENSOR_FRONT_LEFT)
{
// Let other scripts know that the front left foot
// sensor has been tapped.
property_set(property_front_left_tapped, 1);
}
}
}
// reset sensor trigger
return true;
}
public close()
{
print("sensors:close() enter\n");
print("sensors:close() exit\n");
}
REHATCH.UPF
<upf_project name="rehatch">
<options>
<set name="top" value="../.." />
<include value="./include:${top}/include" />
<tools>
<pawn value="../../bin/pawncc33 %i -O2 -V8192 -v2 -S128 -C- %I -o%o" />
</tools>
<directories>
<build value="build" />
<include value="include" />
</directories>
<umf value="3" />
<folders />
</options>
<set-default name="MEDIA" value="../../media" />
<set name="SOUNDS" value="${MEDIA}/sounds" />
<set name="MOTIONS" value="${MEDIA}/motions" />
<set name="COMMANDS" value="${MEDIA}/commands" />
<set name="SCRIPTS" value="${MEDIA}/scripts" />
<resources>
<!-- Sounds -->
<sound path="${SOUNDS}/moo.wav" />
<!-- Motions -->
<!-- User Properties -->
<user_property path="front_left_tapped" />
<!-- Scripts -->
<script path="main.p" />
<script path="sensors.p" />
</resources>
</upf_project>
description :
When script run, it will check for current age stage. If it older than hatchling stage, Pleo will continuous moo. And if you press front left foot (of Pleo), it will re-aging back to hatchling stage.
todo :
add cancel button
PROBLEM :
In doc, it says no use for PROPERTY_AGE, so it must be relate with \pleo\age.inc. But now I'm still find out what's age variable. And other thing is I don't know which parameters need to pull down to hatchling level, which numbers need to put in.
As I read in Aibohack.com, this task can do with ChangeRB. But no any source. So I must keep figure it out.