在Lua中仅提交一次 [英] Do file only once in Lua

查看:113
本文介绍了在Lua中仅提交一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法只做一次lua文件,而以后再尝试做一次lua文件都将导致无操作.

I was wondering if there's a way to do a lua file only once and have any subsequent attempts to do that lua file will result in a no-op.

我已经考虑过要做一些类似于C ++标头的#if/else/endif技巧.我想知道是否有一种标准的方法来实现这一点.

I've already thought about doing something akin to C++ header's #if/else/endif trick. I'm wondering if there's a standard way to implement this.

詹姆斯

推荐答案

好吧,require确实做到了.

require "file" -- runs "file.lua"
require "file" -- does not run the "file" again

这篇关于在Lua中仅提交一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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