Hi there.
I'm currently working on a random script called Virtual Pet. Purely build with JavaScript. This script allows you to make your own virtual pet. As simple as that
Building a complete script of a huge collection of pet is pretty long, so it'll make time to build. And if you wanna suggest a pet/feature, please notify me, I'll add it directly in the script.
Feel free to comment.
After all, even the code's pretty long, it's still on progress.. maybe it's still 10% of 100%. Feel free to correct any grammar issues (lol).
I'm currently working on a random script called Virtual Pet. Purely build with JavaScript. This script allows you to make your own virtual pet. As simple as that
Building a complete script of a huge collection of pet is pretty long, so it'll make time to build. And if you wanna suggest a pet/feature, please notify me, I'll add it directly in the script.
Feel free to comment.
- Code:
[panda=js]// Virtual Pet script by eval
var virtualPet = true; // it means the script's successfully imported
// object literal
var pet = {
type: "",
name: "",
gender: "",
age: ""
};
// pet's type configuration
var prom = prompt("Type your pet's type!");
switch(prom.toLowerCase()) {
case "cat":
pet.type = "Cat"; break;
case "dog":
pet.type = "Dog"; break;
case "rabbit":
pet.type = "Rabbit"; break;
case "turtle":
pet.type = "Turtle"; break;
case "snake":
pet.type = "Snake"; break;
case "bird":
pet.type = "Bird"; break;
case "iguana":
pet.type = "Iguana"; break;
default:
alert("Please enter a valid pet type!");
}
// confirmation
if(pet["type"].length) {
alert("If you're ready, hit OK.");
}else{
alert("There was an error.");
}
// basic data
var prom2 = prompt("Enter your pet's name!");
pet.name = prom2;
var prom3 = prompt("Enter your pet's gender!");
if(prom3.toLowerCase() != "male" || prom3.toLowerCase() != "female") alert("Invalid gender.");
pet.gender = prom3;
var prom4 = prompt("Enter your pet's age!");
pet.age = prom4;
// checking data
alert("So far you've entered this data:");
alert(pet.type + ", " + pet.name + ", " + pet.gender + ", " + pet.age);
var con = confirm("Proceed with this datas?");
// some checks
if(con) {
document.cookie = "name=" + pet.name;
document.cookie = "gender=" + pet.gender;
document.cookie = "type=" + pet.type;
document.cookie = "age=" + pet.age;
alert("We've saved all of your pet basic datas.");
var con2 = confirm("If you're interested in outputting more data about your pet," + pet.name + " , please hit OK.");
}else{
pet.type = "";
pet.name = "";
pet.gender = "";
}
// pet's detail
if(con2 && virtualPet) {
var prom5 = prompt("Please type your pet's data. Anything, like fur color, fur length, etc.");
pet["details"] = prom5;
alert("Now you've created a complete virtual pet. Congrats!");
switch(pet.gender.toLowerCase()) {
case "male":
alert("Please take a good care of him. Your virtual pet can also get sick or even die. But even if your " + pet.type + "'s not sick, he cannot live forever."); break;
case "female":
alert("Please take a good care of her. Your virtual pet can also get sick or even die. But even if your " + pet.type + "'s not sick, she cannot live forever."); break;
}
}
After all, even the code's pretty long, it's still on progress.. maybe it's still 10% of 100%. Feel free to correct any grammar issues (lol).