Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Inventory Question (https://forums.graalonline.com/forums/showthread.php?t=134266242)

Entrok 04-14-2012 08:52 PM

Inventory Question
 
2 Attachment(s)
Im trying to learn how to make a inventory based on loading .txt/.arc files and sofar so good, but when i want to place out the weapons that are available i dident know how to do it, so i checked forums but dident find so much about it.

I did check in to Stonehenge how they had done theirs but the prob is that they only have 1 row, with 4 items down like i show in attached file 1.

What im trying to do is to list the items like attached file 2.

What i have tryed to use/modify atm is this:

PHP Code:

  if (this.curtab == NILthis.curtab "weapons";
  
this.gsk getstringkeys("clientr." this.curtab "_");
  

  for (
temp.0temp.min(this.gsk.size(), 5); temp.g++) 
  {  
    
// Draw the icons in the inventory that are currently visible
    
temp.draw clientr.(@ this.curtab "_" this.gsk[temp.this.menuscroll])[3];
    
    
drawImg(502 temp.2temp.draw31 temp.35110 temp.356);
    
temp.writ clientr.(@ this.curtab "_" this.gsk[temp.this.menuscroll])[1];
    
drawText(502 temp.162131 temp.35temp.font"r"temp.writ7.51111);
    if (
mousescreenx in |3163|) 
    {
      if (
mousescreeny in |110 temp.35142 temp.35|) 
      {  
        
// Hovering over an item in the inventory
        
temp.writ clientr.(@ this.curtab "_" this.gsk[temp.this.menuscroll])[2];
        
drawText(500mousescreenxmousescreeny 8temp.font"bc"temp.writ9.50001);
        
drawImg(501"light4.png", -1762 temp.358.7.7.7.7.7);
      }
    }
  } 

How would i make it to list more then 1 row?

fowlplay4 04-14-2012 10:33 PM

One way to do it is to keep track of your current position in the Inventory, then use a dual for loop to draw the amount of rows and columns you're after. I.e.

PHP Code:

//#CLIENTSIDE

function drawInventory() {
  
temp.rows 4// Rows
  
temp.cols  5// Columns
  
temp.spacing 2// Pixels between squares
  
temp.0;
  
temp.tx 100// Top-left X
  
temp.ty 100// Top-left Y
  
temp.icon_width 32;
  
temp.icon_height 32;
  for (
temp.0temp.temp.colstemp.x++) {
    for (
temp.0temp.temp.rowstemp.y++) {
      
temp.item getInventoryItemIcon(temp.i);
      
showimg(200 temp.itemp.itemtemp.tx + (temp.temp.icon_width) + temp.spacingtemp.ty + (temp.temp.icon_height) + temp.spacing);
      
changeimgvis(200 temp.i4); // Draws is on screen-level instead of player.
      
temp.i++; // You could do math to determine the item by x and y but a simple counter is easier
    
}
  }
}

function 
getInventoryItemIcon(item_pos) {
  return 
this.items[item_pos].icon// Placeholder...




All times are GMT +2. The time now is 01:33 AM.

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