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 09-03-2011, 09:01 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Train Script Problem

Basically im making a train that moves on tracks by its self, but iv ran into a problem.
the tracks are npcs that set images to whatever track piece it is.
is there any way to check if a npc is touching a certain npc and set its this.mode = whatever depending on whats in the npc its touching?
thanks in advanced.
im sure theres a way to do it
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 09-03-2011, 09:15 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
You can find all the NPCs at one point by doing something like

PHP Code:
for (temp.npc findAreaNPCs(xy0.10.1)) {
  echo(
"joined classes: " temp.npc.joinedclasses);

Then just figure out which NPC you're looking for based on the joined classes or some other variable. Keep in mind it's the actual NPC object, so you can access its variables ("this.").
__________________
Reply With Quote
  #3  
Old 09-03-2011, 09:18 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
with the for findAreaNPCs(x, y, 0.1, 0.1)
what are the 0.1's?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 09-03-2011, 09:21 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 Gunderak View Post
with the for findAreaNPCs(x, y, 0.1, 0.1)
what are the 0.1's?
Directly from the wiki:

Quote:
Originally Posted by The Wiki
findareanpcs(float, float, float, float) - returns object - returns an array of all npcs at the specified rectangle (x,y,width,height)
__________________
Reply With Quote
  #5  
Old 09-03-2011, 09:22 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
is there any way to change another npcs variable by some command like findnpc("whatever").this.mode = ?
if i made it join to a class how would i change the class variables via a script?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #6  
Old 09-03-2011, 09:28 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 Gunderak View Post
is there any way to change another npcs variable by some command like findnpc("whatever").this.mode = ?
if i made it join to a class how would i change the class variables via a script?
The this prefix refers to the current object. If you did it as you proposed (which wouldn't work since you can't use findNPC for local NPCs (level NPCs)), you'd be setting this.this.mode. In the example I gave above,

PHP Code:
temp.npc.variableName value
As I said, temp.npc is the actual NPC object.

What do you mean by class variables? That doesn't make any sense, classes are joined to an object. They don't have separate sets of variables.
__________________
Reply With Quote
  #7  
Old 09-05-2011, 04:16 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
whoever repped me for "being a disgrace to the 'scripter' title"
these forums are a place to learn, i am relativly new to scripting.
so please in future dont judge people over their scripting ability.
if this is your outlook on life i really dont think these forums are the place for you.

@cbk1994 i mean class variables as in if a class has this.whatever = whatever;
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #8  
Old 09-05-2011, 04:21 PM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
Quote:
Originally Posted by Gunderak View Post
whoever repped me for "being a disgrace to the 'scripter' title"
these forums are a place to learn, i am relativly new to scripting.
so please in future dont judge people over their scripting ability.
if this is your outlook on life i really dont think these forums are the place for you.

@cbk1994 i mean class variables as in if a class has this.whatever = whatever;
Aren't there special flags within the NPC with vars that you can write to? Just join your class to your NPC and redefine them I guess?
__________________
Quote:
Originally Posted by ffcmike View Post
But make sure to change beer.png to Orange Juice.
pay bills to play graal
Reply With Quote
  #9  
Old 09-06-2011, 06:45 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
ahh thats a batter idea.
can i put
PHP Code:
function onCreated() {
this.join("whatever");
this.mode "idle";

would it still go to on created? or would it stop and go to the class?
im at work so i cant test it.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #10  
Old 09-06-2011, 12:58 PM
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
What do you mean by "go to the class"? You seem to have a misunderstanding of how classes work. It doesn't create another object or stop execution of the current one. Imagine the class' script being copied and pasted into the NPC you join it to. onCreated in classes will be triggered if you join the class to something.
__________________
Reply With Quote
  #11  
Old 09-07-2011, 01:11 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
thanks i tested it at home, i thought if i joined it to a class seeming my class had a timeout it would go execute my class and stay on the class because its looping.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
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 09:12 AM.


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