Jump to content

Column & Row


_Marco_

Recommended Posts

  • Moderators
Posted (edited)
-- LAYOUT
local cells            = 30
local cells_in_a_row   = 6

-- CELL SIZE
local cell_size        = 30
local cell_gap         = 5

-- LEFT-TOP corner position
local start_x, start_y = 500, 500


addEventHandler("onClientRender", root, function()
    -- use loop to draw 30 cells
    for i = 0, cells-1 do
      	-- calculate cell index in row. ("i % cells_in_a_row" returns a number between 0 and 5) (modulo)
        local nth_cell = i % cells_in_a_row
      	-- calculate row index
        local nth_row  = math.floor(i / cells_in_a_row)

      	-- cell position
        local x, y = start_x + (cell_size+cell_gap)*nth_cell, start_y + (cell_size+cell_gap)*nth_row
      
      	-- draw cell background and text
        dxDrawRectangle(x, y, cell_size, cell_size)
        dxDrawText(i, x, y, x+cell_size, y+cell_size, 0xff000000, 1, "default", "center", "center")
    end
end)

unknown.png

Edited by Patrick
  • Like 1
Posted

Ty

Is it possible to do something that will be transferred to the second slot if the first slot is full?  Example If the first slot has an item, the next item will be in the second slot

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...