Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Tetris grid inventory system? This biggest, stupidest question you've ever seen.

Asked by 3 years ago
Edited 3 years ago

edit: this isn't a "gimme script" thing, i'm just completely stuck on the logic.

General programming logical question

I'm trying to recreate tarkov's inventory system.

So far I have a 2d array of item slots, each item slot can have a item value, but item values don't take up multiple slots, only the "top left" of the 2d item

so the general 2d array looks like this

[1,1] [1,2] [1,3] [1,4] [1,5]
[2,1] [2,2] [2,3] [2,4] [2,5]
[3,1] [3,2] [3,3] [3,4] [3,5]
[4,1] [4,2] [4,3] [4,4] [4,5]
[5,1] [5,2] [5,3] [5,4] [5,5]

(Lua counts from 1, don't blame me for it.)

Each 'Item' takes up only ONE of these slot 2d values, But items have a reference too a table that looks like this

sword = {
    {nil, true, nil},
    {nil, true, nil},
    {nil, true, nil},
    {nil, true, nil},
    {nil, true, nil},
    {true, true, true},
    {nil, true, nil},
    {nil, true, nil},
}

If you look at what these "true" values draw, they make the rough shape of a sword. I need a way to convert these values into the grid references, if that makes sense. https://cdn.discordapp.com/attachments/103875996138102784/774674908126248980/unknown.png this is what i mean by each item originating in the top left For example the yellow item is 2 wide and 3 tall but only the top right, right, bottom right, and left are actually occupied so it would look like this

`{false, true},
{true, true},
{false, true},

so basically my move function would be something like

move(fromContainer, toContainer, coordsFrom, coordsTo)

https://cdn.discordapp.com/attachments/165226280118255616/774655066221183017/unknown.png Firest of all thats the unity system which uses overlaps

Here's what the guy suggested on the server with inconsistent variable names https://cdn.discordapp.com/attachments/103875996138102784/774675607899996200/unknown.png

https://i.gyazo.com/3c98dbb896702102dfc7474ff6377f5d.mp4 Example of a github thing in unity which uses client-side UI rect.overlay/overlap or something things that wouldn't work in a networked or roblox-multiplayer enviroment.

https://cdn.discordapp.com/attachments/103875996138102784/774677741249101834/unknown.png Something i found on google images

Basically i'm trying to make a tetris inventory system with tables, And I have no clue how to do the logic.

1
Sorry explain again? User#30567 0 — 3y

Answer this question