User Tools

Site Tools


scriptlib:minerminig

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
scriptlib:minerminig [2015/05/09 20:13]
emerald
scriptlib:minerminig [2015/05/16 15:52] (current)
emerald
Line 43: Line 43:
  */  */
 phrases <- [ phrases <- [
- "I just know it's buried here somewhere ..", +    ​"I just know it's buried here somewhere ..", 
- "One day I'll be able to pay others to do this for me", +    "One day I'll be able to pay others to do this for me", 
- "I really dig ... digging",​ +    "I really dig ... digging",​ 
- "Rock .. that's all I seem to find these days",​ +    "Rock .. that's all I seem to find these days",​ 
- "I mine the mine, and what's mine is mine",​ +    "I mine the mine, and what's mine is mine",​ 
- "​I'​m really digging a hole for myself here"+    "​I'​m really digging a hole for myself here"
 ]; ];
  
Line 56: Line 56:
  */  */
 walk_locations <- [ walk_locations <- [
- Point(3028, 4110), +    ​Point(3028, 4110), 
- Point(3139,​ 4048), +    Point(3139, 4048), 
- Point(3026,​ 4006)+    Point(3026, 4006)
 ]; ];
  
Line 65: Line 65:
  */  */
 function moveSomewhere() { function moveSomewhere() {
- /* +    ​/* 
-  * Pick a random location from the list. '​randmodrnd'​ is used as it +     ​* Pick a random location from the list. '​randmodrnd'​ is used as it 
-  * returns a number between 0 (inclusive) and 1 less than the number of possible +     ​* returns a number between 0 (inclusive) and 1 less than the number of possible 
-  * locations +     ​* locations 
-  */ +     ​*/ 
- local location = walk_locations[randmodrng(0,​ walk_locations.len())];​+    local location = walk_locations[randmodrng(0,​ walk_locations.len())];​
  
- // As with most things, we need the CID of the creature to act on +    ​// As with most things, we need the CID of the creature to act on 
- local ​cid = inst.cids(ACTOR_CDEFID)[0];+    local cids = inst.cids(ACTOR_CDEFID)
 +    if(cids.len() == 0) { 
 +        // Just in case they haven'​t spawned (yet), we don't an error 
 +        inst.queue(moveSomewhere,​ 5000); 
 +        return; 
 +    }
  
- /* Instruct the  actor to walk to the chosen location. The +    ​/* Instruct the  actor to walk to the chosen location. The 
-  * last argument to '​orderWalk'​ is the function to call when +     ​* last argument to '​orderWalk'​ is the function to call when 
-  * the actor arrives +     ​* the actor arrives 
-  */ +     ​*/ 
- inst.walkThen(cid, location, speed, 0, arrived);+    inst.walkThen(cids[0], location, speed, 0, arrived);
 } }
  
Line 87: Line 92:
 function arrived() { function arrived() {
  
- local cid = inst.cids(ACTOR_CDEFID)[0];​+    ​local cid = inst.cids(ACTOR_CDEFID)[0];​
  
- /* Determine if we want the actor to speak at all */+    ​/* Determine if we want the actor to speak at all */
  
- if(randmodrng(0,​ 100) <= SPEAK_CHANCE) { +    ​if(randmodrng(0,​ 100) <= SPEAK_CHANCE) { 
- /* +        /* 
-  * Pick a random phrase to '​say'​. As with the location, randmodrng is used. We also +         ​* Pick a random phrase to '​say'​. As with the location, randmodrng is used. We also 
-  * delay the speech by a second +         ​* delay the speech by a second 
-  */ +         ​*/ 
- core.queue(function() { +        inst.queue(function() { 
- inst.creatureChat(cid,​ "​s/",​ phrases[randmodrng(0,​ phrases.len())]);​ +            inst.creatureChat(cid,​ "​s/",​ phrases[randmodrng(0,​ phrases.len())]);​ 
- }, 1000); +        }, 1000); 
- }+    }
  
- /* Make the character perform an emote. We will perform the emote 4 times, once +    ​/* Make the character perform an emote. We will perform the emote 4 times, once 
-  * every 2000ms (2 seconds). +     ​* every 2000ms (2 seconds). 
-  */ +     ​*/ 
-  + 
- inst.emote(cid,​ ANIMATION);​ +    inst.emote(cid,​ ANIMATION);​ 
- core.queue(function() { inst.emote(cid,​ ANIMATION); }, 2000); +    inst.queue(function() { inst.emote(cid,​ ANIMATION); }, 2000); 
- core.queue(function() { inst.emote(cid,​ ANIMATION); }, 4000); +    inst.queue(function() { inst.emote(cid,​ ANIMATION); }, 4000); 
- core.queue(function() { inst.emote(cid,​ ANIMATION); }, 6000); +    inst.queue(function() { inst.emote(cid,​ ANIMATION); }, 6000); 
- core.queue(function() { inst.emote(cid,​ ANIMATION); }, 8000); +    inst.queue(function() { inst.emote(cid,​ ANIMATION); }, 8000); 
-   + 
- /* +    /* 
-  * At 10 seconds, we move the actor on +     ​* At 10 seconds, we move the actor on 
-  */ +     ​*/ 
- core.queue(moveSomewhere,​ 10000);+    inst.queue(moveSomewhere,​ 10000);
 } }
  
-core.queue(moveSomewhere,​ 1000);+inst.queue(moveSomewhere,​ 1000);
  
 </​code>​ </​code>​
scriptlib/minerminig.1431198799.txt.gz · Last modified: 2015/05/09 20:13 by emerald