xs_infomatic.lsl 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. // :CATEGORY:XS Pet
  2. // :NAME:XS Pet Robot
  3. // :AUTHOR:Ferd Frederix
  4. // :KEYWORDS: Pet,XS,breed,breedable,companion,Ozimal,Meeroo,Amaretto,critter,Fennux,Pets
  5. // :CREATED:2013-09-06
  6. // :EDITED:2014-05-18
  7. // :ID:988
  8. // :NUM:1466
  9. // :REV:0.52
  10. // :WORLD:Second Life, OpenSim
  11. // :DESCRIPTION:
  12. // XS Pet xs_infomatic
  13. // :CODE:
  14. // xs_infomatic
  15. // This code handles the hovertext and also the Dialog boxes
  16. // 4-10-2013 V 0.43 Lots of casting to fix Opensim 0.7.4 failures to parse llList2Float and llList2Integer when there are strings in the list
  17. // 12-9-2013 C 0.48 added Breed name string
  18. // START OF COPIED file 'Global Constants.txt' from the Debug folder. It has to be the same in all files
  19. // If you change this in any script, change it in all of them, please. It works a lot better that way.
  20. // This is code based on Version 0.50 01-30-2014
  21. // For version history, see file revisions.txt
  22. //
  23. // LICENSE
  24. /////////////////////////////////////////////////////////////////////
  25. // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike
  26. // See http://creativecommons.org/liceses/by-nc-sa/3.0/
  27. // Noncommercial -- You may not use this work for commercial purposes, i.e., you cannot sell this script in any form, including derivatives.
  28. // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
  29. // This means that you cannot sell this or derivative code by itself, but you may share and use this code in any object or virtual world.
  30. // You must attribute authorship in the original scripts to Ferd Frederix and Xundra Snowpaw, and leave this notice intact.
  31. // You do not have to give back to the community any changes you make, however, code changes would be greatly appreciated!
  32. //
  33. // Exception: I am allowing this script to be used in an original build and sold with the build.
  34. // You are not selling the script, you are selling the build. If you want to sell these scripts, write your own or use the original at http://code.google.com/p/xspets/
  35. // Note: Xundra Snowpaw's license was 'New BSD' license and adding additional licenses is allowed.
  36. // Based on code from Xundra Snowpaw
  37. // New BSD License: http://www.opensource.org/licenses/bsd-license.php
  38. // Copyright (c) 2010, Xundra Snowpaw
  39. // All rights reserved.
  40. // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  41. //* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  42. //* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
  43. // in the documentationand/or other materials provided with the distribution.
  44. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  45. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
  46. // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  47. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  48. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  49. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  50. ////////////////////////////////////////////////////////////////////
  51. // DEBUG - lets you see and hear wtf is happening
  52. integer debug = FALSE; // set to TRUE TO hear a lot of chat
  53. // This section has a few tuneable items that MUST be changed for any new pet
  54. // SECURITY
  55. string SECRET_PASSWORD = "top secret string"; // must use a password unique to any species of animal, when ENCRYPT= TRUE. Otherwise you will find Pet type A fucking pet type B.
  56. integer SECRET_NUMBER = 99999; // any number thats a secret, not necessary to change usually, this is used when pets are born and eggs are rezzed to establish a comm channel.
  57. integer ENCRYPT = TRUE; // set to TRUE to encrypt all data, Some Opensim worlds prefer FALSE due to parsing bugs, TRUE is the most secure. If FALSE you MUST change the FOOD_CHANNEL and other channels for different pets. or they will literally fuck each other.
  58. // if you add the UUID for your avatar here, you can change it later
  59. // and other alts or friends can change it too, and all of you can work on these pets.
  60. // If you leave it blank, only the creator of the root prim can work on these pets.
  61. key YOUR_UUID = "";
  62. // PET NAMES - YOU MUST CHANGE THEM HERE AND IN THE ROOT PRIM OF THE OBJECT - THEY MUST MATCH EXACTLY
  63. /////////////////////////
  64. string MaleName = "Troubot"; // Must be the name of your animal
  65. string FemaleName = "Troubot"; // The name of the female pet, if a different shape or prim count. Can be the same as the Male for pets like the robot that are unisex.
  66. string Egg = "Nut and Bolt"; // was 'XS Egg', must be the name of your egg
  67. string Crate = "Transport Spaceship"; // was XS-Cryocrate, must be the name of the crate you package pets in
  68. string HomeObject = "Home Flag"; // was "XS Home Object", must be the name of your Home Post indicator
  69. string EggCup = "Toolbox"; // was "XS Egg Cup", must be the name of your egg holder
  70. // any other object names are 'do not cares'.
  71. // NOTHING NEEDS TO BE CHANGED BELOW, BUT CAN BE CHANGED IF YOU DO IT EVERYWHERE
  72. // misc tunables
  73. float GROWTH_AMOUNT = 0.10; // 10% size increase each day for MaxAge days = 200% (double size after 7 days)
  74. integer MaxAge = 7; // stop growing in seven days. 10% growth compounded daily means that your pet will be 194% larger ( 2x, basically) in 7 days.
  75. integer UNITS_OF_FOOD = 168; // food bowl food qty, used by food bowl only
  76. float secs_to_grow = 86400; // grow daily = 86400 seconds
  77. float FOOD_BOWL_SCAN_INTERVAL = 10800.0; // look for food every 3 hours
  78. float fPregnancy = 172800.0; // how many seconds to lay an egg = 2 days or 48 hours.
  79. float MALE_TIMEOUT = 900.0 ; // in seconds, female waits this long in one spot for a male to arrive
  80. float SEX_WAIT = 10800.0; // How often they desire sex = 3 hours
  81. float fDaysToAdult = 7; // 7 days to become old enough to breed.
  82. integer SECONDS_BETWEEN_FOOD_NORMAL = 14400; // number of seconds to get hungry = 4 hours
  83. integer SECONDS_BETWEEN_FOOD_HUNGRY = 3600; // number of seconds before hunger count increases = 1 hour
  84. integer MAXIMUM_HUNGER = 30; // They die after a month with no food.
  85. // I control versions by Subversion Source Code Control. But the updater needs a version numbert in world.
  86. // This is the Protocol version. If you change this, then all pets with a lower version will be updated by the updater
  87. float VERSION = 0.50;
  88. // the leg sizes are safe to leave alone or set to 0 if you use a thin base prim, these are from the original Quail
  89. float LegLength = 0.064; // length of pet leg??? - not sure
  90. float LegOffset = 0.052399; // This is added to the Post Z to position the pet
  91. // the following are global constants and do not need to be changed
  92. // Prim animation linkmessages are sent by scripts on Link Message number 1
  93. // The strings are the names of the animations that are recorded.
  94. // No need to change them unless you want to change names of the animations when you run the prim animator, or you add additional link messages
  95. // If your pet walks, you need to record these names and save them in the notecard
  96. //
  97. // Example:
  98. // llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
  99. // The above line will play the pre-recorded 'stand up' animation "stand" using the animator script.
  100. // The following animations are used in the pet. You can add your own.
  101. string ANI_STAND = "stand"; // default standing animation
  102. string ANI_WALKL = "left"; // triggers Left foot and Right arm walk animation
  103. string ANI_WALKR = "right"; // triggers Right foot and Left arm walk animation
  104. string ANI_SLEEP = "sleep"; // Sleeping
  105. string ANI_WAVE = "wave"; // Calling for sex, needs help with food, etc.
  106. // Channel assignments
  107. // if you change any of these constants, change it everywhere and in the list in XS_Debug so it can print them
  108. // If you turn encryption FALSE, you MUST change these between species of pets are they will fuck with each other. Literally.
  109. integer FOOD_CHANNEL = -999191;
  110. integer ANIMAL_CHANNEL = -999192;
  111. integer EGG_CHANNEL = -999193;
  112. integer HOME_CHANNEL = -999194;
  113. integer BOX_CHANNEL = -999195;
  114. integer ACC_CHANNEL = -999196;
  115. integer UPDATE_CHANNEL = -999197;
  116. integer API_CHANNEL = -999198;
  117. // global link messages to control the animal, never any need to change these.
  118. // They are exposed here so they will be the same everywhere. This uses a bit of RAM, but who cares?
  119. integer LINK_ANIMATE = 1; // messages on num 1 are assumed to be directed at the prim animator.
  120. integer DECREASE_FOOD = 100; // used in the food bowl.
  121. integer LINK_AGE_START = 800; // when pety is rezzed and secret_number is sent by brain to breeder, eater and infomatic get booted up
  122. integer LINK_TEXTURE = 801; // ask for a new texture, or paint a color
  123. integer LINK_BREEDNAME = 802; // the name of the pet texture from the texture server notecard
  124. integer LINK_FOOD_CONSUME = 900; // from movement to brain when close to food, brain then consumes a random amount up to 10000
  125. integer LINK_FOODMINUS = 901; // xs_brain receives FOOD_CONSUME, decrement hunger (eat)
  126. integer LINK_HUNGRY = 903; // sent by eater (string)hunger_amount, checks each hour
  127. integer LINK_HAMOUNT = 904; // hunger_amount = (integer)str,m updates the hunger amount in scripts
  128. integer LINK_SET_HOME = 910; // loc ^ dist
  129. integer LINK_MOVER = 911; // tell mover to rest for str seconds
  130. integer LINK_FOODIE_CLR = 920; // clear all food_bowl_keys and contents
  131. integer LINK_FOODIE = 921; // send FOOD_LOCATION coordinates to movement
  132. integer LINK_COLOR1 = 930; // colour1
  133. integer LINK_COLOR2 = 931; // colour2
  134. integer LINK_SEX = 932; // sex
  135. integer LINK_SHINE = 933; // shine
  136. integer LINK_GLOW = 934; // glow
  137. integer LINK_GEN = 935; // generation
  138. integer LINK_RESET_SIZE = 936; // reset size to 1
  139. integer LINK_MAGE = 940; // xs_brain sends, xs_ager consumes, adds str to age, if older than 7 days, will grow the animal
  140. integer LINK_DAYTIME = 941; // xs_ager consumes, starts a timer of 86,400 seconds in xs_ager
  141. integer LINK_GET_AGE = 942; // get age from xs_ager and sent it on channel 943
  142. integer LINK_PUT_AGE = 943; // print age from xs_ager
  143. integer LINK_PACKAGE = 950; // look for a cryo_crate
  144. integer LINK_SEEK_FEMALE = 960; // MALE_BREED_CALL
  145. integer LINK_MALE_BREED_CALL = 961; // triggered by LINK_SEEK_FEMALE
  146. integer LINK_SIGNAL_ELIGIBLE = 962; // sent by female when hears LINK_MALE_BREED_CALL
  147. integer LINK_FEMALE_ELIGIBLE = 963; // sent when it hears in chat FEMALE_ELIGIBLE
  148. integer LINK_CALL_MALE = 964; // if LINK_FEMALE_ELIGIBLE && looking_for_female
  149. integer LINK_MALE_ON_THE_WAY = 965; // triggered by LINK_CALL_MALE
  150. integer LINK_FEMALE_LOCATION = 966; // female location, sends coordinates of a female
  151. integer LINK_RQST_BREED = 967; // sent when close enough to male/female
  152. integer LINK_CALL_MALE_INFO = 968; // sent by xs_breeding, this line of code was in error in v.24 of xs_breeding see line 557 and 636 of xs_brain which make calls and also xs_breeding which receives LINK_MALE_INFO.
  153. integer LINK_MALE_INFO = 969; // Breeding failed, sent info
  154. integer LINK_LAY_EGG = 970; // Rez Object(Egg...
  155. integer LINK_BREED_FAIL = 971; // key = father, failed, timed out
  156. integer LINK_PREGNANT = 972; // chick is preggers
  157. integer LINK_SOUND_OFF= 974; // sound is off
  158. integer LINK_SOUND_ON= 973; // sound is on
  159. integer LINK_SLEEPING = 990; // close eyes
  160. integer LINK_UNSLEEPING = 991; // open eyes
  161. integer LINK_SOUND = 1001; // plays a sound if enabled
  162. integer LINK_SPECIAL = 1010; // xs_special, if str = "Normal", removes script
  163. integer LINK_EFFECTS_ON = 2000; // particle effects in the packger
  164. integer LINK_PREGNANCY_TIME = 5000; // in seconds as str
  165. integer LINK_SLEEP = 7999; // disable sleep by parameter
  166. integer LINK_TIMER = 8000; // scan for food bowl about every 1800 seconds
  167. integer LINK_DIE = 9999; // death
  168. string Copyright = " (c)2014 by Ferd Frederix"; // You cannot change this line, but you can change the code that prints it!
  169. // See License agreements above.
  170. // Attribution is required, as these files are copyrighted.
  171. DEBUG ( string msg){
  172. if (debug) {
  173. llOwnerSay(llGetScriptName() + ":" + msg);
  174. }
  175. }
  176. ///////// end global Link constants ////////
  177. // END OF COPIED CODE
  178. string sBreedName; // hold the breed name fronm texture server, if any
  179. integer hunger_amount;
  180. vector colour1;
  181. vector colour2;
  182. integer sex;
  183. integer shine;
  184. float glow;
  185. string pregnant;
  186. string sleep;
  187. integer gen;
  188. integer name_listener;
  189. integer menu_listener;
  190. integer age;
  191. integer play_sounds;
  192. string special;
  193. integer menu_expired;
  194. integer sleep_disabled;
  195. string gHEX_STRING = "0123456789abcdef"; // hex string index **uses lower case
  196. // vector values of all known system colors
  197. list sysColorsVector;
  198. // names of all known system colors
  199. list sysColorsName;
  200. string HTML2SysColorBestMatch(vector userColor)
  201. {
  202. // place holder for the system color to match
  203. // start with a large variance and narrow down
  204. float variance = 2.0;
  205. float test;
  206. integer index;
  207. integer count = llGetListLength(sysColorsVector);
  208. integer i;
  209. for (i=0;i<count;i++)
  210. {
  211. test = llVecMag(userColor - llList2Vector(sysColorsVector, i));
  212. if (test < variance)
  213. {
  214. variance = test;
  215. index = i;
  216. }
  217. }
  218. return llList2String(sysColorsName, index);
  219. }
  220. say_details()
  221. {
  222. string mysex;
  223. string myshine;
  224. if (sex == 1) {
  225. mysex = "Male";
  226. } else
  227. if (sex == 2) {
  228. mysex = "Female";
  229. } else {
  230. mysex = "unknown - not configured correctly";
  231. }
  232. if (shine == 0) {
  233. myshine = "None";
  234. } else
  235. if (shine == 1) {
  236. myshine = "Low";
  237. } else
  238. if (shine == 2) {
  239. myshine = "Medium";
  240. } else
  241. if (shine == 3) {
  242. myshine = "High";
  243. }
  244. if (llStringLength(sBreedName))
  245. llWhisper(0, "Breed: " + (string)sBreedName);
  246. llWhisper(0, "Color1: " + HTML2SysColorBestMatch(colour1));
  247. llWhisper(0, "Color1: " + HTML2SysColorBestMatch(colour2));
  248. llWhisper(0, "Shine: " + myshine);
  249. llWhisper(0, "Glow: " + (string)((integer)(glow * 100)) + "%");
  250. llWhisper(0, "Special: " + special);
  251. llWhisper(0, "Sex: " + mysex);
  252. llWhisper(0, "Age: " + (string)age + " days");
  253. llWhisper(0, "Generation: " + (string)gen);
  254. // the API channel is unused at this time. You can use it for whatever
  255. llSay(API_CHANNEL, "XSPet^" + (string)llGetKey() + "^" + sBreedName + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSPetEnd");
  256. }
  257. default
  258. {
  259. state_entry()
  260. {
  261. sysColorsVector =
  262. [
  263. <0.941176,0.972549,1.000000>,
  264. <0.980392,0.921569,0.843137>,
  265. <0.000000,1.000000,1.000000>,
  266. <0.498039,1.000000,0.831373>,
  267. <0.941176,1.000000,1.000000>,
  268. <0.960784,0.960784,0.862745>,
  269. <1.000000,0.894118,0.768627>,
  270. <0.000000,0.000000,0.000000>,
  271. <1.000000,0.921569,0.803922>,
  272. <0.000000,0.000000,1.000000>,
  273. <0.541176,0.168627,0.886275>,
  274. <0.647059,0.164706,0.164706>,
  275. <0.870588,0.721569,0.529412>,
  276. <0.372549,0.619608,0.627451>,
  277. <0.498039,1.000000,0.000000>,
  278. <0.823529,0.411765,0.117647>,
  279. <1.000000,0.498039,0.313725>,
  280. <0.392157,0.584314,0.929412>,
  281. <1.000000,0.972549,0.862745>,
  282. <0.862745,0.078431,0.235294>,
  283. <0.000000,1.000000,1.000000>,
  284. <0.000000,0.000000,0.545098>,
  285. <0.000000,0.545098,0.545098>,
  286. <0.721569,0.525490,0.043137>,
  287. <0.662745,0.662745,0.662745>,
  288. <0.000000,0.392157,0.000000>,
  289. <0.741176,0.717647,0.419608>,
  290. <0.545098,0.000000,0.545098>,
  291. <0.333333,0.419608,0.184314>,
  292. <1.000000,0.549020,0.000000>,
  293. <0.600000,0.196078,0.800000>,
  294. <0.545098,0.000000,0.000000>,
  295. <0.913725,0.588235,0.478431>,
  296. <0.560784,0.737255,0.545098>,
  297. <0.282353,0.239216,0.545098>,
  298. <0.184314,0.309804,0.309804>,
  299. <0.000000,0.807843,0.819608>,
  300. <0.580392,0.000000,0.827451>,
  301. <1.000000,0.078431,0.576471>,
  302. <0.000000,0.749020,1.000000>,
  303. <0.411765,0.411765,0.411765>,
  304. <0.117647,0.564706,1.000000>,
  305. <0.698039,0.133333,0.133333>,
  306. <1.000000,0.980392,0.941176>,
  307. <0.133333,0.545098,0.133333>,
  308. <1.000000,0.000000,1.000000>,
  309. <0.862745,0.862745,0.862745>,
  310. <0.972549,0.972549,1.000000>,
  311. <1.000000,0.843137,0.000000>,
  312. <0.854902,0.647059,0.125490>,
  313. <0.501961,0.501961,0.501961>,
  314. <0.000000,0.501961,0.000000>,
  315. <0.678431,1.000000,0.184314>,
  316. <0.941176,1.000000,0.941176>,
  317. <1.000000,0.411765,0.705882>,
  318. <0.803922,0.360784,0.360784>,
  319. <0.294118,0.000000,0.509804>,
  320. <1.000000,1.000000,0.941176>,
  321. <0.941176,0.901961,0.549020>,
  322. <0.901961,0.901961,0.980392>,
  323. <1.000000,0.941176,0.960784>,
  324. <0.486275,0.988235,0.000000>,
  325. <1.000000,0.980392,0.803922>,
  326. <0.678431,0.847059,0.901961>,
  327. <0.941176,0.501961,0.501961>,
  328. <0.878431,1.000000,1.000000>,
  329. <0.980392,0.980392,0.823529>,
  330. <0.827451,0.827451,0.827451>,
  331. <0.564706,0.933333,0.564706>,
  332. <1.000000,0.713725,0.756863>,
  333. <1.000000,0.627451,0.478431>,
  334. <0.125490,0.698039,0.666667>,
  335. <0.529412,0.807843,0.980392>,
  336. <0.466667,0.533333,0.600000>,
  337. <0.690196,0.768627,0.870588>,
  338. <1.000000,1.000000,0.878431>,
  339. <0.000000,1.000000,0.000000>,
  340. <0.196078,0.803922,0.196078>,
  341. <0.980392,0.941176,0.901961>,
  342. <1.000000,0.000000,1.000000>,
  343. <0.501961,0.000000,0.000000>,
  344. <0.400000,0.803922,0.666667>,
  345. <0.000000,0.000000,0.803922>,
  346. <0.729412,0.333333,0.827451>,
  347. <0.576471,0.439216,0.858824>,
  348. <0.235294,0.701961,0.443137>,
  349. <0.482353,0.407843,0.933333>,
  350. <0.000000,0.980392,0.603922>,
  351. <0.282353,0.819608,0.800000>,
  352. <0.780392,0.082353,0.521569>,
  353. <0.098039,0.098039,0.439216>,
  354. <0.960784,1.000000,0.980392>,
  355. <1.000000,0.894118,0.882353>,
  356. <1.000000,0.894118,0.709804>,
  357. <1.000000,0.870588,0.678431>,
  358. <0.000000,0.000000,0.501961>,
  359. <0.992157,0.960784,0.901961>,
  360. <0.501961,0.501961,0.000000>,
  361. <0.419608,0.556863,0.137255>,
  362. <1.000000,0.647059,0.000000>,
  363. <1.000000,0.270588,0.000000>,
  364. <0.854902,0.439216,0.839216>,
  365. <0.933333,0.909804,0.666667>,
  366. <0.596078,0.984314,0.596078>,
  367. <0.686275,0.933333,0.933333>,
  368. <0.858824,0.439216,0.576471>,
  369. <1.000000,0.937255,0.835294>,
  370. <1.000000,0.854902,0.725490>,
  371. <0.803922,0.521569,0.247059>,
  372. <1.000000,0.752941,0.796078>,
  373. <0.866667,0.627451,0.866667>,
  374. <0.690196,0.878431,0.901961>,
  375. <0.501961,0.000000,0.501961>,
  376. <1.000000,0.000000,0.000000>,
  377. <0.737255,0.560784,0.560784>,
  378. <0.254902,0.411765,0.882353>,
  379. <0.545098,0.270588,0.074510>,
  380. <0.980392,0.501961,0.447059>,
  381. <0.956863,0.643137,0.376471>,
  382. <0.180392,0.545098,0.341176>,
  383. <1.000000,0.960784,0.933333>,
  384. <0.627451,0.321569,0.176471>,
  385. <0.752941,0.752941,0.752941>,
  386. <0.529412,0.807843,0.921569>,
  387. <0.415686,0.352941,0.803922>,
  388. <0.439216,0.501961,0.564706>,
  389. <1.000000,0.980392,0.980392>,
  390. <0.000000,1.000000,0.498039>,
  391. <0.274510,0.509804,0.705882>,
  392. <0.823529,0.705882,0.549020>,
  393. <0.000000,0.501961,0.501961>,
  394. <0.847059,0.749020,0.847059>,
  395. <1.000000,0.388235,0.278431>,
  396. <1.000000,1.000000,1.000000>,
  397. <0.250980,0.878431,0.815686>,
  398. <0.933333,0.509804,0.933333>,
  399. <0.960784,0.870588,0.701961>,
  400. <1.000000,1.000000,1.000000>,
  401. <0.960784,0.960784,0.960784>,
  402. <1.000000,1.000000,0.000000>,
  403. <0.603922,0.803922,0.196078>
  404. ];
  405. sysColorsName =
  406. [
  407. "AliceBlue",
  408. "AntiqueWhite",
  409. "Aqua",
  410. "Aquamarine",
  411. "Azure",
  412. "Beige",
  413. "Bisque",
  414. "Black",
  415. "BlanchedAlmond",
  416. "Blue",
  417. "BlueViolet",
  418. "Brown",
  419. "BurlyWood",
  420. "CadetBlue",
  421. "Chartreuse",
  422. "Chocolate",
  423. "Coral",
  424. "CornflowerBlue",
  425. "Cornsilk",
  426. "Crimson",
  427. "Cyan",
  428. "DarkBlue",
  429. "DarkCyan",
  430. "DarkGoldenrod",
  431. "DarkGray",
  432. "DarkGreen",
  433. "DarkKhaki",
  434. "DarkMagenta",
  435. "DarkOliveGreen",
  436. "DarkOrange",
  437. "DarkOrchid",
  438. "DarkRed",
  439. "DarkSalmon",
  440. "DarkSeaGreen",
  441. "DarkSlateBlue",
  442. "DarkSlateGray",
  443. "DarkTurquoise",
  444. "DarkViolet",
  445. "DeepPink",
  446. "DeepSkyBlue",
  447. "DimGray",
  448. "DodgerBlue",
  449. "Firebrick",
  450. "FloralWhite",
  451. "ForestGreen",
  452. "Fuchsia",
  453. "Gainsboro",
  454. "GhostWhite",
  455. "Gold",
  456. "Goldenrod",
  457. "Gray",
  458. "Green",
  459. "GreenYellow",
  460. "Honeydew",
  461. "HotPink",
  462. "IndianRed",
  463. "Indigo",
  464. "Ivory",
  465. "Khaki",
  466. "Lavender",
  467. "LavenderBlush",
  468. "LawnGreen",
  469. "LemonChiffon",
  470. "LightBlue",
  471. "LightCoral",
  472. "LightCyan",
  473. "LightGoldenrodYellow",
  474. "LightGray",
  475. "LightGreen",
  476. "LightPink",
  477. "LightSalmon",
  478. "LightSeaGreen",
  479. "LightSkyBlue",
  480. "LightSlateGray",
  481. "LightSteelBlue",
  482. "LightYellow",
  483. "Lime",
  484. "LimeGreen",
  485. "Linen",
  486. "Magenta",
  487. "Maroon",
  488. "MediumAquamarine",
  489. "MediumBlue",
  490. "MediumOrchid",
  491. "MediumPurple",
  492. "MediumSeaGreen",
  493. "MediumSlateBlue",
  494. "MediumSpringGreen",
  495. "MediumTurquoise",
  496. "MediumVioletRed",
  497. "MidnightBlue",
  498. "MintCream",
  499. "MistyRose",
  500. "Moccasin",
  501. "NavajoWhite",
  502. "Navy",
  503. "OldLace",
  504. "Olive",
  505. "OliveDrab",
  506. "Orange",
  507. "OrangeRed",
  508. "Orchid",
  509. "PaleGoldenrod",
  510. "PaleGreen",
  511. "PaleTurquoise",
  512. "PaleVioletRed",
  513. "PapayaWhip",
  514. "PeachPuff",
  515. "Peru",
  516. "Pink",
  517. "Plum",
  518. "PowderBlue",
  519. "Purple",
  520. "Red",
  521. "RosyBrown",
  522. "RoyalBlue",
  523. "SaddleBrown",
  524. "Salmon",
  525. "SandyBrown",
  526. "SeaGreen",
  527. "SeaShell",
  528. "Sienna",
  529. "Silver",
  530. "SkyBlue",
  531. "SlateBlue",
  532. "SlateGray",
  533. "Snow",
  534. "SpringGreen",
  535. "SteelBlue",
  536. "Tan",
  537. "Teal",
  538. "Thistle",
  539. "Tomato",
  540. "White",
  541. "Turquoise",
  542. "Violet",
  543. "Wheat",
  544. "White",
  545. "WhiteSmoke",
  546. "Yellow",
  547. "YellowGreen"
  548. ];
  549. if (debug)
  550. {
  551. float i;
  552. float j;
  553. float k;
  554. for (i = 0; i <= 1; i+= 0.5)
  555. {
  556. for (j = 0; j <= 1; j+= 0.5)
  557. {
  558. for (k = 0; k <= 1; k+= 0.5)
  559. {
  560. llWhisper(0, (string)<i,j,k> + ":" + HTML2SysColorBestMatch(<i,j,k>));
  561. }
  562. }
  563. }
  564. }
  565. }
  566. link_message(integer sender, integer num, string str, key id)
  567. {
  568. if (num == LINK_AGE_START) { // this starts the aging process
  569. state running;
  570. }
  571. }
  572. }
  573. state running
  574. {
  575. state_entry()
  576. {
  577. hunger_amount = 0;
  578. age = 0;
  579. pregnant = "";
  580. play_sounds = TRUE;
  581. llListen(API_CHANNEL, "", "", "");
  582. }
  583. touch_start(integer total_number)
  584. {
  585. string mysex;
  586. if (sex == 1) {
  587. mysex = "Male";
  588. } else
  589. if (sex == 2) {
  590. mysex = "Female";
  591. } else {
  592. mysex = "unknown - not configured correctly";
  593. }
  594. llSetText(llGetObjectName() + "\n" + mysex + " - Age: " + (string)age + " - Gen: " + (string)gen + "\n" + "Hunger: " + (string)hunger_amount + "/" + (string)MAXIMUM_HUNGER + "\n" + pregnant + sleep, <1,1,1>, 1.0);
  595. say_details();
  596. menu_expired = 0;
  597. if (llDetectedKey(0) == llGetOwner()) {
  598. integer menu_chan = (integer)llFrand(10000.0) + 100;
  599. llListenRemove(menu_listener);
  600. menu_listener = llListen(menu_chan, "", llGetOwner(), "");
  601. llDialog(llGetOwner(), "What would you like to do?\n\n - Name: Name your pet "
  602. + "\n - Package: Place your pet"
  603. + "into a nearby " + Crate
  604. + "\n - Sound: Toggle Sound On/Off\n"
  605. + "- Home Object: Get a new home object\n"
  606. + "- Sleep: Toggle Sleep On/Off", ["Nothing", "Name", "Package", "Sound", "Home Object", "Sleep"], menu_chan);
  607. menu_expired = 1;
  608. }
  609. llSetTimerEvent(30.0);
  610. }
  611. timer()
  612. {
  613. llListenRemove(menu_listener);
  614. llListenRemove(name_listener);
  615. llSetTimerEvent(0.0);
  616. llSetText("", <1,1,1>, 1.0);
  617. if (menu_expired) {
  618. llWhisper(0, "Menu Expired");
  619. menu_expired = 0;
  620. }
  621. }
  622. link_message(integer sender, integer num, string str, key id)
  623. {
  624. if (num == LINK_BREEDNAME) {
  625. sBreedName = str;
  626. } else
  627. if (num == LINK_HUNGRY || num == LINK_HAMOUNT) {
  628. hunger_amount = (integer)str;
  629. } else
  630. if (num == LINK_FOODMINUS) {
  631. hunger_amount --;
  632. //eaten ++;
  633. } else
  634. if (num == LINK_COLOR1) {
  635. colour1 = (vector)str;
  636. } else
  637. if (num == LINK_COLOR2) {
  638. colour2 = (vector)str;
  639. } else
  640. if (num == LINK_SEX) {
  641. sex = (integer)str;
  642. } else
  643. if (num == LINK_SHINE) {
  644. shine = (integer)str;
  645. } else
  646. if (num == LINK_GLOW) {
  647. glow = (float)str;
  648. } else
  649. if (num == LINK_GEN) {
  650. gen = (integer)str;
  651. } else
  652. if (num == LINK_MAGE) {
  653. age += (integer)str;
  654. } else
  655. if (num == LINK_PREGNANT) {
  656. pregnant = "Pregnant";
  657. llSay(API_CHANNEL, "I'm Pregnant!");
  658. } else
  659. if (num == LINK_PREGNANCY_TIME) {
  660. sex = 2;
  661. if ((integer)str != 0) {
  662. pregnant = "Pregnant";
  663. }
  664. } else
  665. if (num == LINK_LAY_EGG) {
  666. pregnant = "";
  667. } else
  668. if (num == LINK_SLEEPING) {
  669. sleep = "\nSleeping";
  670. } else
  671. if (num == LINK_UNSLEEPING) {
  672. sleep = "";
  673. } else
  674. if (num == LINK_SPECIAL) {
  675. special = str;
  676. } else
  677. if (num == LINK_SET_HOME) {
  678. list data = llParseString2List(str, ["^"], []);
  679. llSetText("Home Set: " + llList2String(data, 0) + " " + llList2String(data, 1) + "m", <1,1,1>, 1.0);
  680. llSetTimerEvent(15.0);
  681. }
  682. }
  683. listen(integer channel, string name, key id, string msg)
  684. {
  685. if (channel == 0 && id == llGetOwner()) {
  686. list name_parts = llParseString2List(msg, [","], []);
  687. if (llToLower(llList2String(name_parts, 0)) == "name") {
  688. string myname = llStringTrim(llList2String(name_parts, 1), STRING_TRIM);
  689. integer i;
  690. for (i=0;i<llStringLength(myname);i++) {
  691. if (llGetSubString(myname, i, i) == "^") {
  692. llWhisper(0, "Sorry, cannot have a \"^\" in the name.");
  693. llListenRemove(name_listener);
  694. return;
  695. }
  696. }
  697. llWhisper(0, "My new name is " + myname);
  698. llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
  699. llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_WAVE, "");
  700. llMessageLinked(LINK_SET, LINK_ANIMATE, ANI_STAND, "");
  701. llSetObjectName(myname);
  702. llListenRemove(name_listener);
  703. }
  704. } else if (channel == API_CHANNEL) {
  705. list data = llParseString2List(msg, ["^"], []);
  706. if (llList2String(data, 0) == "XSPet" && (key) llList2String(data, 1) == llGetKey()) {
  707. llSay(API_CHANNEL, "XSPet^" + (string)llGetKey() + "^" + (string)colour1 + "^" + (string)colour2 + "^" + (string)shine + "^" + (string)glow + "^" + special + "^" + (string)gen + "^" + (string)sex + "^" + (string)age + "^XSPetEnd");
  708. }
  709. } else if (channel != ANIMAL_CHANNEL) {
  710. llListenRemove(menu_listener);
  711. menu_expired = 0;
  712. if (msg == "Name") {
  713. llOwnerSay("You have 30 seconds to type a new name: (Format \"name, Charlie\")");
  714. name_listener = llListen(0, "", llGetOwner(), "");
  715. llSetTimerEvent(30.0);
  716. } else
  717. if (msg == "Package") {
  718. llMessageLinked(LINK_SET, LINK_PACKAGE, "", "");
  719. } else
  720. if (msg == "Sound") {
  721. if (play_sounds) {
  722. llMessageLinked(LINK_SET, LINK_SOUND_OFF, "", "");
  723. llWhisper(0, "Turning sound off.");
  724. } else {
  725. llMessageLinked(LINK_SET, LINK_SOUND_ON, "", "");
  726. llWhisper(0, "Turning sound on.");
  727. }
  728. play_sounds = !play_sounds;
  729. } else
  730. if (msg == "Home Object") {
  731. llGiveInventory(llGetOwner(), HomeObject);
  732. } else
  733. if (msg == "Sleep") {
  734. if (sleep_disabled) {
  735. llWhisper(0, "Enabling Sleeping.");
  736. } else {
  737. llWhisper(0, "Disabling Sleeping.");
  738. }
  739. sleep_disabled = !sleep_disabled;
  740. llMessageLinked(LINK_SET, LINK_SLEEP, (string)sleep_disabled, "");
  741. }
  742. }
  743. }
  744. }