在实时代码中修复我的数学游戏中的大于号和小于号

fixing the greater and less than signs in my math game in livecode

我使用两个变量,每个变量的随机数为 1-10,我希望用户单击我在其中使用工具提示的 <= 或 >= 符号图片。所有代码都写在卡片的脚本中,方法在需要的按钮或字段中调用。我也附上了我的应用程序界面的图片。谢谢

这是我的代码 有人可以帮忙找出问题所在吗?谢谢

 local _leftNumberValue 
local _rightNumberValue
local _correctAnswer
local _userAnswerValue
local _userScore
local _numberOfQuestions
on openCard
   PreparingQuestion
end openCard

on PreparingQuestion
   put random(10) into _leftNumberValue 
   put _leftNumberValue  into field "leftNumber"
   put random  (10)  into _rightNumberValue
   put _rightNumberValue  into field "rightNumber" 
   if  _leftNumberValue >=  _rightNumberValue
   then
      put _leftNumberValue  into _correctAnswer
      add 1 to _numberOfQuestions
      put _numberOfQuestions into field "numberOfQuestions"
   end if 
end PreparingQuestion

on CheckUsersAnswer
   put field "userAnswer" into _userAnswerValue
   if _userAnswerValue = _correctAnswer
   then
      if _userScore < 4
      then  
         AddPointsToPlayer
         PreparingQuestion
      else 
         answer "Great Job :) You can move on  to the next level"
      end if 
   end if 
   put empty into field "userAnswer"
end CheckUsersAnswer

on AddPointsToPlayer
   add 1 to _userScore
   put _userScore into field "scoreBoard"
end AddPointsToPlayer

on StartOver 
   put empty into field "numberOfQuestions"
   put 0 into _userScore
   put 0 into _numberOfQuestions
   put _numberOfQuestions into field "numberOfQuestions"
   put _userScore into field  "scoreBoard"
end StartOver

我觉得你需要解释一下游戏的玩法和要点。 我尝试根据描述和代码尽我所能重新创建您的堆栈,它似乎工作正常,但我不确定我是否完全理解应该发生什么或哪里出错了。

一分;您的 CheckUsersAnswer 处理程序仅检查正确答案,如果答案错误应该怎么办?

更新:

修改处理程序…

on PreparingQuestion
   put random(10) into _leftNumberValue 
   put _leftNumberValue  into field "leftNumber"
   put random  (10)  into _rightNumberValue
   put _rightNumberValue  into field "rightNumber" 
   
   ## CHANGED: Determine the correct answer…
   if _leftNumberValue > _rightNumberValue then put ">" into _correctAnswer
   if _leftNumberValue < _rightNumberValue then put "<" into _correctAnswer
   if _leftNumberValue = _rightNumberValue then put "=" into _correctAnswer
   
   add 1 to _numberOfQuestions
   put _numberOfQuestions into field "numberOfQuestions"
end PreparingQuestion

on CheckUsersAnswer
   put field "userAnswer" into _userAnswerValue
   if _userAnswerValue = _correctAnswer then
      if _userScore < 4 then  
         AddPointsToPlayer
         PreparingQuestion
      else 
         answer "Great Job :) You can move on  to the next level"
      end if
      
      ## ADDED: Message for user to try again…
   else
      answer "Wrong answer. Please try again."
   end if 
   put empty into field "userAnswer"
end CheckUsersAnswer