Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-05-2011, 11:46 PM
Sp_lit Sp_lit is offline
Mercury
Sp_lit's Avatar
Join Date: Mar 2010
Location: Sweden
Posts: 102
Sp_lit will become famous soon enough
Problem using a level NPC that's joined to a class

Hey there!
This is me and my friend's first attempt at GS2. This is what we've got so far. We're just wondering; are we on the right track here? We have encountered some problem with triggeraction when trying to trigger serverside from clientside, in a level NPC.

Any ideas or suggestions on what to improve or totally change?
In case the aweful script does not tell; we're trying to create a shop system..or something closely remote to one...

Help is very much appreciated, thanks!

Class:
PHP Code:
function onActionBuyItem()
{
  
player.rupees = 0;
}

function 
onCreated() {
  
this.setShape(1, 32, 32);
  
this.dontblock();
}

//#CLIENTSIDE
function onPlayerTouchsMe()
{
  new 
GuiBitmapBorderCtrl("Shop_Window") 
  {
    
this.profile = GuiBitmapBorderProfile;
    
this.width = screenwidth / 2;
    
this.height = screenheight / 2;
    
this.x = screenwidth / 2 - this.width / 2;
    
this.y = screenheight / 2 - this.height / 2;
    
this.canmove = false;
    
this.canresize = false;
    
this.makefirstresponder(true);
    
    new 
GuiButtonCtrl("Shop_Button")
    {
      
width = 100;
      
height = 40;
      
x = Shop_Window.width / 2 - this.width / 2;    
      
y = Shop_Window.height - this.height - 10;
      
text = "Buy";
    }
        
    new 
GuiShowImgCtrl("Shop_Item_Fireball") 
    {
      
x = 20;
      
y = 20;
      
width = 60;
      
height = 60;
      
      
this.imageselected = "split_fireball_selected.png";
      
this.imagenotselected = "split_fireball.png";
      
this.image = this.imageselected;
      
      
this.price = 20;
    }
    
    new 
GuiShowImgCtrl("Shop_Item_Sword") 
    {
      
x = Shop_Item_FireBall.x + Shop_Item_Fireball.width + 20;
      
y = 20;
      
width = 60;
      
height = 60;
      
      
this.imageselected = "split_sword_selected.png";
      
this.imagenotselected = "split_sword.png";
      
this.image = this.imagenotselected;
      
      
this.price = 30;
    }
  }  
  
this.listofitems = {Shop_Item_Fireball, Shop_Item_Sword};
  
this.itemselected = this.listofitems[0];
}

function 
onMouseDown()
{
  if(!((
mousescreenx in |Shop_Window.x, Shop_Window.x + Shop_Window.width|)
      &&(
mousescreeny in |Shop_Window.y, Shop_Window.y + Shop_Window.height|)))
  {
    
Shop_Window.destroy();
  }
}

function 
Shop_Button.onMouseDown()
{
  
triggeraction(this.x + 0.5, this.y + 0.5, "ButItem", null);
}

function 
Shop_Button.onMouseUp()
{
  
Shop_Window.makefirstresponder(true);
}

function 
Shop_Item_Fireball.onMouseDown()
{
  for(
i = 0; i < this.listofitems.size(); i ++)
  {
    
this.listofitems[i].image = this.listofitems[i].imagenotselected;   
    if(
this.listofitems[i] == Shop_Item_Fireball)
      
this.itemselected = this.listofitems[i];
  } 
  
Shop_Item_Fireball.image = Shop_Item_Fireball.imageselected;
}

function 
Shop_Item_Sword.onMouseDown()
{
  for(
i = 0; i < this.listofitems.size(); i ++)
  {
    
this.listofitems[i].image = this.listofitems[i].imagenotselected;   
    if(
this.listofitems[i] == Shop_Item_Sword)
      
this.itemselected = this.listofitems[i];
  }
  
Shop_Item_Sword.image = Shop_Item_Sword.imageselected;
} 
NPC:
PHP Code:
this.join("shopkeeper"); 
__________________
Reply With Quote
 

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 04:31 PM.


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