Skip to content

Instantly share code, notes, and snippets.

@dipsywong98
Created October 27, 2018 16:00
Show Gist options
  • Save dipsywong98/67e4efb441f5e795472e44c1ad9c2200 to your computer and use it in GitHub Desktop.
Save dipsywong98/67e4efb441f5e795472e44c1ad9c2200 to your computer and use it in GitHub Desktop.
路亞闖關(BETA)的答案
--play at http://tw.gamelet.com/mission.do?code=csArena&gltParam=%7B%27mode%27%3A%27userMission%27%2C+%27id%27%3A%27270136%27%7D
--請不要更改第1至第1行的程式碼
require "sys.game"
if level == nil then
--請在此初始化你的程式
elseif level == 1 then
--第一關目標:說出 hello world
--請在此寫下第一關的程式
me.talk("hello world")
elseif level == 2 then
--第二關目標:說出a值和b值的和
--提示:a和b都是隨機數, a值和b值的已在a和b中
--以下在路亞思路印出a值和b值
game.logState("a",a)
game.logState("b",b)
--請在此寫下第二關的程式
me.talk(a+b)
elseif level == 3 then
--第三關目標:說出"a*b=答案"
--提示:a和b都是隨機數\n如果a是3,b是7,說出 「a*b=21」
--請在此寫下第三關的程式
me.talk("a*b="..a*b)
elseif level == 4 then
--第四關目標:如果a大於b,說YEAH;否則說OH
--請在此寫下第四關的程式
if a > b then
me.talk("YEAH")
else
me.talk("OH")
end
elseif level == 5 then
--第五關目標:說一次「hi」,1秒後再說一次「bye」,有效範圍0.5秒
--提示:game.now
if t_5 == nil then
me.talk("hi")
t_5 = game.now + 1000
elseif t_5 < game.now then
me.talk("bye")
end
end
--請不要更改下面的程式碼
friends = game.findVisibleFriends()
for _,friend in pairs(friends) do
if friend.info.id == "level" then
level = friend.hp
elseif friend.info.id == "input1" then
a = friend.hp
elseif friend.info.id == "input2" then
b = friend.hp
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment