Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-21-2012, 09:14 PM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Quote:
Originally Posted by ffcmike View Post
The placed NPC would be a separate object to the original weapon script, so the this. variable would not transfer between them. It should use 'if(created){}' as the condition, and then probably use 'destroy;' rather than 'hide;'.

Also I know this is old gscript but I believe you still need to use '==' rather than a single '='. A single '=' is for assigning values, whereas a double '==' is for comparing different values. In modern gscript using just one would result in the condition being determined as true, even if the 2 compared values were different.
But I am assigning values, it is so that when I use the weapon, it can place the bomb first, then when you use the weapon again, it blows it up, and I can't do "if(created)" because I need it to blow up when I want it to, not on it's own.
Reply With Quote
  #2  
Old 06-21-2012, 09:25 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by E_Man View Post
But I am assigning values, it is so that when I use the weapon, it can place the bomb first, then when you use the weapon again, it blows it up
Your assigning of variables is correct, it is the comparing of variables within the if conditions which is incorrect, using an assignment causes the if conditions to always be true.

It should be for example:

PHP Code:
if(playertouchsme){
  if(
this.value == 2){
    
this.value 3;
  }

Doing something like:

PHP Code:
if(this.value 2){
  
//stuff

is essentially the same as:

PHP Code:
if(true){
 
//stuff

It's probably worth mentioning that the opposite can also be applied for doing 'not equal to', for example:

PHP Code:
if(playertouchsme){
  if(
this.value != 2){
    
this.value 2;
  }

Quote:
Originally Posted by E_Man View Post
and I can't do "if(created)" because I need it to blow up when I want it to, not on it's own.
In that case, you should write and read the 'bomb' variable without using 'this.', so it is a global flag, rather than one tied to the weapon.
Reply With Quote
  #3  
Old 06-21-2012, 09:38 PM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Quote:
Originally Posted by ffcmike View Post
Your assigning of variables is correct, it is the comparing of variables within the if conditions which is incorrect, using an assignment causes the if conditions to always be true.

It should be for example:

PHP Code:
if(playertouchsme){
  if(
this.value == 2){
    
this.value 3;
  }

Doing something like:

PHP Code:
if(this.value 2){
  
//stuff

is essentially the same as:

PHP Code:
if(true){
 
//stuff

It's probably worth mentioning that the opposite can also be applied for doing 'not equal to', for example:

PHP Code:
if(playertouchsme){
  if(
this.value != 2){
    
this.value 2;
  }



In that case, you should write and read the 'bomb' variable without using 'this.', so it is a global flag, rather than one tied to the weapon.
I don't get why I need to compare variables, also would client.variable work for global flags? Though it probably is the comparing variables because I can place the bomb but it blows up on it's own.
Reply With Quote
  #4  
Old 06-21-2012, 09:50 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by E_Man View Post
I don't get why I need to compare variables,
When I say comparing variables, this also counts for checking to see if one variable is equal to a numerical value.

Quote:
Originally Posted by E_Man View Post
also would client.variable work for global flags?
It would work yes, but this is a functionality designed to save variables permanently for online usage, which doesn't apply here.

It should be fine to do:

PHP Code:
//Weapon
bomb 1;

//NPC
if(bomb == 1){


Reply With Quote
  #5  
Old 06-21-2012, 10:01 PM
E_Man E_Man is offline
E-Man
E_Man's Avatar
Join Date: Jun 2012
Posts: 81
E_Man will become famous soon enough
Quote:
Originally Posted by ffcmike View Post
When I say comparing variables, this also counts for checking to see if one variable is equal to a numerical value.



It would work yes, but this is a functionality designed to save variables permanently for online usage, which doesn't apply here.

It should be fine to do:

PHP Code:
//Weapon
bomb 1;

//NPC
if(bomb == 1){


I tried that and it still blows up on it's own and the image does not change back, here is the script, I also can send the images if you need to test it.

Weapon:
PHP Code:
// NPC made by E-Man
if (created) {
  
client.bomb=0;
  
client.explosion=0;
  
setimg remotebomb1.png;
}
if (
playertouchsme) {
  
toweapons Remote Bomb;
  
hide;
}
if (
weaponfired && client.bomb==&& playerdir0) {
  
putnpc remotebomb1.png,remotebomb.txt,playerx+0.5,playery-1;
  
client.bomb=1;
}
if (
weaponfired && client.bomb==&& playerdir1) {
  
putnpc remotebomb1.png,remotebomb.txt,playerx-1.5,playery+1;
  
client.bomb=1;
}
if (
weaponfired && client.bomb==&& playerdir2)  {
  
putnpc remotebomb1.png,remotebomb.txt,playerx+0.5,playery+2.5;
  
client.bomb=1;
}

if (
weaponfired && client.bomb==&& playerdir3) {
  
putnpc remotebomb1.png,remotebomb.txt,playerx+2.5,playery+1;
  
client.bomb=1;
}
if (
weaponfired && client.bomb==1) {
  
setani shoot,remote.png;
   
setimg remotebomb1.png;
 
client.explosion=1;
    }
if (
client.bomb==1) {
  
setimg remoteimage.png;

remotebomb.txt
PHP Code:
if (created) {
setimg remotebomb1.png;
}
if (
client.explosion==1) {
canbecarried;
setimg remotebomb2.png;
sleep 0.5;
putexplosion 2,x,y;
client.explosion=0;
destroy;

__________________
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 04:20 AM.


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