Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 06-05-2010, 09:10 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by sssssssssss View Post
could you explain this? I'd rather learn, so I dont have to post so many threads for help. Im really not sure what too many of this does, just by looking at it, and not too sure on how to use it. Im guessing its a function that goes in the dbnpc script, and I call it to show up the items for the category selected, but if an explanation line by line is possible with comments or something, that would be great.
PHP Code:
public function getCategoryListing(temp.category){
  
clearemptyvars(); // Removes any empty variables in the npc, for example: it would remove 'this.var1= ' if it existed for some reason (usually pointing to an empty object when that happens).
  
temp.list = {}; // Create an array outside of for-loop scope so it can be used inside of the for-loop and also outside of it (for the return value).
  // This first for loop will loop through all variables starting with this.item.(temp.category).* where temp.category is the parameter passed in the function and * is anything. For example: if temp.category="pie" then it would loop through all variables starting with 'this.item.pie.' I will explain getdynamicvarnames() below.
  
for (temp.acntthis.item.(@temp.category).getdynamicvarnames() ) {
  
// This for loop will loop through similarly to the one above, using the value that was found from 'this.item.(@temp.category).getdynamicvarnames()' to look for deeper variables.
    
for (temp.itemthis.item.(@temp.category).(@temp.acnt).getdynamicvarnames() ){
      
// temp.v is equivalent to 'this.item.(@temp.category).(@temp.acnt).(@temp.item)' in order to shorten it because it will be used several times for temp.list.add().
      
temp.this.item.(@temp.category).(@temp.acnt).(@temp.item);
      
// Add values to the list in their respective order.
      
temp.list.add({ temp.itemtemp.v[0], temp.acnttemp.v[3] });
    }
  }

  return 
temp.list;

var.getdynamicvarnames() returns a list of all variables that exist starting with 'var.' This can be used in several ways, for example, to return all client.variables, you could do:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  for (
temp.iclient.getDynamicVarNames()) {
    echo(
"client." temp." = " client.( @ temp.i));
  }

Personally, I don't think you should follow the suggestion given above because it seems needlessly complicated unless you fully understand what is going on within the code.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
 


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:15 AM.


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