mirror of
https://github.com/D4M13N-D3V/godot_grid_inventory.git
synced 2025-03-14 08:14:55 +00:00
Merge pull request #3 from D4M13N-D3V/2-is_grid_space_available-on-the-inventorygrid-class-is-not-working-properly
fix the inventory grid class to account for global position not being…
This commit is contained in:
commit
6a3c366cd9
@ -92,6 +92,7 @@ func show_context_menu(mouse_pos: Vector2, item):
|
|||||||
# Function to hide the context menu
|
# Function to hide the context menu
|
||||||
func hide_context_menu():
|
func hide_context_menu():
|
||||||
if(inventory_context_menu!=null):
|
if(inventory_context_menu!=null):
|
||||||
|
inventory_context_menu_item=null
|
||||||
inventory_context_menu.queue_free()
|
inventory_context_menu.queue_free()
|
||||||
|
|
||||||
func context_menu_open():
|
func context_menu_open():
|
||||||
|
@ -135,13 +135,15 @@ func get_item_under_pos(pos):
|
|||||||
if item.get_global_rect().has_point(pos):
|
if item.get_global_rect().has_point(pos):
|
||||||
return item
|
return item
|
||||||
return null
|
return null
|
||||||
|
# Function to insert an item at the first available spot in the grid
|
||||||
# Function to insert an item at the first available spot in the grid
|
# Function to insert an item at the first available spot in the grid
|
||||||
func insert_item_at_first_available_spot(item):
|
func insert_item_at_first_available_spot(item):
|
||||||
for x in inventory_item_grid_width:
|
for x in range(inventory_item_grid_width):
|
||||||
for y in inventory_item_grid_height:
|
for y in range(inventory_item_grid_height):
|
||||||
if not inventory_item_grid[x][y]["used"]:
|
if inventory_item_grid[x][y]["used"] == false:
|
||||||
item.global_position = Vector2(x* inventory_item_grid_cell_size, (y)* inventory_item_grid_cell_size)
|
item.global_position = global_position+ Vector2(x * inventory_item_grid_cell_size, y * inventory_item_grid_cell_size)
|
||||||
if insert_item(item)==true:
|
if insert_item(item) == true:
|
||||||
|
print("Item inserted at:", item.position)
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user