[英]Syntax error: player.lua:11: '=' expected near '<eof>'
我最近一直在用Love2d學習Lua,所以我決定開始制作一個簡單的RPG。 這很簡單。 在控制台上可以玩游戲,在額外的窗口中可以看到統計信息,裝備項目等。 但是,我遇到了問題! 每當我運行代碼時,我都會看到這個main.lua:15: '=' expected near 'else'
我將在下面包括代碼(所有3個文件)。 這是main.lua
function love.load()
love.graphics.setBackgroundColor( 255, 255, 255 )
require("player")
print("Enter your name")
pcStats.Name = io.read()
print("What class are you, " .. pcStats.Name .. "?")
pcStats.Class = io.read()
if pcStats.Class == "Ranger" then
os.execute("cls")
pcInv.InvSpace = 10
pcInv.Items.basicBow = Basic Bow
else
print("Error: Invalid Class. Please restart game")
end
print("What would you like to do? CODE END")
input = io.read()
end
function love.draw()
love.graphics.setColor( 0, 0, 0 )
love.graphics.print( "Level: " .. pcStats.Level, 1, 1 )
love.graphics.print( "Inv Space: " .. pcInv.InvSpace, 1, 20 )
love.graphics.print( "Inv: " .. pcInv.Items, 1, 40 )
end
這是player.lua,這是游戲變量的存儲位置
pcStats = {}
pcStats.Level = 1
pcStats.XP = nil
pcStats.Name = nil
pcStats.Class = nil
pcStats.Atk = nil
pcStats.Def = nil
pcInv = {}
pcInv.InvSpace = nil
pcInv.Items.testsword = testing sword
最后但並非最不重要的是,這是用於love2d的conf.lua
function love.conf(t)
t.modules.joystick = true
t.modules.audio = true
t.modules.keyboard = true
t.modules.event = true
t.modules.image = true
t.modules.graphics = true
t.modules.timer = true
t.modules.mouse = true
t.modules.sound = true
t.modules.thread = true
t.modules.physics = true
t.console = true
t.title = "Lua RPG Alpha v0.0.1"
t.author = "Zach Herzer"
end
第15行是這樣的:
pcInv.Items.basicBow = Basic Bow
Basic Bow
不是有效的Lua代碼。 我很確定你是在說別的東西-也許是字符串?
pcInv.Items.basicBow = "Basic Bow"
當我們在這時,
pcInv.Items.testsword = testing sword
有類似的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.