Add in throwing items
This commit is contained in:
parent
a500ab9386
commit
c890bdd13c
@ -32,7 +32,7 @@ function entity.create_entity(type,sizex,sizey,texture,chunkx,chunky,posx,posy,i
|
|||||||
entity_table[entity_count]["texture"] = texture
|
entity_table[entity_count]["texture"] = texture
|
||||||
end
|
end
|
||||||
|
|
||||||
print(entity_count)
|
--print(entity_count)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ function entity.gravity()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("entity "..i.." in unloaded chunk")
|
--print("entity "..i.." in unloaded chunk")
|
||||||
entity_table[i]["inertiax"] = 0
|
entity_table[i]["inertiax"] = 0
|
||||||
entity_table[i]["inertiay"] = 0
|
entity_table[i]["inertiay"] = 0
|
||||||
end
|
end
|
||||||
|
@ -106,3 +106,13 @@ function render_inventory()
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function throw_item()
|
||||||
|
print(inventory[inventory_selection]["id"])
|
||||||
|
if inventory[inventory_selection]["id"] ~= nil then
|
||||||
|
--do it in this order to avoid nil
|
||||||
|
entity.create_entity("item",0.4,0.4,nil,chunkx,chunky,player.playerx,player.playery+0.5,math.random(-300,300)/1000,math.random(-150,-240)/1000,inventory[inventory_selection]["id"])
|
||||||
|
inventory_remove(inventory_selection,inventory[inventory_selection]["id"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -128,6 +128,10 @@ function love.keypressed( key, scancode, isrepeat )
|
|||||||
entity.create_entity("item",0.4,0.4,texture_table[2],chunkx,chunky,player.playerx,player.playery,0,0,nil)
|
entity.create_entity("item",0.4,0.4,texture_table[2],chunkx,chunky,player.playerx,player.playery,0,0,nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--throw stuff
|
||||||
|
if key == "q" then
|
||||||
|
throw_item()
|
||||||
|
end
|
||||||
|
|
||||||
--trick to get input as inventory change
|
--trick to get input as inventory change
|
||||||
--greater than 1 to not select air
|
--greater than 1 to not select air
|
||||||
@ -197,7 +201,8 @@ function mine(key,dt)
|
|||||||
minesound:stop()
|
minesound:stop()
|
||||||
minesound:play()
|
minesound:play()
|
||||||
|
|
||||||
inventory_add(loaded_chunks[selected_chunkx][selected_chunky][mx][my]["block"])
|
--THIS
|
||||||
|
--inventory_add(loaded_chunks[selected_chunkx][selected_chunky][mx][my]["block"])
|
||||||
|
|
||||||
--print(math.random(10,50)/1000)
|
--print(math.random(10,50)/1000)
|
||||||
entity.create_entity("item",0.4,0.4,nil,selected_chunkx,selected_chunky,mx+0.5,my+0.5,math.random(-100,100)/1000,math.random(-100,-140)/1000,loaded_chunks[selected_chunkx][selected_chunky][mx][my]["block"])
|
entity.create_entity("item",0.4,0.4,nil,selected_chunkx,selected_chunky,mx+0.5,my+0.5,math.random(-100,100)/1000,math.random(-100,-140)/1000,loaded_chunks[selected_chunkx][selected_chunky][mx][my]["block"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user