Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-06-2011, 03:20 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
New problem, move() only works first time then stops.. any particular reason behind this?

PHP Code:
function onMouseDown() {
  
this.nx x;
  
this.ny y;
  for ( 
i=0i<3i++ ) {
    
this.angle random(this.angle-0.522,this.angle+0.522); // angle
    
this.distance random(2,5); // distance
    
this.nx2 this.nx sin(this.angle) * this.distance;
    
this.ny2 this.ny cos(this.angle) * this.distance;
    
move(xyx+5y+5);
    
DrawLine(2000+ithis.nxthis.nythis.nx2this.ny2);
    
this.nx += sin(this.angle) * this.distance;
    
this.ny += cos(this.angle) * this.distance;
  }

Reply With Quote
  #2  
Old 01-06-2011, 03:22 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by scriptless View Post
New problem, move() only works first time then stops.. any particular reason behind this?

PHP Code:
function onMouseDown() {
  
this.nx x;
  
this.ny y;
  for ( 
i=0i<3i++ ) {
    
this.angle random(this.angle-0.522,this.angle+0.522); // angle
    
this.distance random(2,5); // distance
    
this.nx2 this.nx sin(this.angle) * this.distance;
    
this.ny2 this.ny cos(this.angle) * this.distance;
    
move(xyx+5y+5);
    
DrawLine(2000+ithis.nxthis.nythis.nx2this.ny2);
    
this.nx += sin(this.angle) * this.distance;
    
this.ny += cos(this.angle) * this.distance;
  }

You can't stack moves on top of eachother like that. Use the option that gives an event when finished (8? check scripthelp) and in the onMovementFinished (if I recall correctly) event call move again.
__________________
Reply With Quote
  #3  
Old 01-06-2011, 03:24 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
so something like

PHP Code:
function newmove() {
  if ( 
this.moved == false move(..);
  
this.moved true;
}

function 
onMovementFinished() {
  
this.moved false;
  
newmove();

is what your saying?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.