love2d访问另外一个文件的自定义变量和自定义函数

test.lua

Lua 复制代码
local module = {}
module.myString = "Hello from test.lua!"
function module.sayHello()
    return "hello world"
end
return module

main.lua

Lua 复制代码
local testModule = require "test"
function love.load()
    
   -- txt = parser.read_file("init.txt")
end

function love.draw()
    love.graphics.print(testModule.myString,200,200)
    love.graphics.print(testModule.sayHello(),200,500)

效果

相关推荐
yuanmenghao17 小时前
从零开始:使用 Claude Code 打造字母消除游戏
游戏·glm·claudecode
阿甘编程点滴1 天前
2026年推荐以下5款游戏直播提词器
游戏
PieroPc1 天前
HTML5 Canvas 平台跳跃游戏
前端·游戏·html5
weixin_424294671 天前
Unity 使用Steamworks.NET
unity·游戏引擎
ellis19701 天前
Unity资源管理框架Addressables总结
unity·游戏引擎
Swift社区1 天前
LeetCode 390 消除游戏 - Swift 题解
leetcode·游戏·swift
技术策划Boring1 天前
2025年工作复盘:开放世界3A项目配置管线与性能监控的探索
游戏·ue5·虚幻·p4·perforce
郭逍遥1 天前
[Godot] 通过AABB包围盒和射线法检测碰撞
算法·游戏引擎·godot
风痕天际1 天前
Godot扫雷游戏制作记录4——计算周围地雷数并显示
游戏·游戏引擎·godot
安全不再安全1 天前
某驱动任意读漏洞分析 - 可用于游戏内存数据读取
c语言·测试工具·安全·游戏·网络安全