Skip to main content
deleted 4 characters in body
Source Link
Howie
  • 332
  • 1
  • 7
Slot (ID, CharacterID, SlotID, EntityIDItemID)
  • Slot is the name of the table
  • ID is the table's primary key
  • CharacterID is a foreign key that points to the character
  • SlotID is the slot's ID going from 1 to 64 (or 0 to 63, or whatever)
  • ItemID is a foreign key that points to the entityitem (ID of a specific weapon, potion...)
Slot (ID, CharacterID, SlotID, EntityID)
  • Slot is the name of the table
  • ID is the table's primary key
  • CharacterID is a foreign key that points to the character
  • SlotID is the slot's ID going from 1 to 64 (or 0 to 63, or whatever)
  • ItemID is a foreign key that points to the entity (ID of a specific weapon, potion...)
Slot (ID, CharacterID, SlotID, ItemID)
  • Slot is the name of the table
  • ID is the table's primary key
  • CharacterID is a foreign key that points to the character
  • SlotID is the slot's ID going from 1 to 64 (or 0 to 63, or whatever)
  • ItemID is a foreign key that points to the item (ID of a specific weapon, potion...)
added 79 characters in body
Source Link
Howie
  • 332
  • 1
  • 7

Since you know the slots form a grid of 8x8 elements, you can use this information in your favor. Here's a pseudocode example when using 0-based SlotIDs (0-63 instead of 1-64):

Since you know the slots form a grid of 8x8 elements, you can use this information in your favor.

Since you know the slots form a grid of 8x8 elements, you can use this information in your favor. Here's a pseudocode example when using 0-based SlotIDs (0-63 instead of 1-64):

deleted 2 characters in body; added 269 characters in body
Source Link
Howie
  • 332
  • 1
  • 7

An example of a character that has a "potion of knowledge" inat the bottom-right corner of the inventory, and a 6-slot "spear of fire & death" inat the top-left corner:

How do you get a 2D grid of 8x8 slots out of this 1D array of slot IDs?

Since you know the slots form a grid of 8x8 elements, you can use this information in your favor.

int x = SlotID % 8;
int y = floor(SlotID / 8);

An example of a character that has a "potion of knowledge" in the bottom-right corner of the inventory, and a 6-slot "spear of fire & death" in the top-left corner:

An example of a character that has a "potion of knowledge" at the bottom-right corner of the inventory, and a 6-slot "spear of fire & death" at the top-left corner:

How do you get a 2D grid of 8x8 slots out of this 1D array of slot IDs?

Since you know the slots form a grid of 8x8 elements, you can use this information in your favor.

int x = SlotID % 8;
int y = floor(SlotID / 8);
Source Link
Howie
  • 332
  • 1
  • 7
Loading