Goodday everyone,
How would i go about capturing a Value with an IF statement.
This is an example from old openbullet:
IF “
” Contains “[]”
SET CAP “ONE” “[ONE]”
ELSE
SET CAP “TWO” “[TWO]”
ENDIF
Goodday everyone,
How would i go about capturing a Value with an IF statement.
This is an example from old openbullet:
IF “
” Contains “[]”
SET CAP “ONE” “[ONE]”
ELSE
SET CAP “TWO” “[TWO]”
ENDIF
Refer to the documentation inside of OB2
http://localhost:5000/docs/lolicode/statements
Also mind that if you want to assign values to variables inside IF/ELSE statements you have to declare them before entering the statement, otherwise you won’t have them anymore when it exits the scope of the statement.
here is some loliscript example using ironpython
BLOCK:ConstantString
value = "dog"
=> VAR @outputstring
ENDBLOCK
BLOCK:Script
INTERPRETER:IronPython
INPUT outputstring
BEGIN SCRIPT
stt = outputstring
if "cat" in stt:
result = "resp1"
if "dog" in stt:
result = "resp2"
END SCRIPT
OUTPUT String @result
ENDBLOCK
BLOCK:ConstantString
value = @result
=> VAR @constantStringOutput
ENDBLOCK
Or using C# you can do
string result = outputString.Contains("cat") ? "resp1" : "resp2";
I have the same doubt, and the documentation is quite simple.
In OB it was like this:
IF “SOURCE” Contains “Example”
SET CAP “” “Example”
SET STATUS CUSTOM “FREE”
How do I do it in OB2?
@Ruri
BLOCK:ConstantString
value = ""
=> CAP @result
ENDBLOCK
IF STRINGKEY @data.SOURCE Contains "Example"
result = "blahblah";
data.STATUS = "FREE";
return;
END