极客战记-春雷
1、选择英雄和编程语言

2、选择装备

3、写中文注释

1、写代码
# Certain coins and gems attract lightning.
# 这个英雄应只收集银币和蓝宝石
while True:
item = hero.findNearestItem()
# A silver coin has a value of 2.
# Collect if item.type is equal to "coin"
# AND item.value 相等于2
if item.type == "coin" and item.value == 2:
hero.moveXY(item.pos.x, item.pos.y)
# 一个蓝宝石价值10
# Collect if item.type is equal to "gem"
# AND item.value is equal to 10.
if item.type == "gem" and item.value == 10:
hero.moveXY(item.pos.x, item.pos.y)

2、运行

1、写代码
// 某些硬币和宝石吸引闪电。
// 这个英雄应只收集银币和蓝宝石
while (true) {
var item = hero.findNearestItem();
// 一枚银币的价值为2。
// 如果item.type等于“coin”,则收集
// AND item.value 相等于2
if (item.type == "coin" && item.value == 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
// 一个蓝宝石价值10
// 如果item.type等于“gem”,则收集
// AND item.value等于10。
if (item.type == "gem" && item.value == 10) {
hero.moveXY(item.pos.x, item.pos.y);
}}

2、运行

1、写代码
# Certain coins and gems attract lightning.
# 这个英雄应只收集银币和蓝宝石
while true
item = hero.findNearestItem()
# A silver coin has a value of 2.
# Collect if item.type is equal to "coin"
# AND item.value 相等于2
if item.type == "coin" and item.value == 2
hero.moveXY(item.pos.x, item.pos.y)
# 一个蓝宝石价值10
# Collect if item.type is equal to "gem"
# AND item.value is equal to 10.
if item.type == "gem" and item.value == 10
hero.moveXY(item.pos.x, item.pos.y)

2、运行

1、写代码
-- 某些硬币和宝石吸引闪电。
-- 这个英雄应只收集银币和蓝宝石
while true do
local item = hero:findNearestItem()
-- 一枚银币的价值为2。
-- 如果item.type等于“coin”,则收集
-- AND item.value 相等于2
if (item.type == "coin" and item.value == 2) then
hero:moveXY(item.pos.x, item.pos.y)
end
-- 一个蓝宝石价值10
-- 如果item.type等于“gem”,则收集
-- AND item.value等于10。
if (item.type == "gem" and item.value == 10) then
hero:moveXY(item.pos.x, item.pos.y)
end
end

2、运行
