View Single Post
  #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(13232);
  
this.dontblock();
}

//#CLIENTSIDE
function onPlayerTouchsMe()
{
  new 
GuiBitmapBorderCtrl("Shop_Window"
  {
    
this.profile GuiBitmapBorderProfile;
    
this.width screenwidth 2;
    
this.height screenheight 2;
    
this.screenwidth this.width 2;
    
this.screenheight this.height 2;
    
this.canmove false;
    
this.canresize false;
    
this.makefirstresponder(true);
    
    new 
GuiButtonCtrl("Shop_Button")
    {
      
width 100;
      
height 40;
      
Shop_Window.width this.width 2;    
      
Shop_Window.height this.height 10;
      
text "Buy";
    }
        
    new 
GuiShowImgCtrl("Shop_Item_Fireball"
    {
      
20;
      
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"
    {
      
Shop_Item_FireBall.Shop_Item_Fireball.width 20;
      
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_FireballShop_Item_Sword};
  
this.itemselected this.listofitems[0];
}

function 
onMouseDown()
{
  if(!((
mousescreenx in |Shop_Window.xShop_Window.Shop_Window.width|)
      &&(
mousescreeny in |Shop_Window.yShop_Window.Shop_Window.height|)))
  {
    
Shop_Window.destroy();
  }
}

function 
Shop_Button.onMouseDown()
{
  
triggeraction(this.0.5this.0.5"ButItem"null);
}

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

function 
Shop_Item_Fireball.onMouseDown()
{
  for(
0this.listofitems.size(); ++)
  {
    
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(
0this.listofitems.size(); ++)
  {
    
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