update std rules & add player.destroy binding
This commit is contained in:
parent
df2f24d94e
commit
d27179b6c3
@ -21,6 +21,7 @@
|
|||||||
- [pack](scripting/builtins/libpack.md)
|
- [pack](scripting/builtins/libpack.md)
|
||||||
- [player](scripting/builtins/libplayer.md)
|
- [player](scripting/builtins/libplayer.md)
|
||||||
- [quat](scripting/builtins/libquat.md)
|
- [quat](scripting/builtins/libquat.md)
|
||||||
|
- [rules](scripting/builtins/librules.md)
|
||||||
- [time](scripting/builtins/libtime.md)
|
- [time](scripting/builtins/libtime.md)
|
||||||
- [utf8](scripting/builtins/libutf8.md)
|
- [utf8](scripting/builtins/libutf8.md)
|
||||||
- [vec2, vec3, vec4](scripting/builtins/libvecn.md)
|
- [vec2, vec3, vec4](scripting/builtins/libvecn.md)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ camera.mode="key:f4"
|
|||||||
player.noclip="key:n"
|
player.noclip="key:n"
|
||||||
player.flight="key:f"
|
player.flight="key:f"
|
||||||
player.attack="mouse:left"
|
player.attack="mouse:left"
|
||||||
|
player.destroy="mouse:left"
|
||||||
player.build="mouse:right"
|
player.build="mouse:right"
|
||||||
player.pick="mouse:middle"
|
player.pick="mouse:middle"
|
||||||
player.drop="key:q"
|
player.drop="key:q"
|
||||||
|
|||||||
@ -61,7 +61,7 @@ function submit(text)
|
|||||||
if name == nil then
|
if name == nil then
|
||||||
name = text
|
name = text
|
||||||
end
|
end
|
||||||
if not rules.get("cheat-commands") and table.has(console.cheats, name) then
|
if not rules.get("allow-cheats") and table.has(console.cheats, name) then
|
||||||
console.log("cheat commands are disabled")
|
console.log("cheat commands are disabled")
|
||||||
document.prompt.text = ""
|
document.prompt.text = ""
|
||||||
document.prompt.focused = true
|
document.prompt.focused = true
|
||||||
|
|||||||
@ -33,7 +33,7 @@ console.add_command(
|
|||||||
local str = "Available commands:"
|
local str = "Available commands:"
|
||||||
|
|
||||||
for i,k in ipairs(commands) do
|
for i,k in ipairs(commands) do
|
||||||
if rules.get("cheat-commands") or not table.has(console.cheats, k) then
|
if rules.get("allow-cheats") or not table.has(console.cheats, k) then
|
||||||
str = str .. "\n " .. build_scheme(console.get_command_info(k))
|
str = str .. "\n " .. build_scheme(console.get_command_info(k))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -229,7 +229,10 @@ function _rules.create(name, value, handler)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function _rules.unlisten(name, id)
|
function _rules.unlisten(name, id)
|
||||||
local rule = _rules.get_rule(name)
|
local rule = _rules.rules[name]
|
||||||
|
if rule == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
rule.listeners[utf8.encode(id)] = nil
|
rule.listeners[utf8.encode(id)] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,7 +240,7 @@ function _rules.clear()
|
|||||||
_rules.rules = {}
|
_rules.rules = {}
|
||||||
_rules.nextid = 1
|
_rules.nextid = 1
|
||||||
|
|
||||||
_rules.create("cheat-commands", true)
|
_rules.create("allow-cheats", true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function __vc_create_hud_rules()
|
function __vc_create_hud_rules()
|
||||||
@ -250,9 +253,12 @@ function __vc_create_hud_rules()
|
|||||||
_rules.create("allow-noclip", true, function(value)
|
_rules.create("allow-noclip", true, function(value)
|
||||||
input.set_enabled("player.noclip", value)
|
input.set_enabled("player.noclip", value)
|
||||||
end)
|
end)
|
||||||
_rules.create("allow-destruct", true, function(value)
|
_rules.create("allow-attack", true, function(value)
|
||||||
input.set_enabled("player.attack", value)
|
input.set_enabled("player.attack", value)
|
||||||
end)
|
end)
|
||||||
|
_rules.create("allow-destroy", true, function(value)
|
||||||
|
input.set_enabled("player.destroy", value)
|
||||||
|
end)
|
||||||
_rules.create("allow-cheat-movement", true, function(value)
|
_rules.create("allow-cheat-movement", true, function(value)
|
||||||
input.set_enabled("movement.cheat", value)
|
input.set_enabled("movement.cheat", value)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -29,7 +29,8 @@ movement.crouch=Crouch
|
|||||||
movement.cheat=Cheat
|
movement.cheat=Cheat
|
||||||
hud.inventory=Inventory
|
hud.inventory=Inventory
|
||||||
player.pick=Pick Block
|
player.pick=Pick Block
|
||||||
player.attack=Attack / Break
|
player.attack=Attack
|
||||||
|
player.destroy=Destroy
|
||||||
player.build=Place Block
|
player.build=Place Block
|
||||||
player.fast_interaction=Accelerated interaction
|
player.fast_interaction=Accelerated interaction
|
||||||
player.flight=Flight
|
player.flight=Flight
|
||||||
|
|||||||
@ -91,7 +91,8 @@ movement.crouch=Красться
|
|||||||
movement.cheat=Чит
|
movement.cheat=Чит
|
||||||
hud.inventory=Инвентарь
|
hud.inventory=Инвентарь
|
||||||
player.pick=Подобрать Блок
|
player.pick=Подобрать Блок
|
||||||
player.attack=Атаковать / Сломать
|
player.attack=Атаковать
|
||||||
|
player.destroy=Сломать
|
||||||
player.build=Поставить Блок
|
player.build=Поставить Блок
|
||||||
player.fast_interaction=Ускоренное взаимодействие
|
player.fast_interaction=Ускоренное взаимодействие
|
||||||
player.flight=Полёт
|
player.flight=Полёт
|
||||||
|
|||||||
@ -25,6 +25,7 @@ inline const std::string BIND_CAM_MODE = "camera.mode";
|
|||||||
inline const std::string BIND_PLAYER_NOCLIP = "player.noclip";
|
inline const std::string BIND_PLAYER_NOCLIP = "player.noclip";
|
||||||
inline const std::string BIND_PLAYER_FLIGHT = "player.flight";
|
inline const std::string BIND_PLAYER_FLIGHT = "player.flight";
|
||||||
inline const std::string BIND_PLAYER_ATTACK = "player.attack";
|
inline const std::string BIND_PLAYER_ATTACK = "player.attack";
|
||||||
|
inline const std::string BIND_PLAYER_DESTROY = "player.destroy";
|
||||||
inline const std::string BIND_PLAYER_BUILD = "player.build";
|
inline const std::string BIND_PLAYER_BUILD = "player.build";
|
||||||
inline const std::string BIND_PLAYER_PICK = "player.pick";
|
inline const std::string BIND_PLAYER_PICK = "player.pick";
|
||||||
inline const std::string BIND_PLAYER_FAST_INTERACTOIN =
|
inline const std::string BIND_PLAYER_FAST_INTERACTOIN =
|
||||||
|
|||||||
@ -494,7 +494,9 @@ void PlayerController::updateInteraction(float delta) {
|
|||||||
bool xkey = Events::active(BIND_PLAYER_FAST_INTERACTOIN);
|
bool xkey = Events::active(BIND_PLAYER_FAST_INTERACTOIN);
|
||||||
float maxDistance = xkey ? 200.0f : 10.0f;
|
float maxDistance = xkey ? 200.0f : 10.0f;
|
||||||
bool longInteraction = interactionTimer <= 0 || xkey;
|
bool longInteraction = interactionTimer <= 0 || xkey;
|
||||||
bool lclick = Events::jactive(BIND_PLAYER_ATTACK) ||
|
bool lclick = Events::jactive(BIND_PLAYER_DESTROY) ||
|
||||||
|
(longInteraction && Events::active(BIND_PLAYER_DESTROY));
|
||||||
|
bool lattack = Events::jactive(BIND_PLAYER_ATTACK) ||
|
||||||
(longInteraction && Events::active(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));
|
||||||
@ -512,7 +514,7 @@ void PlayerController::updateInteraction(float delta) {
|
|||||||
scripting::on_item_use(player.get(), item);
|
scripting::on_item_use(player.get(), item);
|
||||||
}
|
}
|
||||||
if (selection.entity) {
|
if (selection.entity) {
|
||||||
updateEntityInteraction(selection.entity, lclick, rclick);
|
updateEntityInteraction(selection.entity, lattack, rclick);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user