Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-27-2005, 02:15 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
array search

Stefan, you should add this, it can be used like findplayer(account), but with a lot more flexibility.

NPC Code:

//Script made by jake13jake
//on Friday, December 9th,
//also the day of his sister's 21st birthday,
//at 2:45 in the morning!

function find(arr,attr,val) {
for (i=0; i<arr.size(); i++) {
if (arr[i].(@attr) == val)
return arr[i];
}
return -1;
}

Reply With Quote
  #2  
Old 12-27-2005, 03:21 PM
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
You could just create a function class and join the class to NPCs you wish to use it in.

Also, it might be a bit nicer to use the built-in for () iterator.
PHP Code:
function find(arrattrval)
{
  for (
keyarr)
  {
    if (
key.(@attr) == val)
    {
      return 
key;
    }
  }
  return -
1;

__________________
Skyld
Reply With Quote
  #3  
Old 12-27-2005, 03:24 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 Skyld
You could just create a function class and join the class to NPCs you wish to use it in.

Also, it might be a bit nicer to use the built-in for () iterator.
PHP Code:
function find(arrattrval)
{
  for (
keyarr)
  {
    if (
key.(@attr) == val)
    {
      return 
key;
    }
  }
  return -
1;

oh cooool... I didn't know gscript2 ripped that out of java . I still think it would be useful as a built in function though. I'd honestly rather have it as a public function, but you can't do clientside public functions.
Reply With Quote
  #4  
Old 12-27-2005, 03:55 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by jake13jake
oh cooool... I didn't know gscript2 ripped that out of java . I still think it would be useful as a built in function though. I'd honestly rather have it as a public function, but you can't do clientside public functions.
You can, in weapon scripts
Reply With Quote
  #5  
Old 12-27-2005, 04:08 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 Stefan
You can, in weapon scripts
REALLY, I'll tell master storm then . Wait a second though, do you think you could elaborate a little bit?

<3 Stefan

Last edited by jake13jake; 12-27-2005 at 04:35 PM..
Reply With Quote
  #6  
Old 12-27-2005, 09:31 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
PHP Code:
Weapon1
function onWeaponFired() {
  
player.chat Weapon2.Omg(player.account);

PHP Code:
Weapon2
public function Omg(acc) {
  return 
"Zomg your account is" SPC acc;


Help?
Reply With Quote
  #7  
Old 12-27-2005, 10:08 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 Yen
PHP Code:
Weapon1
function onWeaponFired() {
  
player.chat Weapon2.Omg(player.account);

PHP Code:
Weapon2
public function Omg(acc) {
  return 
"Zomg your account is" SPC acc;


Help?
Well, one of the reasons I'd want this command integrated is that it helps you find Weapon2.
Reply With Quote
  #8  
Old 12-27-2005, 10:22 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
Well, one of the reasons I'd want this command integrated is that it helps you find Weapon2.
Never heard of System NPCs?

We don't need a scripting language that is bloated with functions we will never use in our life-time.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #9  
Old 12-27-2005, 11:15 PM
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
Quote:
Originally Posted by Yen
PHP Code:
Weapon1
function onWeaponFired() {
  
player.chat Weapon2.Omg(player.account);

PHP Code:
Weapon2
public function Omg(acc) {
  return 
"Zomg your account is" SPC acc;


Help?
PHP Code:
findWeapon("Weapon2").Omg("variable"); 
... is what I'm thinking.
__________________
Skyld
Reply With Quote
  #10  
Old 12-28-2005, 12:58 AM
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
Yeah, you need to use findweapon() if it has a space, -, *, +, ect.
Reply With Quote
  #11  
Old 12-28-2005, 04:16 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
Is that why findweapon never worked for me?
Reply With Quote
  #12  
Old 12-28-2005, 05:29 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Yen
Yeah, you need to use findweapon() if it has a space, -, *, +, ect.
Or if you'd like to remove any ambiguity.
Reply With Quote
  #13  
Old 12-29-2005, 01:27 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
You can also do ("Complex-Name").omg(stuff). findweapon() and findnpc() have the advantage though that they are not case-sensitive.
The possibility to call code of other Weapon/GUI scripts is good for separating functionality into smaller scripts, instead of having one huge system-script.
Reply With Quote
  #14  
Old 12-29-2005, 02:22 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 Stefan
You can also do ("Complex-Name").omg(stuff). findweapon() and findnpc() have the advantage though that they are not case-sensitive.
The possibility to call code of other Weapon/GUI scripts is good for separating functionality into smaller scripts, instead of having one huge system-script.
Yea, it was in my movement script that I'm hoping master storm will help me on. It separates into a lot of weapons. Complete list now is: -system_moving, -system_sidemoving, -system_action, -system_gani, -system_keys, -system_extra.

Moving handles the default dir/dx/dy handling (pretty simple).
Sidemoving handles the sliding off of corners (not as simple).
Action handles grab/push/pull/jump all on the same counter.
Gani handles the default moving ganis.
Keys handles sword and extra commands like whistle and hug
Extra does the extra simple stuff, like bed movement, handling all movement related scripts, etc. The main goal is to have them work mostly independently of eachother. But, seeing that that could lead to a bit of redundant code, it would be better in some cases to have the systems interact with eachother. The action system and the gani system still need a little bit of work before this new movement is released for Classic, as well as a new carry system created. I also would like to document and post this movement on graal.net. I'm just hoping that Master Storm will actually help out a little bit. I've done it all on my own so far.
Reply With Quote
  #15  
Old 12-29-2005, 04:10 AM
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
I also like to set global variables in weapon scripts for calling functions. So I don't have to use makevar everytime I call something from another script.
PHP Code:
First Weapon:
function 
onCreated() {
  
mud makevar("-SystemMudlib");
}
public function 
additem(itemidqty) {
  
junkhere;

PHP Code:
Second Weapon:
public function 
playerIni() {
  
mud.additem("skill_battleaura1",1);

__________________
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 10:33 PM.


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