Thread: Script: Mining
View Single Post
  #1  
Old 08-21-2006, 10:51 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Script: Mining

Here is a mining system, also posted in the interest of education. Since I will probably never use these scripts, it makes sense to post them for other people!

There are two parts to the mining system; you will need to add the mining class (which is the script for the rocks), and you will also require the axe.

If you put the mining class in a class called "mining", then use the following to make a rock in a level:
PHP Code:
this.join("mining"); 
The axe is simple enough. Just add the weapon, add in your own animation into setani() and play.

You'll need to edit the mining class though; first, you'll need to put the appropriate images in the right place so the rock looks like it's being mined. Secondly, you'll have to insert your own item adding routine, so that you can actually add the item to the player. The method was different on Rudora, so it's no good putting that in there.

It's a fairly old script and could probably do with some work, especially if you want it to be more complex. Enjoy.

Axe weapon:
PHP Code:
//#CLIENTSIDE

function onWeaponFired()
{
  
setani("ani""params");
  
  
freezeplayer(1);
  
sleep(0.5);
  
  
ar = {player.+ (vecx(player.dir) * 2) + 1.1,
        
player.+ (vecy(player.dir) * 2) + 1.1};
  
  
showimg(2001"@Courier New@b@+"ar[0], ar[1]);

  
triggeraction(ar[0], ar[1], "axe"10);
  
hitobjects(1ar[0], ar[1]);
  
  
putleaps(2this.wx 0.5this.wy 0.5);
  
  
sleep(0.5);
  
  
setani("idle""");
  
hideimg(2001);

Mining class:
PHP Code:
function onCreated()
{
  
this.show();
  
  
this.offset 0

  
this.owner "none";
  
  
// Define possible types
  
this.types = {"bronze""silver""gold""crystal""metal"};
  
this.idtype int(random(0this.types.size()));
  
this.rtype this.types[this.idtype];
  
  
// set your default rock image here
 
  
this.setshape(13232);
  
  
this.chat "(Owner: " this.owner ")";
}

function 
onActionaxe()
{
  if (
this.owner == "none")
  {
    
this.owner player.account;
  }
    else
  if (
this.owner == player.account)
  {
    
setTimer(15);
  }
  
  
this.chat "(Owner: " this.owner ")";
  
  
this.progress += params[0];
  
  if (
this.progress 199)
  {
    
player.chat "You got a " this.rtype " rock!";
    
    
// Add your item to the player here
    
    
this.progress 0;
    
    
hide();
    
sleep(15); // <- how long to vanish for
    
onCreated();
  }
    else
  if (
this.progress 160)
  {
    
// set first progress rock image
  
}
    else
  if (
this.progress 120)
  {
    
// set second progress rock image
  
}
    else
  if (
this.progress 80)
  {
    
// set third progress rock image
  
}
    else
  if (
this.progress 40)
  {
    
// set fourth progress rock image
  
}
    else
  if (
this.progress 0)
  {
    
// set last progress rock image
  
}
}
  
function 
onTimeout()
{
  
this.owner "none";
  
this.chat "(Owner: " this.owner ")";

Reply With Quote