本帖最后由 soulsaga 于 2018-6-29 17:33 编辑
#-------------------------------------------------------------------------- # ● 将字符转化为按键 #-------------------------------------------------------------------------- def self.char2key(char) return NONE if char.empty? or [83,87].include?(char[0]) and $game_switches[83]#如果按的键是W或S键和83号开关打开就返回NONE case char[0] when 8..13, 27, 32, 48..57, 65..90 char[0] when 97..122 char[0] - 32 else pindex = ")!@#\$%^&*(".index(char[0]) return D0 + pindex if pindex pindex = ";:=+,<-_.>/?`~".index(char[0]) return SEMICOLON + (pindex >> 1) if pindex pindex = "[{\\|]}\'\"".index(char[0]) return L_BRACE + (pindex >> 1) if pindex NONE end end end
#--------------------------------------------------------------------------
# ● 将字符转化为按键
#--------------------------------------------------------------------------
def self.char2key(char)
return NONE if char.empty? or [83,87].include?(char[0]) and $game_switches[83]#如果按的键是W或S键和83号开关打开就返回NONE
case char[0]
when 8..13, 27, 32, 48..57, 65..90
char[0]
when 97..122
char[0] - 32
else
pindex = ")!@#\$%^&*(".index(char[0])
return D0 + pindex if pindex
pindex = ";:=+,<-_.>/?`~".index(char[0])
return SEMICOLON + (pindex >> 1) if pindex
pindex = "[{\\|]}\'\"".index(char[0])
return L_BRACE + (pindex >> 1) if pindex
NONE
end
end
end
这样可行么..
不知道+无可奉告.. |