Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 比较多个整数_Variables_If Statement_Lua - Fatal编程技术网

Variables 比较多个整数

Variables 比较多个整数,variables,if-statement,lua,Variables,If Statement,Lua,我想比较n1-10,其中一个是=box 然后写nx1和ny1等等。。。 我该怎么做才能更快地比较它们呢。 下面这条路需要我几年的时间 box=readString('[[[[[_name]+11c]+670]+394]+2fc]+1c',20) n1=readString('[_player]+184',20) n2=readString('[_player]+f94',20) n3=readString('[_player]+1da4',20) nx1= re

我想比较n1-10,其中一个是=box 然后写nx1和ny1等等。。。 我该怎么做才能更快地比较它们呢。 下面这条路需要我几年的时间

 box=readString('[[[[[_name]+11c]+670]+394]+2fc]+1c',20)
    n1=readString('[_player]+184',20)
    n2=readString('[_player]+f94',20)
    n3=readString('[_player]+1da4',20)
    nx1= readInteger('[_player]+48d8')
    nx2= readInteger('[_player]+56e8')
    nx3= readInteger('[_player]+64f8')

    ny1= readInteger('[_player]+48dc')
    ny2= readInteger('[_player]+56ec')
    ny3= readInteger('[_player]+64fc')

    if box =n1 or n2 or n3   --lets say n1=box  
    then    writeInteger('[_player]+28c',n1x) 
            writeInteger('[_player]+28c',n1y) 

    if box =n1 or n2 or n3   --lets say n2=box  
    then    writeInteger('[_player]+28c',n2x) 
            writeInteger('[_player]+28c',n2y) 

你在这里练习得不好。最好将这些变量存储到数组中,如

ns[1] = ...
ns[2] = ...
...
nys[1] = ...
nys[2] = ...
然后

   key = -1
   for k,v in na do
     if box == v then
        key = k
     end
   end

   if key == -1 then
      print("no match values")
   else
      writeInteger('[_player]+28c',nys[key]) 
       writeInteger('[_player]+28c',nys[key])
   end