Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Need some advice on this approach.. (https://forums.graalonline.com/forums/showthread.php?t=134269034)

Torankusu 01-25-2014 02:35 PM

Need some advice on this approach..
 
I am making a mock up of an inventory system, and I want to have grid alignment.

Ex:
0 0 0 0
0 0 0 0

Not:
00 0 0
0 0 00

At the moment, I am using a frames control, And showimg for the icons (32x32 pix), and that works fine.

What I want to do, is, say for example I have an icon that id 32 pix wide, and 64 pixels in height. I need that to take up grid space like this:

0 0 X 0
0 0 X 0

Without allowing anything else To display in that slot (X's refer to 32x64 item.)

I have thought of checking for the width/height of the image and basically chopping it in two and displaying two halves (one half in each corresponding frame) but that seems messy.

Chompy 01-27-2014 01:14 PM

So, an inventory system like Diablo, Torchlight, Neverwinter Nights, Path of Exile, etc? Items take up different spaces but basically as a different sized square?

Torankusu 01-27-2014 05:41 PM

Quote:

Originally Posted by Chompy (Post 1725623)
So, an inventory system like Diablo, Torchlight, Neverwinter Nights, Path of Exile, etc? Items take up different spaces but basically as a different sized square?

Haven't played those games, but yeah, I think you get what I mean. I want some items to be restricted to taking up VISIBLE / physical space in the inventory window.

Here's What I have so far (not much at all, mind you...)...
I've actually gotten stuck on the dragging part. :[

Everything I try it just shows the image UNDER the GUI, and doesn't seem to move with the mouse.

http://pastebin.com/9u8Bxa75

sssssssssss 01-27-2014 06:36 PM

Quote:

Originally Posted by Torankusu (Post 1725497)
I am making a mock up of an inventory system, and I want to have grid alignment.

Ex:
0 0 0 0
0 0 0 0

Not:
00 0 0
0 0 00

At the moment, I am using a frames control, And showimg for the icons (32x32 pix), and that works fine.

What I want to do, is, say for example I have an icon that id 32 pix wide, and 64 pixels in height. I need that to take up grid space like this:

0 0 X 0
0 0 X 0

Without allowing anything else To display in that slot (X's refer to 32x64 item.)

I have thought of checking for the width/height of the image and basically chopping it in two and displaying two halves (one half in each corresponding frame) but that seems messy.

If you already have a way to check the width/height of the images, when you set the amount per line to show read each one its putting in as it comes in a loop, and check the width/height there, set a temp.var in the order, then on the next line (i'd imagine also in your loop) do checks to see, and if it the temp.var is set, on that next line when the loop comes to it, make it null on that spot for the image, erase the temp.var, and if there are anymore the set above for the temp.var will reset it to the next one.

e.g.
PHP Code:

for (temp.0temp.< array.size(); temp.i++) {
 
// set up a checker for what position in the line it is (#1 - 6 in each line)
  
if (!temp.itemPos) {
    
temp.itemPos 0;
    
temp.line 0;
  }
  
// since this is for the line, if it's past the 6 max for the line, reset
  
if (itemPos 6) {
    
itemPos 0;
    
line++;
  }

  new 
GuiImgCtrl("whatever"@someID/Name) {
    
set x's
    y = line + adjustment space here
    // set everything else, including where you read for your width/height
  }
  
  // see if the width or height (or both) is more than 32
  if (getimgwidth(whaterver.image) > 32) {
    temp.checkW = true;
    temp.checkWID = itemPos + 1;
  }
  if (getimgheight(whaterver.image) > 32) {
    temp.checkH = true;
    temp.checkHID = itemPos + 6;
  }

  // now check the width/height
  if (checkW && itemPos == checkWID) {
    this.checkW = false;
    // set the next image to move over
    (@"whatever"@someID/Name).x = adjust over to next;

    itemPos += 2;
  }else if (checkH && itemPos == checkHID) {
    this.checkH = false;
    // set the image under to move over when you get there
    (@"whatever"@someID/Name).x = adjusted over 1 however u wanna do it;
   
    itemPos += 2;
  }else itemPos++;

  // make sure to add the img ctrl to a parent, either a scroll or window.


I haven't tested the above, just going off how I would start. It may not be the best; I'm not the best scripter. Someone might have a better way.

100Zero100 01-28-2014 02:57 AM

You could opt to just make a grid of indices that correlates to the image grid. When an item is placed into the grid, it would set indices of the array to 1 where it's blocking.

Should be pretty simple using standard grid algorithms (ie, mod and int division)

xAndrewx 02-01-2014 06:14 PM

Quote:

Originally Posted by sssssssssss (Post 1725636)
If you already have a way....

Your loop is very sloppy... if you learn maths you can optimize it a substantial amount.


All times are GMT +2. The time now is 06:00 PM.

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