Git Product home page Git Product logo

Comments (12)

zhongfly avatar zhongfly commented on June 15, 2024

我觉得也是彻底解决#11 之类问题的方法
虽然会使得键位绑定的设置分散

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

zhongfly@916f7ca

先改了一个简单的,获取mpv当前的绑定,覆盖外部配置文件的click。
可以自定义配置文件地址,外部配置的语法和现在的input.conf完全一致

from input-event.

hooke007 avatar hooke007 commented on June 15, 2024

我不理解为什么要把函数局部化。。。

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

我不理解为什么要把函数局部化。。。

1,局部变量访问更快
2,没有坏处

from input-event.

hooke007 avatar hooke007 commented on June 15, 2024

访问更快是否有验证依据。如果更快mpv内最复杂的osc脚本没理由不使用

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

访问更快是否有验证依据。如果更快mpv内最复杂的osc脚本没理由不使用

这是lua语言自身的特性,https://stackoverflow.com/questions/9132288/why-are-local-variables-accessed-faster-than-global-variables-in-lua

from input-event.

hooke007 avatar hooke007 commented on June 15, 2024

..这并没有解释我的疑问
假设成立,为什么还有遗漏的函数并没有统一为局部

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

..这并没有解释我的疑问 假设成立,为什么还有遗漏的函数并没有统一为局部

xx:xx这种函数担心改了会出问题,也懒得查文档,所以懒得改

from input-event.

hooke007 avatar hooke007 commented on June 15, 2024

按照网上的做了测试,用了局部的话最好还是全部统一局部

-- 无报错
local function test()
    test1()
    test2()
end
function test1()
    print("test1")
end
function test2()
    print("test2")
end
test()
-- 报错
local function test()
    test1()
    test2()
end
function test1()
    print("test1")
end
local function test2()
    print("test2")
end
test()

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

按照网上的做了测试,用了局部的话最好还是全部统一局部

https://www.lua.org/pil/6.2.html
主要还是变量应该先定义后使用吧,这个脚本里都是先定义,后使用的,所以不会报错

以下不会报错

function test1()
    print("test1")
end
local function test2()
    print("test2")
end
local function test()
    test1()
    test2()
end
test()

from input-event.

hooke007 avatar hooke007 commented on June 15, 2024

先声明肯定是不报错啦,这也算是发现一个特性了

from input-event.

zhongfly avatar zhongfly commented on June 15, 2024

..这并没有解释我的疑问 假设成立,为什么还有遗漏的函数并没有统一为局部

xx:xx这种函数担心改了会出问题,也懒得查文档,所以懒得改

补充说明,object:method这种形式的函数,实际上是给object添加函数方法,如果定义为local,则只能在对象内部进行调用,即私有方法,不可以在外部通过object:method()来运行。

https://www.lua.org/pil/16.4.html 说的不太清楚

脚本里的此类函数,分为2类:
1、给lua自带类型增加的方法,都是要在对象外部调用的,不能加local
2、InputEvent对象的方法,有部分方法是被外部调用,new bind unbind rebind,不可被私有化;其余的可以私有化。

要改也可以改

from input-event.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.