Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2012, 08:52 PM
Entrok Entrok is offline
Registered User
Join Date: Sep 2009
Location: Sweden
Posts: 51
Entrok is on a distinguished road
Send a message via MSN to Entrok
Inventory Question

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?
Attached Images
  
Reply With Quote
  #2  
Old 04-14-2012, 10:33 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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...

__________________
Quote:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:21 PM.


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