mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-01-24 09:00:21 +01:00
Add three settings
throwing.velocity_factor, throwing.horizontal_acceleration_factor, throwing.vertical_acceleration
This commit is contained in:
parent
af35502e61
commit
318bf9e23c
@ -6,7 +6,7 @@ This mod is a new rewrite of the original throwing mod by PilzAdam. Compatible r
|
||||
|
||||
## Configuration
|
||||
|
||||
The settings are the following (they all default to true):
|
||||
The settings are the following:
|
||||
```
|
||||
throwing.enable_arrow = true
|
||||
throwing.enable_golden_arrow = true
|
||||
@ -15,6 +15,10 @@ throwing.enable_teleport_arrow = true
|
||||
throwing.enable_dig_arrow = true
|
||||
throwing.enable_dig_arrow_admin = true
|
||||
throwing.enable_build_arrow = true
|
||||
|
||||
throwing.velocity_factor = 19
|
||||
throwing.horizontal_acceleration_factor = -3
|
||||
throwing.vertical_acceleration = -10
|
||||
```
|
||||
|
||||
## API
|
||||
|
9
init.lua
9
init.lua
@ -14,8 +14,13 @@ local function shoot_arrow(itemstack, player)
|
||||
local playerpos = player:getpos()
|
||||
local obj = minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, arrow.."_entity")
|
||||
local dir = player:get_look_dir()
|
||||
obj:setvelocity({x=dir.x*19, y=dir.y*19, z=dir.z*19})
|
||||
obj:setacceleration({x=dir.x*-3, y=-10, z=dir.z*-3})
|
||||
|
||||
local velocity_factor = tonumber(minetest.setting_get("throwing.velocity_factor")) or 19
|
||||
local horizontal_acceleration_factor = tonumber(minetest.setting_get("throwing.horizontal_acceleration_factor")) or -3
|
||||
local vertical_acceleration = tonumber(minetest.setting_get("throwing.vertical_acceleration")) or -10
|
||||
|
||||
obj:setvelocity({x=dir.x*velocity_factor, y=dir.y*velocity_factor, z=dir.z*velocity_factor})
|
||||
obj:setacceleration({x=dir.x*horizontal_acceleration_factor, y=vertical_acceleration, z=dir.z*horizontal_acceleration_factor})
|
||||
obj:setyaw(player:get_look_horizontal()-math.pi/2)
|
||||
minetest.sound_play("throwing_sound", {pos=playerpos, gain = 0.5})
|
||||
obj:get_luaentity().player = player:get_player_name()
|
||||
|
Loading…
Reference in New Issue
Block a user