带有方法的表格,如何处理/检查它们? [英] Table with methods, how to handle/inspect them?

查看:81
本文介绍了带有方法的表格,如何处理/检查它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,没有上下文,我有一个返回表的方法. 尝试将其打印出来,该表似乎主要包含要调用的方法. 但是,由于对LUA的了解不是很广,我不知道如何正确获取有关应该调用的这些方法的一些信息.

So without the context, I have a method that returns a table. Trying to print it out, it seems that the table mainly contains methods to be called. However not being very knowledgeable in LUA, i have no idea how to properly get some information about these methods i should call.

我试图从事物的创建者那里获取文档,但是据我所知没有.而且由于这是在computercraft(minecraft mod)内部,所以我没有很多功能可以依靠.

I tried to get documentation from the creator of the thing, but there is none as far as i know. And since this is inside computercraft (minecraft mod) i don't have a lot of features to rely on either.

因此仅知道这是一个包含我可以调用的方法的表,如何正确确定如何调用它们以及使用哪些参数等?

So knowing only that it is a table with methods that i can call, how do i properly figure out how to call them, and with what parameters etc. ?

推荐答案

通常来说,模块/库总是随文档一起提供,或者是一种打印文档的方法.

Generally speaking, modules/ libraries always come with docs, or a method to print the docs.

但是,如果不是这种情况,您可以执行以下操作:

But if this is not the case, here's what you can do:

  • 您可以在表格中打印所有内容!这是必须的,方法的名称可能非常有用
  • 您可以寻求帮助!查找使用相同模块的人员,并询问他们如何工作.为什么要解决别人已经已经弄清的事情?
  • debug.getinfo和其他hacky函数用于调试库!与Lua标准库中的其他内容相比,它们可以提供更多信息
  • C端编码可以揭示Lua无法做到的!如果您有权使用C端,则可以完全看到代码在做什么(或者至少我认为是这样)
  • 查看源代码!这将向您显示代码的作用以及它的作用方式
  • 最重要的是,进行实验!在不同的参数,不同的值上尝试这些方法,并确定通过连续测试执行的操作!
  • You can print everything in the table! This is a must, the names of the methods can be very useful
  • You can seek out help! Find people who have used the same module, and ask them how it works. Why solve something others have already figured out?
  • Use debug.getinfo and other hacky functions for the debug library! They can provide more info than anything else in the Lua standard libraries!
  • C-Side coding can reveal what Lua cannot! If you have access to the C-Side you can see exactly what the code is doing (or at least I think so)
  • Check out the source code! This shows you what the code does and how it does it
  • And above all else, experiment! Try the methods on different parameters, different values, and identify what it does through continuous testing!

这篇关于带有方法的表格,如何处理/检查它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆