赞 | 40 |
VIP | 0 |
好人卡 | 72 |
积分 | 63 |
经验 | 38967 |
最后登录 | 2024-11-5 |
在线时间 | 1481 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6260
- 在线时间
- 1481 小时
- 注册时间
- 2015-7-25
- 帖子
- 652
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
是这样的,今天闲着无聊自己写了一个功能类似于计算器的小脚本(四则运算,支持先乘除后加减),
那么呢,使用方法如下图
变量51,53,55,57分别代入4个数,变量52,54,56分别代入3个符号。
然后,执行写好的方法,结果代入在100号变量里,最后在事件里输出数值。
那么呢,现在的问题是,确实是经过了计算但是计算结果却不对。
然后呢,我检查过算法了但是并未发现有什么地方不对,希望大家能来帮忙看一下谢谢=w=
下面是脚本
- module MFXRB
- AA = 1
- A = 1
- BB = 2
- B = 2
- CC = 3
- C = 3
- DD = 4
- D = 4
- EE = 5
- E = 5
- FF = 6
- F = 6
- GG = 7
- G = 7
- HH = 8
- H = 8
- II = 9
- I = 9
- JJ = 10
- J = 10
- KK = 11
- K = 11
- LL = 12
- L = 12
- ZH = 100
- def add(x,y)
- x+y
- end
- def jian(x,y)
- x-y
- end
- def cheng(x,y)
- x*y
- end
- def chu(x,y)
- x/y
- end
- def jisuan
- a = $game_variables[51]
- b = $game_variables[52]#
- c = $game_variables[53]
- d = $game_variables[54]#
- e = $game_variables[55]
- f = $game_variables[56]#
- g = $game_variables[57]
- s = [a,b,c,d,e,f,g]
- if s[1] == "/"
- $game_variables[AA] = chu(a,c)
- $game_switches[A] = true
- end
- if s[3] == "/"
- if $game_switches[A] = true
- $game_variables[BB] = chu($game_variables[AA],e)
- $game_switches[B] = true
- else
- $game_variables[BB] = chu(c,e)
- $game_switches[B] = true
- end
- end
- if s[5] == "/"
- if $game_switches[B] = true#chu
- $game_variables[CC] = chu($game_variables[BB],g)
- $game_switches[C] = true
- else
- $game_variables[CC] = chu(e,g)
- $game_switches[C] = true
- end
- end
- if s[1] == "*"
- if $game_switches[B] = true#chu
- $game_variables[DD] = cheng(a,$game_variables[BB])
- $game_switches[D] = true
- else
- $game_variables[DD] = cheng(a,c)
- $game_switches[D] = true
- end
- end
- if s[3] == "*"
- if $game_switches[A] = true && $game_switches[C] = true#chu,chu
- $game_variables[EE] = cheng($game_variables[AA],$game_variables[CC])
- $game_switches[E] = true
- elsif $game_switches[D] = true && $game_switches[C] = true#cheng,chu
- $game_variables[EE] = cheng($game_variables[DD],$game_variables[CC])
- $game_switches[E] = true
- elsif $game_switches[D] = true#cheng
- $game_variables[EE] = cheng($game_variables[DD],e)
- $game_switches[E] = true
- elsif $game_switches[C] = true#chu
- $game_variables[EE] = cheng(c,$game_variables[CC])
- $game_switches[E] = true
- else
- $game_variables[EE] = cheng(c,e)
- $game_switches[E] = true
- end
- end
- if s[5] == "*"
- if $game_switches[B] = true#chu
- $game_variables[FF] = cheng($game_variables[BB],g)
- $game_switches[F] = true
- elsif $game_switches[E] = true#cheng
- $game_variables[FF] = cheng($game_variables[EE],g)
- $game_switches[F] = true
- else
- $game_variables[FF] = cheng(e,g)
- $game_switches[F] = true
- end
- end
- if s[1] == "-"
- if $game_switches[B] = true#chu
- $game_variables[GG] = jian(a,$game_variables[BB])
- $game_switches[G] = true
- elsif $game_switches[E] = true#cheng
- $game_variables[GG] = jian(a,$game_variables[EE])
- $game_switches[G] = true
- else
- $game_variables[GG] = jian(a,c)
- $game_switches[G] = true
- end
- end
- if s[3] == "-"
- if $game_switches[A] = true && $game_switches[C] = true#chu,chu
- $game_variables[HH] = jian($game_variables[AA],$game_variables[CC])
- $game_switches[H] = true
- elsif $game_switches[D] = true && $game_switches[C] = true#cheng,chu
- $game_variables[HH] = jian($game_variables[DD],$game_variables[CC])
- $game_switches[H] = true
- elsif $game_switches[A] = true && $game_switches[F] = true#chu,cheng
- $game_variables[HH] = jian($game_variables[AA],$game_variables[FF])
- $game_switches[H] = true
- elsif $game_switches[D] = true && $game_switches[F] = true#cheng,cheng
- $game_variables[HH] = jian($game_variables[DD],$game_variables[FF])
- $game_switches[H] = true
- elsif $game_switches[G] = true && $game_switches[C] = true#jian,chu
- $game_variables[HH] = jian($game_variables[GG],$game_variables[CC])
- $game_switches[H] = true
- elsif $game_switches[G] = true && $game_switches[F] = true#jian,cheng
- $game_variables[HH] = jian($game_variables[GG],$game_variables[FF])
- $game_switches[H] = true
- elsif $game_switches[A] = true#chu
- $game_variables[HH] = jian($game_variables[AA],e)
- $game_switches[H] = true
- elsif $game_switches[C] = true#chu
- $game_variables[HH] = jian(c,$game_variables[CC])
- $game_switches[H] = true
- elsif $game_switches[D] = true#cheng
- $game_variables[HH] = jian($game_variables[DD],e)
- $game_switches[H] = true
- elsif $game_switches[F] = true#cheng
- $game_variables[HH] = jian(c,$game_variables[FF])
- $game_switches[H] = true
- elsif $game_switches[G] = true#jian
- $game_variables[HH] = jian($game_variables[GG],e)
- $game_switches[H] = true
- else
- $game_variables[HH] = jian(c,e)
- $game_switches[H] = true
- end
- end
- if s[5] == "-"
- if $game_switches[B] = true#chu
- $game_variables[II] = jian($game_variables[BB],g)
- $game_switches[I] = true
- elsif $game_switches[E] = true#cheng
- $game_variables[II] = jian($game_variables[EE],g)
- $game_switches[I] = true
- elsif $game_switches[H] = true#jian
- $game_variables[II] = jian($game_variables[HH],g)
- $game_switches[I] = true
- else
- $game_variables[II] = jian(e,g)
- $game_switches[I] = true
- end
- end
- if s[1] == "+"
- if $game_switches[B] = true#chu
- $game_variables[JJ] = add(a,$game_variables[BB])
- $game_switches[J] = true
- elsif $game_switches[E] = true#cheng
- $game_variables[JJ] = add(a,$game_variables[EE])
- $game_switches[J] = true
- elsif $game_switches[H] = true#jian
- $game_variables[JJ] = add(a,$game_variables[HH])
- $game_switches[J] = true
- else
- $game_variables[JJ] = add(a,c)
- $game_switches[J] = true
- end
- end
- if s[3] == "+"
- if $game_switches[A] = true && $game_switches[C] = true
- $game_variables[KK] = add($game_variables[AA],$game_variables[CC])
- $game_switches[K] = true
- elsif $game_switches[D] = true && $game_switches[C] = true
- $game_variables[KK] = add($game_variables[DD],$game_variables[CC])
- $game_switches[K] = true
- elsif $game_switches[A] = true && $game_switches[F] = true
- $game_variables[KK] = add($game_variables[AA],$game_variables[FF])
- $game_switches[K] = true
- elsif $game_switches[D] = true && $game_switches[F] = true
- $game_variables[KK] = add($game_variables[DD],$game_variables[FF])
- $game_switches[K] = true
- elsif $game_switches[A] = true && $game_switches[I] = true#chu,jian
- $game_variables[KK] = add($game_variables[AA],$game_variables[II])
- $game_switches[K] = true
- elsif $game_switches[D] = true && $game_switches[I] = true#cheng,jian
- $game_variables[KK] = add($game_variables[DD],$game_variables[II])
- $game_switches[K] = true
- elsif $game_switches[G] = true && $game_switches[C] = true#jian,chu
- $game_variables[KK] = add($game_variables[GG],$game_variables[CC])
- $game_switches[K] = true
- elsif $game_switches[G] = true && $game_switches[F] = true#jian,cheng
- $game_variables[KK] = add($game_variables[GG],$game_variables[FF])
- $game_switches[K] = true
- elsif $game_switches[G] = true && $game_switches[I] = true#jian,jian
- $game_variables[KK] = add($game_variables[GG],$game_variables[II])
- $game_switches[K] = true
- elsif $game_switches[J] = true && $game_switches[C] = true#add,chu
- $game_variables[KK] = add($game_variables[JJ],$game_variables[CC])
- $game_switches[K] = true
- elsif $game_switches[J] = true && $game_switches[F] = true#add,cheng
- $game_variables[KK] = add($game_variables[JJ],$game_variables[FF])
- $game_switches[K] = true
- elsif $game_switches[J] = true && $game_switches[I] = true#add,jian
- $game_variables[KK] = add($game_variables[JJ],$game_variables[II])
- $game_switches[K] = true
- elsif $game_switches[A] = true#chu
- $game_variables[KK] = add($game_variables[AA],e)
- $game_switches[K] = true
- elsif $game_switches[D] = true#cheng
- $game_variables[KK] = add($game_variables[DD],e)
- $game_switches[K] = true
- elsif $game_switches[G] = true#jian
- $game_variables[KK] = add($game_variables[GG],e)
- $game_switches[K] = true
- elsif $game_switches[J] = true#add
- $game_variables[KK] = add($game_variables[JJ],e)
- $game_switches[K] = true
- else
- $game_variables[KK] = add(c,e)
- $game_switches[K] = true
- end
- end
- if s[5] == "+"
- if $game_switches[B] = true#chu
- $game_variables[LL] = add($game_variables[BB],g)
- $game_switches[L] = true
- elsif $game_switches[E] = true#cheng
- $game_variables[LL] = add($game_variables[EE],g)
- $game_switches[L] = true
- elsif $game_switches[H] = true#jian
- $game_variables[LL] = add($game_variables[HH],g)
- $game_switches[L] = true
- elsif $game_switches[K] = true#add
- $game_variables[LL] = add($game_variables[KK],g)
- $game_switches[L] = true
- else
- $game_variables[LL] = add(e,g)
- $game_switches[L] = true
- end
- end
- if s[1] == "+" && s[3] == "*" && s[5] == "/"
- zh = $game_variables[JJ]#1+
- elsif s[1] == "+" && s[3] == "+" && s[5] == "+"
- zh = $game_variables[LL]#5+
- elsif s[1] == "-" && s[3] == "-" && s[5] == "-"
- zh = $game_variables[II]#5-
- elsif s[1] == "*" && s[3] == "*" && s[5] == "*"
- zh = $game_variables[FF]#5*
- elsif s[1] == "/" && s[3] == "/" && s[5] == "/"
- zh = $game_variables[CC]#5/
- elsif s[1] == "+" && s[3] == "-" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "+" && s[3] == "-" && s[5] == "-"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "-" && s[5] == "*"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "-" && s[5] == "/"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "+" && s[5] == "-"
- zh = $game_variables[KK]#3+
- elsif s[1] == "+" && s[3] == "+" && s[5] == "*"
- zh = $game_variables[KK]
- elsif s[1] == "+" && s[3] == "+" && s[5] == "/"
- zh = $game_variables[KK]
- elsif s[1] == "+" && s[3] == "*" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "+" && s[3] == "*" && s[5] == "-"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "*" && s[5] == "*"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "/" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "+" && s[3] == "/" && s[5] == "-"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "/" && s[5] == "*"
- zh = $game_variables[JJ]
- elsif s[1] == "+" && s[3] == "/" && s[5] == "/"
- zh = $game_variables[JJ]
- elsif s[1] == "-" && s[3] == "+" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "-" && s[3] == "+" && s[5] == "-"
- zh = $game_variables[KK]
- elsif s[1] == "-" && s[3] == "+" && s[5] == "*"
- zh = $game_variables[KK]
- elsif s[1] == "-" && s[3] == "+" && s[5] == "/"
- zh = $game_variables[KK]
- elsif s[1] == "-" && s[3] == "-" && s[5] == "+"
- zh = $game_variables[LL]#5+
- elsif s[1] == "-" && s[3] == "-" && s[5] == "*"
- zh = $game_variables[HH]#3-
- elsif s[1] == "-" && s[3] == "-" && s[5] == "/"
- zh = $game_variables[HH]
- elsif s[1] == "-" && s[3] == "*" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "-" && s[3] == "*" && s[5] == "-"
- zh = $game_variables[II]#5-
- elsif s[1] == "-" && s[3] == "*" && s[5] == "*"
- zh = $game_variables[GG]#1-
- elsif s[1] == "-" && s[3] == "*" && s[5] == "/"
- zh = $game_variables[GG]
- elsif s[1] == "-" && s[3] == "/" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "-" && s[3] == "/" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "-" && s[3] == "/" && s[5] == "*"
- zh = $game_variables[GG]
- elsif s[1] == "-" && s[3] == "/" && s[5] == "/"
- zh = $game_variables[GG]
- elsif s[1] == "*" && s[3] == "+" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "*" && s[3] == "+" && s[5] == "-"
- zh = $game_variables[KK]#3+
- elsif s[1] == "*" && s[3] == "+" && s[5] == "*"
- zh = $game_variables[KK]
- elsif s[1] == "*" && s[3] == "+" && s[5] == "/"
- zh = $game_variables[KK]
- elsif s[1] == "*" && s[3] == "-" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "*" && s[3] == "-" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "*" && s[3] == "-" && s[5] == "*"
- zh = $game_variables[HH]
- elsif s[1] == "*" && s[3] == "-" && s[5] == "/"
- zh = $game_variables[HH]#3-
- elsif s[1] == "*" && s[3] == "*" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "*" && s[3] == "*" && s[5] == "-"
- zh = $game_variables[II]#5-
- elsif s[1] == "*" && s[3] == "*" && s[5] == "/"
- zh = $game_variables[EE]#3*
- elsif s[1] == "*" && s[3] == "/" && s[5] == "+"
- zh = $game_variables[LL]#5+
- elsif s[1] == "*" && s[3] == "/" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "*" && s[3] == "/" && s[5] == "*"
- zh = $game_variables[FF]
- elsif s[1] == "*" && s[3] == "/" && s[5] == "/"
- zh = $game_variables[DD]
- elsif s[1] == "/" && s[3] == "+" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "/" && s[3] == "+" && s[5] == "-"
- zh = $game_variables[KK]
- elsif s[1] == "/" && s[3] == "+" && s[5] == "*"
- zh = $game_variables[KK]
- elsif s[1] == "/" && s[3] == "+" && s[5] == "/"
- zh = $game_variables[KK]
- elsif s[1] == "/" && s[3] == "-" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "/" && s[3] == "-" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "/" && s[3] == "-" && s[5] == "*"
- zh = $game_variables[HH]
- elsif s[1] == "/" && s[3] == "-" && s[5] == "/"
- zh = $game_variables[HH]
- elsif s[1] == "/" && s[3] == "*" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "/" && s[3] == "*" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "/" && s[3] == "*" && s[5] == "*"
- zh = $game_variables[FF]
- elsif s[1] == "/" && s[3] == "*" && s[5] == "/"
- zh = $game_variables[EE]
- elsif s[1] == "/" && s[3] == "/" && s[5] == "+"
- zh = $game_variables[LL]
- elsif s[1] == "/" && s[3] == "/" && s[5] == "-"
- zh = $game_variables[II]
- elsif s[1] == "/" && s[3] == "/" && s[5] == "*"
- zh = $game_variables[FF]
- end
- $game_variables[ZH] = zh
- end
- end
- class Game_Interpreter
- include MFXRB
- end
复制代码
|
评分
-
查看全部评分
|