Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-13-2008, 07:06 AM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
trigger problems

a friend of mine made a script but something odd is going wrong.
PHP Code:
function onActionGrab()
{
  
triggeraction(level.chairxlevel.chairy"Shock""");

PHP Code:
function onCreated()
{
  
setshape(13232);

  
/*
  showcharacter();
  this.headimg = "era_personal_understood-noobhulk.gif";
  this.colors[0] = "green";
  this.colors[1] = "darkpurple";
  this.colors[2] = "darkpurple";
  this.colors[3] = "green";
  this.colors[4] = "darkpurple";
  this.colors[5] = "black";
  this.colors[6] = "white";
  this.shieldimg = "no-shield.png";
  this.bodyimg = "wad-muscle-body.png";
  dir = 2;
  setcharani("era_prison-elect-idle", "");
  */

  
level.chairx this.x;
  
level.chairy this.y;
}

function 
onActionShock()
{
  
this.setcharani("era_prison-elect-shock""");
  
message("Did someone just push the button?...");
  
sleep(3);
  
message("#$!, I've gotta get out of here...");
  
sleep(3.00);
  
message("SHI--");
  
sleep(.5);
  
message("");

it doesn't work unless I take out all the attribute stuff. (the stuff commented out) can I get an explanation? :[
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #2  
Old 08-13-2008, 12:34 PM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Quote:
Originally Posted by Frankie View Post
it doesn't work unless I take out all the attribute stuff. (the stuff commented out) can I get an explanation? :[
Try to trigger level.chairx + 1 and level.chair + 1 when using setshape.
__________________
Reply With Quote
  #3  
Old 08-13-2008, 03:22 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Here is an alternative.
PHP Code:
function onActionGrab() {
  
this.level.chair.trigger("ActionShock""");

PHP Code:
function onCreated() {
  
this.setshape(13232);
  
this.level.chair this;
}
function 
onActionShock() {
  
// do stuff

The this. prefix isn't required in this instance but it is my preference to do it like that so you clearly know what the variable belongs to.
__________________

Last edited by Inverness; 08-13-2008 at 04:54 PM..
Reply With Quote
  #4  
Old 08-16-2008, 08:47 AM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
I used to have an issue with triggeraction where I could only trigger an NPC with triggeraction if the NPC had an image set to it when the trigger reaches it. Don't know if that is true anymore, just a thought.
Reply With Quote
  #5  
Old 08-16-2008, 03:18 PM
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 The_Kez View Post
I used to have an issue with triggeraction where I could only trigger an NPC with triggeraction if the NPC had an image set to it when the trigger reaches it. Don't know if that is true anymore, just a thought.
That sounds like setshape issues to me.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 08-16-2008, 03:43 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by The_Kez View Post
I used to have an issue with triggeraction where I could only trigger an NPC with triggeraction if the NPC had an image set to it when the trigger reaches it. Don't know if that is true anymore, just a thought.
Hmm, when you set an image, if no shape is set, the npc will take shape as the shape of the image if I'm not wrong ;o
__________________
Reply With Quote
  #7  
Old 08-17-2008, 01:41 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Quote:
Originally Posted by Inverness View Post
Here is an alternative.
PHP Code:
function onActionGrab() {
  
this.level.chair.trigger("ActionShock""");

PHP Code:
function onCreated() {
  
this.setshape(13232);
  
this.level.chair this;
}
function 
onActionShock() {
  
// do stuff

The this. prefix isn't required in this instance but it is my preference to do it like that so you clearly know what the variable belongs to.
I like this idea, I didn't think of this! [However, you'd need to remove the 'this.level.chair' to replace it with 'level.chat' and also make the 'onActionShock' a public function]
Reply With Quote
  #8  
Old 08-17-2008, 01:54 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by [email protected] View Post
However, you'd need to remove the 'this.level.chair' to replace it with 'level.chat'
No you don't. And I assume you meant level.chair. In an NPC, this.level.chair is the same as level.chair because static (built-in) variables can be accessed with or without the this. prefix.
Quote:
Originally Posted by [email protected] View Post
and also make the 'onActionShock' a public function
No you don't, it only needs to be public if you're calling it. You can trigger events even if they're not public.

Function Call: this.level.chair.onActionShock();
Calling a function means its on the same thread so that function must complete before the script can continue to next statement. To call a function in a different object it needs to be public.

Event Trigger: this.level.chair.trigger("ActionShock", null);
Triggering an event means its on a different thread, so it means the script that triggered it will continue to next statement while the onActionShock executes at the same time. An event does not need to be public to trigger it because the trigger function is public and that is the function you are using.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:47 PM.


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