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 05-28-2014, 12:07 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Finding Params

I'm having issues with the placed NPC finding the right params...

On the placement..
PHP Code:
function onActionServerSide(){
 if (
params[0] == "place"){
  
temp.npc this.level.putNPC2(player.xplayer.y+1params[1]);
  
temp.npc.join("combat_dmgdisplay");
  }
 } 

//#CLIENTSIDE
//blah blah blah
triggerserver("weapon"this.name"place"123); //123 is my test value (params[1]..this is what I want the NPC placed to display 

and in the NPC..
PHP Code:
function onCreated(){
 
setImg("block.png");
 
setTimer(1);
 
dontblock();
 
drawoverplayer();
 
this.chat params[1];
 }
 
function 
onTimeOut(){
 
destroy();
 } 

The NPC just keeps saying 0..
I most likey have things in the wrong spots.

Someone help me out please!

Last edited by i8bit; 05-28-2014 at 09:14 AM..
Reply With Quote
  #2  
Old 05-28-2014, 12:15 AM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
hello!

in the provided example you are checking to see if the first parameter is "place" yet the one parameter which is defined is "dmg", in that case i dont see how an npc should be placed to begin with. i can only assume this is a mistake with the example

the reason the npcs chat would be "0" though is because there simply are no parameters within the onCreated event on the npc object itself

you can actually write the npcs chat at the same time you create it like so:

PHP Code:
temp.npc this.level.putNPC2(player.xplayer.y+1""/*params[1]*/); //3rd parameter here is supposed to be the npcs script, but you are joining a class externally anyway
temp.npc.chat params[1]; 
also just a note that although it might work through some quirk, it doesnt really make sense to be using 'this.level' serverside within a weapon object, it makes more sense to use 'player.level'
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #3  
Old 05-28-2014, 09:16 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by Jakov_the_Jakovasaur View Post
hello!

in the provided example you are checking to see if the first parameter is "place" yet the one parameter which is defined is "dmg", in that case i dont see how an npc should be placed to begin with. i can only assume this is a mistake with the example

the reason the npcs chat would be "0" though is because there simply are no parameters within the onCreated event on the npc object itself

you can actually write the npcs chat at the same time you create it like so:

PHP Code:
temp.npc this.level.putNPC2(player.xplayer.y+1""/*params[1]*/); //3rd parameter here is supposed to be the npcs script, but you are joining a class externally anyway
temp.npc.chat params[1]; 
also just a note that although it might work through some quirk, it doesnt really make sense to be using 'this.level' serverside within a weapon object, it makes more sense to use 'player.level'

I just fixed my thread post...
The "dmged" was a typo.. I rewrite some stuff to make it easier to read on forums.. I just forgot to change that.


With that being said, I want to do the chat within the "class" script. Not in the creation of the NPC.

So I would need a
PHP Code:
this.chat params[1]; 
But it doesn't recognize params[1]... THAT'S my issue

Last edited by i8bit; 05-28-2014 at 09:47 AM..
Reply With Quote
  #4  
Old 05-28-2014, 05:08 PM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 354
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
Quote:
Originally Posted by i8bit View Post
I just fixed my thread post...
The "dmged" was a typo.. I rewrite some stuff to make it easier to read on forums.. I just forgot to change that.


With that being said, I want to do the chat within the "class" script. Not in the creation of the NPC.

So I would need a
PHP Code:
this.chat params[1]; 
But it doesn't recognize params[1]... THAT'S my issue
well then theres a lot of ways you can do it, a few examples:

PHP Code:
  /*
    weapon
  */

  
temp.npc this.level.putNPC2(player.xplayer.y+1"");
  
temp.npc.join("combat_dmgdisplay");
  
temp.npc.chatParam params[1]; 
PHP Code:
  /*
    npc
  */

  
function onCreated() {
    
this.chat this.chatParam;
  } 
PHP Code:
  /*
    weapon
  */

  
temp.npc this.level.putNPC2(player.xplayer.y+1"");
  
temp.npc.join("combat_dmgdisplay");
  
temp.npc.trigger("SetChat"params[1]); 
PHP Code:
  /*
    npc
  */

  
function onSetChat(temp.chat) {
    
this.chat temp.chat;
  } 
but you wont be able to access the original params[1] outside of the onActionServerSide() event they were passed to
__________________
This signature has been deleted by Darlene159.
Reply With Quote
  #5  
Old 05-28-2014, 10:33 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
I appreciate the help

I actually figured it out last night!
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 06:11 PM.


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