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 04-19-2006, 12:24 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Mini Lotto

I'm making a mini lotto game for DR. The script works for 1 NPC, but put more than one in a level, and ALL of them trigger the test action. Why??
PHP Code:

// NPC made by Excaliber
function onCreated()
{
  
setshape(1,32,32);
}
function 
onActiontest()
{
  
playerrupees-=1;
  
this.minilotto_num1=int(random(0,9));
  
this.minilotto_num2=int(random(0,9));
  
this.minilotto_num1*=10;
  
this.minilotto_num=this.minilotto_num1+this.minilotto_num2;
  if(
client.minilotto_num==this.minilotto_num)
  {
    
chat="JACKPOT!";
    
with(findplayer(player.account))
    {
      
play extra.wav//doesn't work
      
playerrupees+=51//does work
    
}
  }
  else
  {
    
chat="Nothing this time... Last number: "@this.minilotto_num;
  }
}
//#CLIENTSIDE
function onPlayertouchsme()
{
  if(
playerrupees>0)
  {
    
chat="Playing";
    
client.minilotto_num=0;
    
mini_lotto.showtop();
    new 
GuiWindowCtrl("mini_lotto")
    {
      
//gui window stuff

        
new GuiButtonCtrl("roll")
        {
          
//roll button stuff
        
}
        new 
GuiTextEditCtrl("p1num")
        {
         
//text stuff
        
}
      new 
GuiTextEditCtrl("p2num")
        {
          
//text stuff
        
}
      }
    }
  }
  function 
roll.onAction()
  {
    
//var setup
    
triggeraction(x,y,"test","test");
  } 
Reply With Quote
  #2  
Old 04-19-2006, 12:29 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
GUI control names are shared across NPCs. Likely, each NPC is receiving roll.onAction().
__________________
Skyld
Reply With Quote
  #3  
Old 04-19-2006, 04:00 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
also, I believe play only works clientside
also it would be play(file);
Reply With Quote
  #4  
Old 04-19-2006, 02:29 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Yeah, the GUI control names are probably conflicting with eachother. Try using something like "roll_" @ this.id or whatever.

also, findplayer(player.account) is the most redundant function call in GraalScript
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 04-19-2006, 07:04 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by ApothiX
Yeah, the GUI control names are probably conflicting with eachother. Try using something like "roll_" @ this.id or whatever.

also, findplayer(player.account) is the most redundant function call in GraalScript
After all, player == findplayer(player.account) is a tautology.

I really can't express how much I want with statements to be deprecated.
Reply With Quote
  #6  
Old 04-19-2006, 11:47 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by jake13jake
I really can't express how much I want with statements to be deprecated.
'with()' lets you modify multiple aspects of a foreign object, without having to repeat the object reference.

PHP Code:
with (findimg(300)) {
  
30;
  
30;
  
text "Hi!";
  
font "Times New Roman";
  
style "cb";
  
red 1;
  
green 0;
  
blue 1;

Reply With Quote
  #7  
Old 04-20-2006, 05:34 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Yen
'with()' lets you modify multiple aspects of a foreign object, without having to repeat the object reference.
Yes, I know, but I prefer using the object reference.
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 05:06 AM.


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