Use mouse to show item
This commit is contained in:
parent
ad17db85b5
commit
f447ea13e5
21
crafting.lua
21
crafting.lua
@ -25,6 +25,8 @@ craft_output_selection_y = 0
|
||||
|
||||
crafting.craft_inventory = {}
|
||||
|
||||
crafting.held_item = {}
|
||||
|
||||
--create crafting inventory
|
||||
for i = 1,crafting.craft_size*crafting.craft_size do
|
||||
crafting.craft_inventory[i] = {}
|
||||
@ -118,13 +120,18 @@ function crafting.move_items()
|
||||
if crafting_open == true then
|
||||
if left and old_left_mouse == false then
|
||||
if crafting_selection_x > 0 and crafting_selection_y > 0 then
|
||||
if selected_slot > 0 and old_selected_slot ~= selected_slot and inventory[selected_slot]["id"] then
|
||||
|
||||
if not crafting.held_item["id"] then
|
||||
crafting.held_item["id"] = inventory[crafting_selection_x + ((crafting_selection_y-1) * inventory_size)]["id"]
|
||||
crafting.held_item["count"] = inventory[crafting_selection_x + ((crafting_selection_y-1) * inventory_size)]["count"]
|
||||
inventory[crafting_selection_x + ((crafting_selection_y-1) * inventory_size)] = {}
|
||||
--[[
|
||||
print("removeing")
|
||||
local old_slot = inventory[selected_slot]
|
||||
|
||||
inventory_remove(selected_slot,nil)
|
||||
|
||||
selected_slot = crafting_selection_x + ((crafting_selection_y-1) * inventory_size)
|
||||
selected_slot =
|
||||
|
||||
inventory_add(old_slot["id"],selected_slot)
|
||||
|
||||
@ -132,9 +139,15 @@ function crafting.move_items()
|
||||
selected_slot = -1
|
||||
|
||||
old_selected_slot = selected_slot
|
||||
]]--
|
||||
--else
|
||||
-- print("test")
|
||||
-- selected_slot = crafting_selection_x + ((crafting_selection_y-1) * inventory_size)
|
||||
else
|
||||
print("test")
|
||||
selected_slot = crafting_selection_x + ((crafting_selection_y-1) * inventory_size)
|
||||
inventory[crafting_selection_x + ((crafting_selection_y-1) * inventory_size)]["id"] = crafting.held_item["id"]
|
||||
inventory[crafting_selection_x + ((crafting_selection_y-1) * inventory_size)]["count"] = crafting.held_item["count"]
|
||||
|
||||
crafting.held_item = {}
|
||||
end
|
||||
|
||||
end
|
||||
|
2
main.lua
2
main.lua
@ -39,12 +39,12 @@ screenheight = love.graphics.getHeight( )
|
||||
function love.draw()
|
||||
maplib.draw()
|
||||
player.draw()
|
||||
menu.draw()
|
||||
player.draw_health()
|
||||
render_inventory()
|
||||
entity.render_entity()
|
||||
particle.render_particle()
|
||||
crafting.render_crafting()
|
||||
menu.draw()
|
||||
end
|
||||
|
||||
function love.load()
|
||||
|
7
menu.lua
7
menu.lua
@ -57,6 +57,7 @@ function menu.draw()
|
||||
for i = 1,characters do
|
||||
love.graphics.print(menutitle[i], screenwidth-260+(12*i),screenheight-10+menu_char[i] )
|
||||
end
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if debugger == true then
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
fpsGraph:draw()
|
||||
@ -111,6 +112,12 @@ function menu.draw()
|
||||
|
||||
love.graphics.print("Deaths:"..tostring(deaths), xxer, 250)
|
||||
end
|
||||
|
||||
if crafting.held_item["id"] then
|
||||
local x, y = love.mouse.getPosition( )
|
||||
love.graphics.draw(texture_table[crafting.held_item["id"]], x, y,0, 4, 4)
|
||||
love.graphics.print( crafting.held_item["count"], x+50, y+64, 0, 1, 1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user