View Single Post
  #1  
Old 09-24-2011, 05:52 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Changing text in timeout.

I am working on a staff boots script for Lexia, and I don't want it to be just an old boring staff boots script, so I have added a little display to tell you your speed and to also show a little staff boots image too. Here is what the display says.
NPC Code:
Speed: 1

It is reading the speed. However, when I press the = key (increase speed), it doesn't recognise that the speed has changed at all and still shows 1;
Here is the code.
PHP Code:
//#CLIENTSIDE
function onKeyPressed(code, Key) {
  if (
Key == "z") {
    
setTimer(0.05);
    if (
this.mode == 0) {
      
this.mode = 1;
      
player.chat = "On";
      
this.speed = 1;
    } else {
      
this.mode = 0;
      
player.chat = "Off";
    }
  }
  if (
Key == "=") {
    
this.speed = this.speed + 1;
  }
}

function 
onTimeout() {
  if (
this.mode == 1) {
    
showingimage();
    for (
temp.key = 0; key < 4; key++) {
      if (
keydown(key)) {
        
player.x += (vecx(key) * this.speed);
        
player.y += (vecy(key) * this.speed);
      }
    }
  }
  if (
this.mode == 0) {
    
hidingimage();
  }
  
setTimer(0.05);
}

function 
ShowingImage() {
  
with(findimg(200)) {
    
image = "wboots.png";
    
layer = 4;
    
x = screenwidth / 2 - 675;
    
y = screenheight - 610;
  }
  
with(findimg(201)) {
    
text = "Speed: " @ this.speed;
    
x = screenwidth / 2 - 638;
    
y = screenheight - 601;
    
zoom = 0.7;
    
layer = 4;
  }
}

function 
HidingImage() {
  
hideimg(200);
  
hideimg(201);
} 
The code isn't finished yet, as you can see there is no way to decrease speed and the display is still very simple. The display is attached below.
Attached Images
 
__________________
Reply With Quote