选择英雄和编程语言
选择装备
写中文注释
写代码# 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)
运行
写代码// 某些硬币和宝石吸引闪电。// 这个英雄应只收集银币和蓝宝石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); }}
运行
写代码# 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)
运行
写代码-- 某些硬币和宝石吸引闪电。-- 这个英雄应只收集银币和蓝宝石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) endend
运行