add module 'base:util' & fix attack
This commit is contained in:
parent
f095edda7a
commit
bc17abc8b3
10
res/content/base/modules/util.lua
Normal file
10
res/content/base/modules/util.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
local base_entities = {}
|
||||||
|
|
||||||
|
function base_entities.drop(ppos, itemid, count)
|
||||||
|
return entities.spawn("base:drop", ppos, {base__drop={
|
||||||
|
id=itemid,
|
||||||
|
count=count
|
||||||
|
}})
|
||||||
|
end
|
||||||
|
|
||||||
|
return base_entities
|
||||||
@ -1,3 +1,5 @@
|
|||||||
|
local base_util = require "util"
|
||||||
|
|
||||||
local DROP_FORCE = 8
|
local DROP_FORCE = 8
|
||||||
local DROP_INIT_VEL = {0, 3, 0}
|
local DROP_INIT_VEL = {0, 3, 0}
|
||||||
|
|
||||||
@ -17,10 +19,7 @@ function on_hud_open()
|
|||||||
local pvel = {player.get_vel(pid)}
|
local pvel = {player.get_vel(pid)}
|
||||||
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
|
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
|
||||||
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
|
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
|
||||||
local drop = entities.spawn("base:drop", ppos, {base__drop={
|
local drop = base_util.drop(ppos, itemid, 1)
|
||||||
id=itemid,
|
|
||||||
count=1
|
|
||||||
}})
|
|
||||||
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
|
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
|
||||||
drop.rigidbody:set_vel(velocity)
|
drop.rigidbody:set_vel(velocity)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -509,8 +509,7 @@ void PlayerController::updateInteraction(float delta) {
|
|||||||
bool longInteraction = interactionTimer <= 0 || xkey;
|
bool longInteraction = interactionTimer <= 0 || xkey;
|
||||||
bool lclick = Events::jactive(BIND_PLAYER_DESTROY) ||
|
bool lclick = Events::jactive(BIND_PLAYER_DESTROY) ||
|
||||||
(longInteraction && Events::active(BIND_PLAYER_DESTROY));
|
(longInteraction && Events::active(BIND_PLAYER_DESTROY));
|
||||||
bool lattack = Events::jactive(BIND_PLAYER_ATTACK) ||
|
bool lattack = Events::jactive(BIND_PLAYER_ATTACK);
|
||||||
(longInteraction && Events::active(BIND_PLAYER_ATTACK));
|
|
||||||
bool rclick = Events::jactive(BIND_PLAYER_BUILD) ||
|
bool rclick = Events::jactive(BIND_PLAYER_BUILD) ||
|
||||||
(longInteraction && Events::active(BIND_PLAYER_BUILD));
|
(longInteraction && Events::active(BIND_PLAYER_BUILD));
|
||||||
if (lclick || rclick) {
|
if (lclick || rclick) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user