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)

效果

相关推荐
2401_841495644 小时前
Python适合开发的游戏
python·游戏·pygame·tkinter·panda3d·arcade·ursina
Sui_Network5 小时前
智能体支付时代:Sui 为 AI 构建可验证的金融基础设施
大数据·人工智能·游戏·金融·rpc·区块链·量子计算
三和尚7 小时前
AI开发之Cursor的下载安装以及Unity-MCP下载安装到你的个人Unity项目中(一)
unity·ai·游戏引擎·cursor·unity-mcp·unity自动化
2401_841495647 小时前
【游戏开发】登山赛车
数据结构·python·游戏·游戏开发·pygame·登山赛车游戏·游戏打包发布
YGGP7 小时前
【Golang】LeetCode 45. 跳跃游戏 II
算法·leetcode·游戏
DaLiangChen8 小时前
Unity 导览相机实现:键鼠控制自由漫游(WASD 移动 + 右键旋转)
数码相机·unity·游戏引擎
练习时长一年10 小时前
Leetcode热题100(跳跃游戏 II)
算法·leetcode·游戏
今夕资源网1 天前
.sav游戏存档在线编辑器 .sav文件存档转json文件 html源码
游戏·游戏存档编辑器·sav游戏存档在线编辑器·游戏存档在线编辑器·sav游戏存档在线编辑·sav游戏存档编辑·游戏存档修改
沉默金鱼1 天前
Unity实用技能-UI进度条
ui·unity·游戏引擎
我无止境1 天前
和平精英模拟器进入对局卡成PPT怎么办?(可能解决黑屏问题)
游戏