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 03-08-2007, 05:50 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
SImple Problem

Hey its me again, Try my hand on scripting Im getting the basics down but for some reason I am having trouble with this simple flag. Here is the first script:

PHP Code:
showcharacter;
  
setcharprop #3,head0.png;
  
setcharprop #C0,orange;
  
setcharprop #C1,white;
  
setcharprop #C2,blue;
  
setcharprop #C3,red;
  
setcharprop #C4,black;
  
setcharprop #2,shield1.gif;
  
shieldpower 1;
  
dir 2;
}
if (
playertouchsme) {move 26.5,-4,10,0;


freezeplayer 10;

sleep 10;

save[1]=true;

Then I have a door script:

PHP Code:
if (save[1]=true) {hide;} 
For some reason the door will not disapear though. Please help

Last edited by MrAnonymous_P2P; 03-08-2007 at 05:51 AM.. Reason: Forgot Problem
Reply With Quote
  #2  
Old 03-08-2007, 05:52 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
God it hurts me just to look at GS1 now that I've been working with GS2 for so long



Are both parts in the same script? If not I don't think it would work because the flag would only be setting for that one script, and thus the other wouldn't be able to read it.
Reply With Quote
  #3  
Old 03-08-2007, 05:55 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Don't really understand what you're trying to do... Could you explain it? I guess it has something to do with the save[x]'s... but I don't understand what.
From reading a little. I guess you have an NPC that will walk to a door and open it?

If that's the case, use triggeractions, not save[x]'s.
PHP Code:
if (created) {
  
showcharacter;
  
setcharprop #3,head0.png;
  
setcharprop #C0,orange;
  
setcharprop #C1,white;
  
setcharprop #C2,blue;
  
setcharprop #C3,red;
  
setcharprop #C4,black;
  
setcharprop #2,shield1.gif;
  
shieldpower 1;
  
dir 2;
}
if (
playertouchsme) {
  
move 26.5,-4,10,0;
  
freezeplayer 10;
  
sleep 10;
  
triggeraction x+1,y,opendoor,;

PHP Code:
if (actionopendoorhide
Though I don't remember if triggeractions work from one non-weapon NPC to another...
Reply With Quote
  #4  
Old 03-08-2007, 06:00 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by DustyPorViva View Post
Though I don't remember if triggeractions work from one non-weapon NPC to another...
It's triggering the map. Why wouldn't it work?
Reply With Quote
  #5  
Old 03-08-2007, 06:05 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Still doesnt work. Remember Im a noob at scripting you might have to explain some things XD
Reply With Quote
  #6  
Old 03-08-2007, 06:19 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Twinny View Post
It's triggering the map. Why wouldn't it work?
Dunno, if I remember correctly, I had problems triggering from a non-weapon NPC to another NPC. I think it was having a block trigger a switch it was pushed over. Could never get it to work.
Reply With Quote
  #7  
Old 03-08-2007, 09:11 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
I answered this in your other thread... re-read?

http://forums.graal2001.com/forums/s...09#post1285014
Reply With Quote
  #8  
Old 03-08-2007, 03:35 PM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Im a noob at scripting I have no idea what all those commands mean. Please explain.(I dont know what to change to make it work or anything )
Reply With Quote
  #9  
Old 03-08-2007, 04:31 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
PHP Code:
TRIGGERACTION npcxnpcyfoundPOSITION,; 
Change this to something like this.
PHP Code:
triggeraction 3030foundPOSITION,; 
Obviously, edit the position (30, 30) to where the door is. [The x/y position of the door]
Then, inside the door add the other script. You'll see how it works.
Reply With Quote
  #10  
Old 03-08-2007, 07:18 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by MrAnonymous_P2P View Post
Hey its me again, Try my hand on scripting Im getting the basics down but for some reason I am having trouble with this simple flag. Here is the first script:

PHP Code:
showcharacter;
  
setcharprop #3,head0.png;
  
setcharprop #C0,orange;
  
setcharprop #C1,white;
  
setcharprop #C2,blue;
  
setcharprop #C3,red;
  
setcharprop #C4,black;
  
setcharprop #2,shield1.gif;
  
shieldpower 1;
  
dir 2;
}
if (
playertouchsme) {move 26.5,-4,10,0;


freezeplayer 10;

sleep 10;

save[1]=true;

Then I have a door script:

PHP Code:
if (save[1]=true) {hide;} 
For some reason the door will not disapear though. Please help
PHP Code:
if (save[1]=true) {hide;} 
should be
PHP Code:
if (save[1]==true) {hide;} 
you used the wrong operator.
this method should work fine after that.

I can't believe all these FOOLS posting pointed you torwards triggeraction and completely overlooked that
jk ILU guys
__________________
Reply With Quote
  #11  
Old 03-08-2007, 07:28 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by Kristi View Post
PHP Code:
if (save[1]=true) {hide;} 
should be
PHP Code:
if (save[1]==true) {hide;} 
you used the wrong operator.
this method should work fine after that.

I can't believe all these FOOLS posting pointed you torwards triggeraction and completely overlooked that
jk ILU guys
I think you're mistaken
Reply With Quote
  #12  
Old 03-08-2007, 07:33 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Chandler View Post
I think you're mistaken
as long as if(save[1]==true) is in a timeout it will be reconized

Alternately the door could be scripted in gs2!
PHP Code:
//#CLIENTSIDE

function onCreated() {
  
door942 this;
}

public function 
hideme() {
  
hide();

then from whatever script you want you can use
PHP Code:
function onPlayerTouchsMe() {
move(26.5,-4,10,0); 


freezeplayer(10); 

sleep(10); 

door942.hideme(); 

__________________
Reply With Quote
  #13  
Old 03-08-2007, 07:37 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Chandler View Post
In a timeout!
Wouldn't you rather call something than check something every ## seconds?
READ THE EDIT

Besides, for all intensive purposes, he asked why his script did not work, not how to do it a better way.
__________________
Reply With Quote
  #14  
Old 03-08-2007, 09:07 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
== is not required.
= works just fine.
__________________
Do it with a DON!
Reply With Quote
  #15  
Old 03-08-2007, 09:12 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by zokemon View Post
== is not required.
= works just fine.
== is required.

= may have worked in GS1, but it acts a lot differently (as it should) in GS2.

For example:
PHP Code:
if (this.foo == 1
This checks if this.foo equals 1

PHP Code:
if (this.bar 1
This assigns the value '1' to this.bar and returns the value of this.bar after the assignment.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.

Last edited by napo_p2p; 03-08-2007 at 10:36 PM..
Reply With Quote
  #16  
Old 03-08-2007, 10:38 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
If the two scripts are in seperate NPCs, you just can't check save[0] from the other npc with save[0]==1. save[0] is local to the NPC, so you'd either have to get the NPC index for npcs[x].save[0]==1 or triggeraction the other NPC...
Now... if they're in the same NPC than triggeraction would be a silly solution.

Anyways, I see in his first post he corrected and captioned the second NPC is a door. In that case save[0]==1 will not work since save[x]'s are a local variable. Triggeraction is the right solution for NPC's interacting.
Reply With Quote
  #17  
Old 03-08-2007, 10:41 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by DustyPorViva View Post
Anyways, I see in his first post he corrected and captioned the second NPC is a door. In that case save[0]==1 will not work since save[x]'s are a local variable. Triggeraction is the right solution for NPC's interacting.
You can access the save[n] of another NPC, just like you can access any of its other variables. Joshie's solution shows how this can be done.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #18  
Old 03-08-2007, 10:52 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
True, true... in GS2. But he posted a GS1 script and I responded with a GS1 solution. In GS1, triggeraction is the most sensible solution.
Reply With Quote
  #19  
Old 03-08-2007, 11:21 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by zokemon View Post
== is not required.
= works just fine.
Thats really bad advice and a horrible habit to get into because it wont work as expected in any other language.

The question has been answered id like to hear from him again to see if he managed to fix it with the advice he was given.
__________________
Reply With Quote
  #20  
Old 03-09-2007, 12:58 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Ok so first off thanks for all the help I did manage to solve it a different way.

I simply made the moving character drop the image of a stair case.(So it made it look like in magically appeared. The staircase had its own script with a drawunderplayer function and the player can now advance to the next level.

I couldn't quite figure out the trigger action function because I don't see how you use x,y coordinates to make an npc dissapear Perhaps I'm doing something wrong. If someone could please correct what I have done wrong it would be a great learning experience for me
Attached Files
File Type: nw new889.nw (10.0 KB, 109 views)
Reply With Quote
  #21  
Old 03-09-2007, 04:24 AM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by DustyPorViva View Post
True, true... in GS2. But he posted a GS1 script and I responded with a GS1 solution. In GS1, triggeraction is the most sensible solution.
no, in gs1, saying save[0] = 1 will treat save as a global clientside array, all npcs clientside will be able to access save. if you said this.save, then it would be local, however, in gs1 clientside you cant have this.arrays, (last time i checked)

since this. was not use, the save[] array is accessable by all npcs on the clientside. Stop saying I am wrong when I am right please ^_^
__________________
Reply With Quote
  #22  
Old 03-09-2007, 07:16 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by MrAnonymous_P2P View Post
I couldn't quite figure out the trigger action function because I don't see how you use x,y coordinates to make an npc dissapear Perhaps I'm doing something wrong. If someone could please correct what I have done wrong it would be a great learning experience for me
The NPCs you have on the level work fine using the triggeraction you have. After correcting the right npc (which didnt have a triggeraction) the door dissapeared after moving both of them.

Maybe you were just getting impaitent but you had to wait 10 seconds (sleep 10 before the triggeraction would happen.
__________________
Reply With Quote
  #23  
Old 03-09-2007, 09:01 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by zokemon View Post
== is not required.
= works just fine.
If you only check for single things, yes. If you want to do something like:

PHP Code:
if (this.blah == || this.blöh 2
You will need ==. A single = wont work here.
Reply With Quote
  #24  
Old 03-09-2007, 09:09 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Crow View Post
If you only check for single things, yes.
No matter what, do not use = for comparing things...
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #25  
Old 03-20-2007, 04:25 AM
MrAnonymous_P2P MrAnonymous_P2P is offline
Retired Oldbie
MrAnonymous_P2P's Avatar
Join Date: Oct 2006
Location: Cambodia
Posts: 722
MrAnonymous_P2P is an unknown quantity at this point
Does triggeraction work in gs2? Its not working for me in this script

PHP Code:
function OnCreated() {

TRIGGERACTION (26.5,-4,hide,1);


Reply With Quote
  #26  
Old 03-20-2007, 04:31 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by MrAnonymous_P2P View Post
Does triggeraction work in gs2? Its not working for me in this script

PHP Code:
function OnCreated() {

TRIGGERACTION (26.5,-4,hide,1);


Your styling is horrible.. also, hide is text thus it should be wrapped in quotes. Right now its set to 0 since it thinks its a variable named "hide".

And hide == 0

PHP Code:
function onCreated() triggerAction(26.5, -4"hide"1); 
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #27  
Old 03-20-2007, 06:37 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by MrAnonymous_P2P View Post
Does triggeraction work in gs2? Its not working for me in this script

PHP Code:
function OnCreated() {

TRIGGERACTION (26.5,-4,hide,1);


As Ziro said, always place words in a string unless it's relating to an object. For instance, triggeraction(mousex, mousey, "fruit", "apples");

compared to
triggeraction(mousex, mousey, "owies", player.account, player.level.name);
Reply With Quote
  #28  
Old 03-20-2007, 02:13 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by MrAnonymous_P2P View Post
PHP Code:
if (save[1]=true) {hide;} 
wouldnt it be

PHP Code:
if (save[1]) {hide;} 
Since the if operations checks for true and false or

PHP Code:
if (save[1]==true) {hide;} 
since "=" is assign" and "==" is equals.
__________________
Deep into the Darkness peering...
Reply With Quote
  #29  
Old 03-20-2007, 02:43 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Angel_Light View Post
since "=" is assign" and "==" is equals.
Technically both will work but Kristi and Novo will hunt you with Tomahawks if you test with =.

[Edit]: haha i frigged this one up

Last edited by Twinny; 03-20-2007 at 03:37 PM..
Reply With Quote
  #30  
Old 03-20-2007, 03:42 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by napo_p2p View Post
No matter what, do not use = for comparing things...
I dont do that, I just wanted to say that it works for single checks.
Reply With Quote
  #31  
Old 03-20-2007, 10:33 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by Twinny View Post
[Edit]: haha i frigged this one up
wth?
__________________
Deep into the Darkness peering...
Reply With Quote
  #32  
Old 03-20-2007, 11:13 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Angel_Light View Post
wth?
I messed up what I said so i changed it. You may have noticed Skyld's deleted post underneath with "Corrected".
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 10:04 PM.


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