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 06-16-2006, 06:22 AM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
Weapons -IRC -Playerlist etc

I'm trying to make a Q Menu, but when I categorize the weapons then try displaying them, I always get shown these (in this order)

Quote:
Originally Posted by Weapons
-IRC
-Playerlist
-F2LogWindow
-F1HelpWindow
-IRC_Installer
-LoadingScreen3D
-IRCEvents
Then my weapons start getting listed. Is there any way to avoid this?
__________________



Reply With Quote
  #2  
Old 06-16-2006, 06:51 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
PHP Code:
this.systemweapons = { "-IRC""-Playerlist""-F2LogWindow""-F1HelpWindow""-IRC_Installer""-LoadingScreen3D""-IRCEvents" };

temp.playeractualweapons NULL;
for(
temp.checkweaponplayer.weapons) {
  if(
this.systemweapons.index(temp.checkweapon) < 0) {
    
temp.playeractualweapons.add(temp.checkweapon);
  }

?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 06-16-2006, 06:54 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by Omini
I'm trying to make a Q Menu, but when I categorize the weapons then try displaying them, I always get shown these (in this order)

Then my weapons start getting listed. Is there any way to avoid this?
Not sure if youve tried it but just dont display any weapons with a - in the front.

PHP Code:
if (obj.substring(0,1) != "-") {

Not sure of any of your code or what you have or havent tried, when you are looking at the weapon-name just make sure the first mark isnt a dash, if it is, just skip over it.
Reply With Quote
  #4  
Old 06-16-2006, 06:59 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Andy0687
Not sure if youve tried it but just dont display any weapons with a - in the front.

PHP Code:
if (obj.substring(0,1) != "-") {

Not sure of any of your code or what you have or havent tried, when you are looking at the weapon-name just make sure the first mark isnt a dash, if it is, just skip over it.
Good advice, -Weapons are supposed to be invisible anyway. However, you should use if(obj.starts("-")) instead of the substring variation.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 06-16-2006, 11:36 AM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
Yeah I've got this in

PHP Code:
function GetWeaponList()
  {
  
thiso.weapons_systems.clear();
  
thiso.weapons_guns.clear();
  
thiso.weapons_ammo.clear();
  
thiso.weapons_player.clear();
  
thiso.weapons_toys.clear();
  
thiso.weapons_other.clear();
  for(
i=0;i<player.weapons.size();i++) {
    if(
player.weapons[i].name.starts("-")) {
      
thiso.weapons_systems.add(i);
    }
    elseif(
player.weapons[i].name.starts("Guns/")) {
      
thiso.weapons_guns.add(i);
    }
    elseif(
player.weapons[i].name.starts("Ammo/")) {
      
thiso.weapons_ammo.add(i);
    }
    elseif(
player.weapons[i].name.starts("Player/")) {
      
thiso.weapons_player.add(i);
    }
    elseif(
player.weapons[i].name.starts("Toys/")) {
      
thiso.weapons_toys.add(i);
    }
    else {
      
thiso.weapons_other.add(i);
    }
  }

I'll try what Okie said then get back to you.

Edit:

Ok so I tried this
PHP Code:
function GetWeaponList()
  {
  
this.systemweapons = { "-IRC""-Playerlist""-F2LogWindow""-F1HelpWindow""-IRC_Installer""-LoadingScreen3D""-IRCEvents" };

  
temp.playeractualweapons NULL;
  for(
temp.checkweaponplayer.weapons) {
    if(
this.systemweapons.index(temp.checkweapon) < 0) {
      
temp.playeractualweapons.add(temp.checkweapon);
    }
  } 

And the bit where it shows the weapon names is (Within the GUI Window Ctrl etc etc, it was all working somewhat fine)

PHP Code:
new GuiScrollCtrl(QMenu_ItemList) {
      
awake true;
      
canmove true;
      
height QMenu_Window.height-40;
      
vscrollbar "dynamic";
      
hscrollbar "alwaysOff";
      
profile "GuiRedScrollProfile";
      
scriptlogmissingfunctions true;
      
visible true;
      
width QMenu_Window.width-80;
      
70;
      
28;
      
      for (
w=0;w<temp.playeractualweapons.size();w++) {
        new 
GuiTextCtrl("QMenu_Weapon"@w) {
          
2;
          
11;
          
width 200;
          
height 20;
          
useownprofile true;
          
profile.fontcolor = {1,1,1};
          
text temp.playeractualweapons[w].name;
        }
      }
    } 
Any suggestions?
__________________



Reply With Quote
  #6  
Old 06-17-2006, 04:54 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by ApothiX
Good advice, -Weapons are supposed to be invisible anyway. However, you should use if(obj.starts("-")) instead of the substring variation.
Is either more processor intensive then the other?
Just wondering.

Substring was the first thing that popped into my head that would have worked, so thanks for that.

Quote:
Originally Posted by Omini
newstuff+code
Sorry, is something still wrong or broken?
Reply With Quote
  #7  
Old 06-17-2006, 04:58 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Andy0687
Is either more processor intensive then the other?
Just wondering.
Probably not, but obj.starts() looks a bit neater than extracting a substring and comparing it, IMO.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 06-17-2006, 06:32 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Andy0687
Is either more processor intensive then the other?
I believe so. Creating a new string object that represents the substring is probably less performant than just checking the beginning of a pre-existing string against another pre-existing string.
Reply With Quote
  #9  
Old 06-17-2006, 09:08 AM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
Quote:
Originally Posted by Andy0687
Sorry, is something still wrong or broken?
Yes. It's still listing those weapons first before the actual string.
__________________



Reply With Quote
  #10  
Old 06-17-2006, 05:53 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
Should be obj.name.starts("-") and "this.systemweapons.index(temp.checkweapon.nam e) < 0"
Reply With Quote
  #11  
Old 06-17-2006, 07:30 PM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
I don't quite catch what you mean... what am I meant to do with the obj.name.starts("-")?
__________________



Reply With Quote
  #12  
Old 06-17-2006, 09:47 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Your problem is that you are using temp.variables in a function. temp.variables only exist during a single execution, and are only in the scope of where you create them, I believe.

Change the temp.playeractualweapons to this. and it should work. (Except in the new GuiBlah() you must use 'thiso.' instead of 'this.')
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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:17 AM.


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