Ich hatte mal das hier gefunden:
Code
stringMath(string) {
while(position := RegExMatch(string, "\(([^\(\)]+)\)", regex_)) {
string := RegExReplace(string, "\(([^\(\)]+)\)", stringMath(regex_1), blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_)) {
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_1 . regex_2**regex_3, blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\*|/) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_3 == "*")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\* *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2*regex_4, blahblah, 1, position)
if(regex_3 == "/")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) */ *((?:\+||)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2/regex_4, blahblah, 1, position)
}
while(position := RegExMatch(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\+|-) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_2 == "+")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\+ *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1+regex_3, blahblah, 1, position)
if(regex_2 == "-")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *- *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1-regex_3, blahblah, 1, position)
}
if(RegExMatch(string, "^-?\d+(?:\.\d+)?$"))
return string
return "ERROR"
}
Alles anzeigen
Einfach mit PlayerInput() machen. ZB so (Mit der SAMP.ahk
Code
#Include, SAMP.ahk
:?:/tr::
Suspend Permit
ergebnis := stringMath(PlayerInput("Taschenrechner: "))
addMessageToChatWindow("{FFFFFF}Ergebnis: {CCCCCC}" ergebnis)
return
stringMath(string) {
while(position := RegExMatch(string, "\(([^\(\)]+)\)", regex_)) {
string := RegExReplace(string, "\(([^\(\)]+)\)", stringMath(regex_1), blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_)) {
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+)\^((?:\+|-)?\d+)", regex_1 . regex_2**regex_3, blahblah, 1, position)
}
while(position := RegExMatch(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\*|/) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_3 == "*")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\* *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2*regex_4, blahblah, 1, position)
if(regex_3 == "/")
string := RegExReplace(string, "(\+|-)? *((?:\+|-)?\d+(?:[\.\,]\d+)?) */ *((?:\+||)?\d+(?:[\.\,]\d+)?) *", regex_1 . regex_2/regex_4, blahblah, 1, position)
}
while(position := RegExMatch(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *(\+|-) *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_)) {
if(regex_2 == "+")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *\+ *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1+regex_3, blahblah, 1, position)
if(regex_2 == "-")
string := RegExReplace(string, " *((?:\+|-)?\d+(?:[\.\,]\d+)?) *- *((?:\+|-)?\d+(?:[\.\,]\d+)?) *", regex_1-regex_3, blahblah, 1, position)
}
if(RegExMatch(string, "^-?\d+(?:\.\d+)?$"))
return string
return "ERROR"
}
PlayerInput(text){
s := A_IsSuspended
Suspend On
KeyWait Enter
BlockChatInput()
SendInput t^a{backspace}%text%
Input, var, v, {enter}
SendInput ^a{backspace 100}{enter}
Sleep, 20
UnblockChatInput()
if(!s)
Suspend Off
return var
}
Alles anzeigen