Text scrambler doo-hickey thing
XanMag
04 Sept 2017, 14:47I am in need of a device to scramble and unscramble text AFTER a code has been put in. I'm pretty sure that I have seen some people on this forum use it before to hide spoilers. It is probably best in this case if it were external, not built into the code of the game.
I'd like to be able to take:
U angy u sfrmuiqp
Give the player a password found in the game and send them to another site to copy-paste the scrambled text above. The unscrambled text (I need a scrambler) would then be a message they need for the text adventure. I'd just scramble it myself and unscramble it within game but the text to be scrambled is quite lengthy.
That make sense?

K.V.
04 Sept 2017, 17:28How about Base64?
WW91IG5lZWQgdG8gZmluZCB0aGUgYW5zd2VyIG9uIHRoZSBmb3J1bSE=
Decode that here:
https://www.base64decode.org/

K.V.
04 Sept 2017, 21:37This uses an iframe link to decode the Base64 from within the game, without the game's code including the answer.
Click here to view the code
<!--Saved by Quest 5.9.4242.69105-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="scrambled message">
<gameid>74bff86a-6845-45b3-b3e9-3fddfdfcb88a</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="letter">
<inherit name="editor_object" />
<look><![CDATA[The letter reads:<br/><br/><pre><code>WW91IG5lZWQgdG8gZmluZCB0aGUgYW5zd2VyIG9uIHRoZSBmb3J1bSE=</code></pre>]]></look>
<take />
</object>
<object name="Base64 decoder">
<inherit name="editor_object" />
<feature_container />
<feature_usegive />
<use type="script"><![CDATA[
msg ("<iframe width=\"100%\" height=\"450px\" src=\"http://decodebase64.com/\" />")
]]></use>
<displayverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
</displayverbs>
</object>
</object>
</asl>
hegemonkhan
05 Sept 2017, 05:07welcome to cryptography and encoder/decoder programming, XanMag, hehe
one of the simplest ways of doing cryptography, an example:
Cryptography:
base: (A:1 to Z:26)
A:1
B:2
C:3
D:4
E:5
F:6
G:7
H:8
I:9
J:10
K:11
L:12
M:13
N:14
O:15
P:16
Q:17
R:18
S:19
T:20
U:21
V:22
W:23
X:24
Y:25
Z:26
shift (change) down/right by +1: (A:26, B:1 to Z:25)
A:26
B:1
C:2
D:3
E:4
F:5
G:6
H:7
I:8
J:9
K:10
L:11
M:12
N:13
O:14
P:15
Q:16
R:17
S:18
T:19
U:20
V:21
W:22
X:23
Y:24
Z:25
Encoder / "Private Key":
A:26
B:1
C:2
D:3
E:4
F:5
G:6
H:7
I:8
J:9
K:10
L:11
M:12
N:13
O:14
P:15
Q:16
R:17
S:18
T:19
U:20
V:21
W:22
X:23
Y:24
Z:25
Decoder / "Public Key":
1:B
2:C
3:D
4:E
5:F
6:G
7:H
8:I
9:J
10:K
11:L
12:M
13:N
14:O
15:P
16:Q
17:R
18:S
19:T
20:U
21:V
22:W
23:X
24:Y
25:Z
26:A
coding/programming of 'shift' cryptography with quest:
(you can do a shift in either direction by a value of: -25 to 25, as I'm just using one case type of the english alphabet only)
<object name="cryptography_object">
<attr name="alphabet_stringlist_attribute" type="simplestringlist">A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z</attr>
<attr name="base_stingdictionary_attribute" type="simplestringdictionary">A=1;B=2;C=3;D=4;E=5;F=6;G=7;H=8;I=9;J=10;K=11;L=12;M=13;N=14;O=15;P=16;Q=17;R=18;S=19;T=20;U=21;V=22;W=23;X=24;Y=25;Z=26</attr>
<attr name="set_shift_cryptography_script_attribute" type="script">
<![CDATA[
msg ("Shift Value?")
get input {
ClearScreen
if (IsInt (result)) {
input_string_variable = result
input_integer_variable = ToInt (input_string_variable)
if (input_integer_variable < -25 or input_integer_variable > 25) {
msg ("wrong input, try again: the inputted value must be: -25 to 25")
do (this, "set_shift_cryptography_script_attribute")
} else {
this.encoder_stringdictionary_attribute = NewStringDictionary ()
this.decoder_stringdictionary_attribute = NewStringDictionary ()
foreach (alphabet_character_string_variable, this.alphabet_stringdictionary_attribute) {
base_value_string_variable = StringDictionaryItem (this.base_stringdictionary_attribute, alphabet_character_string_variable)
base_value_integer_variable = ToInt (base_value_string_variable)
shifted_value_integer_variable = base_value_integer_variable + input_integer_variable
if (shifted_value_integer_variable > 26) {
final_value_integer_variable = shifted_value_integer_variable - 26
} else if (shifted_value_integer_variable < 1) {
final_value_integer_variable = shifted_value_integer_variable + 26
} else {
final_value_integer_variable = shifted_value_integer_variable
}
final_value_string_variable = ToString (final_value_integer_variable)
dictionary add (this.encoder_stringdictionary_attribute, alphabet_character_string_variable, final_value_string_variable)
dictionary add (this.decoder_stringdictionary_attribute, final_value_string_variable, alphabet_character_string_variable)
}
}
} else {
msg ("wrong input, try again: the input must be an integer value")
do (this, "set_shift_cryptography_script_attribute")
}
}
]]>
</attr>
<attr name="encode_script_attribute" type="script">
msg ("Secret Message?")
get input {
ClearScreen
if (IsNumeric (result) or not result = UCase (result)) {
msg ("Wrong input, try again: your secret message must be an english phrase and must be upper case alphabet and whitespace characters only")
do (this, "encode_script_attribute")
} else {
this.secret_message_string_attribute = result
input_string_variable = result
encoded_number_value_string_variable = ""
foreach (alphabet_character_string_variable, this.alphabet_stringdictionary_attribute) {
if (not Instr (input_string_variable, alphabet_character_string_variable) = 0) {
encoded_number_value_string_variable = StringDictionaryItem (this.encode_stringdictionary_attribute, alphabet_character_string_variable) + ";"
encoded_message_string_variable = Replace (input_string_variable, alphabet_character_string_variable, encoded_number_value_integer_variable)
}
}
this.encoded_message_string_attribute = encoded_message_string_variable
}
}
</attr>
<attr name="decode_script_attribute" type="script">
decoded_message_string_varable = ""
final_decoded_message_string_varable = ""
word_stringlist_variable = split (this.encoded_message_string_variable, " ")
foreach (word_string_variable, word_stringlist_variable) {
number_stringlist_variable = split (word_string_variable, ";")
if (not number_string_variable = null) { <!-- hopefully this works for dealing with the ending ';' split character without an item on its right side, as I can't find any way of removing this ending ';' character -->
foreach (number_string_variable, number_stringlist_variable) {
alphabet_string_variable = StringDictionaryItem (this.decode_stringdictionary_attribute, number_string_variable)
decoded_message_string_variable = decoded_message_string_variable + alphabet_string_variable
}
final_decoded_message_string_variable = final_decoded_message_string_variable + " " + decoded_message_string_variable
}
}
this.decoded_message_string_attribute = final_decoded_message_string_variable
</attr>
<attr name="view_cryptography_messages_script_attribute" type="script">
msg ("Inputted Secret Message: " + this.inputted_secret_message_string_attribute)
msg ("Encoded Message: " + this.encoded_message_string_attribute)
msg ("Decoded Message: " + this.decoded_message_string_attribute)
msg ("(The 'inputted secret message' and 'decoded message' should match up / be the same)")
</attr>
</object>
argh...
that took a long time... to figure out...
quest needs some 'string iteration for its individual characters' type of Functions ... !!!!

K.V.
05 Sept 2017, 05:23Nice!
@HK
Did you just look at a Little Orphan Annie Secret Decoder Ring as a reference?

K.V.
05 Sept 2017, 05:33U angy u sfrmuiqp
I think XM just typed example jibberish. Attempts to decode:
``` V bohz v tgsnvjrq W cpia w uhtowksr X dqjb x viupxlts Y erkc y wjvqymut Z fsld z xkwrznvu A gtme a ylxsaowv B hunf b zmytbpxw C ivog c anzucqyx D jwph d boavdrzy E kxqi e cpbwesaz F lyrj f dqcxftba G mzsk g erdygucb H natl h fsezhvdc I obum i gtfaiwed J pcvn j hugbjxfe K qdwo k ivhckygf L rexp l jwidlzhg M sfyq m kxjemaih N tgzr n lykfnbji O uhas o mzlgockj P vibt p namhpdlk Q wjcu q obniqeml R xkdv r pcojrfnm S ylew s qdpksgon T zmfx t reqlthpo ```Hrmm...
hegemonkhan
05 Sept 2017, 05:35nope, tried to do it all on my own... not easy when quest (as far as I know), doesn't seem to have any way of getting (iterating) individual characters (that are next to each other, as if you got some other character between them, then you got a List Value which you can just use the List Attribute/Script/Function usages for it) within a string.
I've also not tested it... I hope it'll work, but probably it won't... I'll get it tested... and see if I can get it working, if I'm not super lucky and it works right-off-the-bat (highly unlikely).
there is the 'Instr/RevInstr' Functions, but they jsut return the position integer, but I could find no Function for being able to then use that gotten position integer for getting (via an iterating Function --- there doesn't seem to be one) a character at that position within a string?
there's infinite ways of doing cryptography, using complex dictionary/mapping like you did (I don't understand or can't figure out how it works though), using mathematical equations (instead of simple shifting), for a random hash string (simplest way is the product of two really huge prime numbers, and more complex would be to further use that within a mathematical equation), multiple iterations of your method (more "randomness/generating": layers of "randomness/generating"), and etc etc etc

K.V.
05 Sept 2017, 06:11Here's a BASH! script:
#!/bin/bash
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZ
rot=1
echo "What would you like to be coded?"
sed "y/${alpha}/${alpha:$rot}${alpha::$rot}/"
NOTES:
- It only works with ALL CAPS. (I was using it to encode the hints for my first game, and I wanted the lower case characters unaltered -- I used them for notes)
- You need to change
rot
's value for this script to actually do anything.

K.V.
05 Sept 2017, 06:38> using complex dictionary/mapping like you did
Who? Me?
Nuh-uh! I actually used my secret decoder ring. (I've had one since I was just a Lil' Text Adventurer.)

hegemonkhan
05 Sept 2017, 07:01oh... that's a cool idea... though still don't know exactly how the idea works, hehe :D
some kind of multi-layered combination dial/clock/lock/time-planet-alignment system/mechanic, I see :D
reminds me of young school days with lockers and your combination locks... I hated them... by the time I finally got my combination memorized... the school year was over, laughs.
The Pixie
05 Sept 2017, 10:00A couple of functions for ROT encoding; the second parameter is the number to shift on by. The second function encodes a single character, the first uses that to do a string. Non-letters are not changed and case is preserved.
<function name="Rot" parameters="s, n" type="string">
result = ""
for (i, 1, LengthOf(s)) {
result = result + _Rot(Mid(s, i, 1), n)
}
return (result)
</function>
<function name="_Rot" parameters="c, n" type="string">
if (c = UCase(c)) {
upper = true
}
else {
upper = false
c = UCase(c)
}
x = Asc(c)
if (x < Asc("A") or x > Asc("Z")) {
return (c)
}
x = (x - Asc("A") + n) % 26 + Asc("A")
c = Chr(x)
if (upper) {
return (c)
}
else {
return (LCase(c))
}
</function>
You can then do:
s = "Hello World!"
msg (Rot(s, 13))
msg (Rot(Rot(s, 13), 13))
Uryyb Jbeyq!
Hello World!
Note: I have edited this to use Asc
and Chr
, so it go longer needs an alphebet attribute on the game object.
hegemonkhan
05 Sept 2017, 13:33ah, so quest does have a Function and method: 'Mid' with 'for', and probably could do/use 'Instr/RevInstr' too, if you need them.
Didn't think/realize of looking-at/using 'Mid', argh....

Doctor Agon
05 Sept 2017, 18:13@ XanMag
Sent you a PM. A BASIC listing, so not sure how helpful it might be

K.V.
05 Sept 2017, 19:36Any way to simplify this command script?
Click here to view the code
(It wouldn't let me post it here.)
https://gist.github.com/KVonGit/eb18ff565bd7f5e06095d5d0aaa72a1c#file-cipher_decipher-md

Doctor Agon
06 Sept 2017, 06:41For what it's worth, this is a quest version of a BASIC program (Beginners All-purpose Symbolic Instruction Code), that I've got.
The program appeared in a magazine 'INPUT' published weekly by Marshall Cavendish in 1984.
As I said, I've done my best to try to change it for quest, but there are problems with it, and I'm hoping some people on here will be able to have a look at it and make it work.
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Text Scrambler">
<gameid>56d38576-fccc-45a0-b102-14ad7861cb40</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
<s type="int">0</s>
<a type="string"></a>
<k type="int">0</k>
<l type="int">0</l>
<t type="int">0</t>
<n type="string"></n>
</game>
<object name="room1">
<inherit name="editor_room" />
<description type="script"><![CDATA[
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("Enter seven figure number key.")
get input {
game.n = result
for (game.k, 1, LengthOf(game.a), 1) {
game.l = game.k-Int(game.k/7)*7+1
t = Asc(Mid(game.a,game.k,1))+(game.s*Val(Mid(game.n,game.l,1)))
if (game.t>90 or game.t<65) {
game.t = game.t-(game.s*26)
}
msg (Chr(game.t))
}
}
}
}
]]></description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>
The errors seem to be in this line
game.l = game.k-Int(game.k/7)*7+1
And also here:
t = Asc(Mid(game.a,game.k,1))+(game.s*Val(Mid(game.n,game.l,1)))
The same program will both encode/decode by the use of the variable 's' (either 1 or -1).

K.V.
06 Sept 2017, 07:27This may or may not be helpful...
I added debugging messages.
Debugging begins here
If I understood what was happening, I'm pretty sure those would help...
You are in a room1.
Text Scrambler
WARNING!!!
Do NOT leave spaces between words.
Enter 1 if you wish to encode.
Enter -1 if you wish to decode.
game.s:1
Enter the text you wish to encode
game.a:hello
Enter seven figure number key.
game.n:2222222
LengthOf(game.a):5
game.k:0
game.l:1
Error running script: Error evaluating expression '"<b>Asc(Mid(game.a,game.k,1)):" + Asc(Mid(game.a,game.k,1)) + "</b>"': Argument 'Start' must be greater than zero.
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (game.k, 1, LengthOf(game.a), 1) {
msg ("<b>game.k:" + game.k + "</b>")
game.l = game.k-(game.k/7)*7+1
msg ("<b>game.l:" + game.l + "</b>")
msg ("<b>Asc(Mid(game.a,game.k,1)):" + Asc(Mid(game.a,game.k,1)) + "</b>")
msg ("<b>(game.s*Val(Mid(game.n,game.l,1)):" + (game.s*Val(Mid(game.n,game.l,1)) + "</b>")
t = Asc(Mid(game.a,game.k,1))+(game.s*Val(Mid(game.n,game.l,1)))
if (game.t>90 or game.t<65) {
game.t = game.t-(game.s*26)
}
msg (Chr(game.t))
}
}
}
}
The Pixie
06 Sept 2017, 07:48Your loop is using game.k as the iterator variable. When you do that, the variable does not change, it keeps the value 0. I think if you change every "game.k" to "k" it will solve at least the first error.

Doctor Agon
06 Sept 2017, 08:10I've tried changing 'Int' to 'ToInt' but it keeps coming back, saying it can't find function, function call element ToInt(Int32)

K.V.
06 Sept 2017, 08:14debugging in progress
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
msg ("<b>game.l:" + game.l + "</b>")
msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
msg ("<b>(game.s*Val(Mid(game.n,game.l,1))):" + (game.s*Val(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(game.s*Val(Mid(game.n,game.l,1)))
if (game.t>90 or game.t<65) {
game.t = game.t-(game.s*26)
}
msg (Chr(game.t))
}
}
}
}
Text Scrambler
WARNING!!!
Do NOT leave spaces between words.
Enter 1 if you wish to encode.
Enter -1 if you wish to decode.
game.s:1
Enter the text you wish to encode
game.a:hello
Enter seven figure number key.
game.n:2222222
LengthOf(game.a):5
k:1
game.l:2
Asc(Mid(game.a,k,1)):104
Error running script: Error compiling expression '"<b>(game.s*Val(Mid(game.n,game.l,1))):" + (game.s*Val(Mid(game.n,game.l,1))) + "</b>"': FunctionCallElement: Could find not function 'Val(String)'

K.V.
06 Sept 2017, 08:21Debugging in progress
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
msg ("<b>game.l:" + game.l + "</b>")
msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
msg ("<b>(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):" + (ToInt(game.s)*ToInt(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (game.t>90 or game.t<65) {
game.t = game.t-(ToInt(game.s)*26)
}
msg (Chr(game.t))
}
}
}
}
Text Scrambler
WARNING!!!
Do NOT leave spaces between words.
Enter 1 if you wish to encode.
Enter -1 if you wish to decode.
game.s:1
Enter the text you wish to encode
game.a:hello
Enter seven figure number key.
game.n:2222222
LengthOf(game.a):5
k:1
game.l:2
Asc(Mid(game.a,k,1)):104
(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):2
Error running script: Error evaluating expression 'Chr(game.t)': Procedure call or argument is not valid.
game.t is -26

Doctor Agon
06 Sept 2017, 08:23Yeah, That's the other message I was getting.
In BASIC, the Val(X$): Converts the character representation of figures into a number. If the string starts with an alphabetic character it returns 0

Doctor Agon
06 Sept 2017, 08:29As I said, I've done my best in trying to convert it to quest, maybe I've done a bad job swapping the variables to quest.
CHR(T) should print the letter, not a number

K.V.
06 Sept 2017, 08:41Yeah, but game.t = -26
Chr can't work from a negative number, can it?
Oh! Look! It switches from t
to game.t
!!!
Be right back!
hegemonkhan
06 Sept 2017, 08:43there might be some differences between quest's 'chr' and 'asc' user-level Functions and whatever language (basic, C, etc) that it works in normally that you're taking the code from and trying to convert to quest's code
these are quest's user-level Functions:
http://docs.textadventures.co.uk/quest/functions/string/chr.html
http://docs.textadventures.co.uk/quest/functions/string/asc.html
if I understand there documentation, I think they convert back and forth between the character/symbol/alphabet and its binary code number representation ( https://en.wikipedia.org/wiki/Binary-coded_decimal ) and/or its ascii number representation ( http://www.asciitable.com )
there's also these Functions for string-character usage:
http://docs.textadventures.co.uk/quest/scripts/for.html
http://docs.textadventures.co.uk/quest/functions/#string
http://docs.textadventures.co.uk/quest/functions/string/mid.html
http://docs.textadventures.co.uk/quest/functions/string/instr.html
http://docs.textadventures.co.uk/quest/functions/string/instrrev.html
a simple way to change a negative number to a positive number: multiple it by '-1'
(negative_number) * (-1) = (positive_number)

K.V.
06 Sept 2017, 08:47Debugging in progress
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
//msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
//msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
//msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
//msg ("<b>game.l:" + game.l + "</b>")
//msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
// msg ("<b>(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):" + (ToInt(game.s)*ToInt(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (t>90 or t<65) {
t = t-(ToInt(game.s)*26)
}
msg (t)
msg (Chr(t))
}
}
}
}
Text Scrambler
WARNING!!!
Do NOT leave spaces between words.
Enter 1 if you wish to encode.
Enter -1 if you wish to decode.
Enter the text you wish to encode
game.a:abc
Enter seven figure number key.
game.n:2222222
73
I
74
J
75
K

K.V.
06 Sept 2017, 08:50PUBLIC SERVICE ANNOUNCEMENT:
Pixie's script works perfectly.
http://textadventures.co.uk/forum/quest/topic/ibk2irzb7kwmddhrnrnfqq/text-scrambler-doo-hickey-thing#abacd36e-79fb-4467-b943-d3df6b0d9b7d
We're just playing around with this one because it's a challenge.

K.V.
06 Sept 2017, 09:02Debugging in progress
t = t-(ToInt(game.s)%26)
instead of t = t-(ToInt(game.s)*26)
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
//msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
//msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
//msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
//msg ("<b>game.l:" + game.l + "</b>")
//msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
// msg ("<b>(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):" + (ToInt(game.s)*ToInt(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (t>90 or t<65) {
t = t-(ToInt(game.s)%26)
}
msg (t)
msg (Chr(t))
}
}
}
}
CODE
Enter the text you wish to encode
game.a:abc
Enter seven figure number key.
game.n:2222222
98
b
99
c
100
d
DECODE
Enter the text you wish to decode
game.a:bcd
Enter seven figure number key.
game.n:2222222
97
a
98
b
99
c

K.V.
06 Sept 2017, 09:10Bwahahahaha!
Enter the text you wish to encode
game.a:abc
Enter seven figure number key.
game.n:2222222
bcd
Enter the text you wish to decode
game.a:bcd
Enter seven figure number key.
game.n:2222222
abc
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
// msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
// msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
// msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
// msg ("<b>game.l:" + game.l + "</b>")
// msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
// msg ("<b>(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):" + (ToInt(game.s)*ToInt(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (t>90 or t<65) {
t = t-(ToInt(game.s)%26)
}
// msg (t)
// msg (Chr(t))
OutputTextNoBr (Chr(t))
}
}
}
}

K.V.
06 Sept 2017, 09:34@ Doctor Agon
Decode this!
Hoftrr Egrn#is#puewty#ddrq croo!
seven-figure number key: 1414141
You can include spaces, too, by the way. That worked 'out of the box'.
Doctor Agon's game code (altered)
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Text Scrambler">
<gameid>56d38576-fccc-45a0-b102-14ad7861cb40</gameid>
<version>1.0</version>
<firstpublished>2017</firstpublished>
<s type="int">0</s>
<a type="string"></a>
<k type="int">0</k>
<l type="int">0</l>
<t type="int">0</t>
<n type="string"></n>
</game>
<object name="room1">
<inherit name="editor_room" />
<description type="script"><![CDATA[
msg ("Text Scrambler")
msg ("WARNING!!!<br/>Do NOT leave spaces between words.")
msg ("Enter 1 if you wish to encode.<br/>Enter -1 if you wish to decode.")
get input {
game.s = result
// msg ("<b>game.s:" + game.s + "</b>")
msg ("Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}")
get input {
game.a = result
msg ("<b>game.a:" + game.a + "</b>")
msg ("Enter seven figure number key.")
get input {
game.n = result
msg ("<b>game.n:" + game.n + "</b>")
// msg ("<b>LengthOf(game.a):" + LengthOf(game.a) + "</b>")
for (k, 1, LengthOf(game.a), 1) {
// msg ("<b>k:" + k + "</b>")
game.l = k-(k/7)*7+1
// msg ("<b>game.l:" + game.l + "</b>")
// msg ("<b>Asc(Mid(game.a,k,1)):" + Asc(Mid(game.a,k,1)) + "</b>")
// msg ("<b>(ToInt(game.s)*Val(ToInt(Mid(game.n,game.l,1)))):" + (ToInt(game.s)*ToInt(Mid(game.n,game.l,1))) + "</b>")
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (t>90 or t<65) {
t = t-(ToInt(game.s)%26)
}
// msg (t)
// msg (Chr(t))
OutputTextNoBr (Chr(t))
}
}
}
}
]]></description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>

K.V.
06 Sept 2017, 09:38Well, I used a bunch of 1s in that example...
Here's one:
Message to decode (press -1
to decode):
Fnq"zqso"fpg"os"und{!qcpgv"Leep"d"eynq"eqz2
seven digit number key: 2536343
I kept wanting to question that seven digit number key, but that's the part that makes your code the best so far, Doctor Agon!
Do you mind if I steal it? I'll make a PC to interact with. with which you can interact. It will prompt you:
>|
PLEASE ENTER THE MESSAGE TO DECODE
>|
Well, that's a lot of coding.
Perhaps I'd just make it an object you could USE...

K.V.
06 Sept 2017, 10:05This post self-destructed.
(I couldn't post 'that' here.)
See the post after the next one for the edit.
The Pixie
06 Sept 2017, 10:50I've tried changing 'Int' to 'ToInt' but it keeps coming back, saying it can't find function, function call element ToInt(Int32)
ToInt
is expecting a string, and you are passing a number.
there might be some differences between quest's 'chr' and 'asc' user-level Functions and whatever language (basic, C, etc) that it works in normally that you're taking the code from and trying to convert to quest's code
I think Quest uses the built-in Visual BASIC functions. There are a whole bunch of them, Asc, Chr, Left, InStr, , InStrRev, LCase, LTrim, LSet, Mid, Replace, Right, RSet, RTrim, Trim, UCase, mostly undocumented. And they all seem to be case-insenstive for some reason.

K.V.
06 Sept 2017, 11:24Here is Doctor Agon's code, made into an object, which 'runs the program' when you USE it.
I fixed his script (using everyone's input (everyone here is so awesome!)), and it only took 2 or 3 changes.
Changing game.k and game.t to just k and t, and I can't remember what these next two lines were originally (and I can't scroll up because I'm editing the post).
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
t = t-(ToInt(game.s)%26)
Here's the message to decode:
seven-digit number key: 6357834
Message:Tykzv#nu$y|rhw/e}lurrg%
Here's the object
<object name="text scrambler">
<feature_usegive />
<displayverbs type="stringlist">
<value>Use</value>
</displayverbs>
<alias>a text scrambler</alias>
<usedefaultprefix type="boolean">false</usedefaultprefix>
<take />
<use type="script">
MoveObjectHere (text scrambler)
text scrambler.alias = "Text Scrambler"
MoveObject (player, text scrambler)
</use>
<onexit type="script">
text scrambler.alias = "a text scrambler"
JS.setForeground (game.defaultforeground)
JS.setBackground (game.defaultbackground)
request (Show, "Location")
request (Show, "Panes")
ClearScreen
HideOutputSection (game.menuoutputsection)
msg ("")
</onexit>
<beforeenter type="script"><![CDATA[
JS.setCss ("div#gameBorder", "box-shadow:0px 0px 15px 5px black;")
request (Hide, "Panes")
request (Hide, "Location")
ClearScreen
msg ("<center><h1><samp style=\"background:black;color:green;\">{b:Text Scrambler}</h1><center>")
msg ("")
JS.setBackground ("black")
JS.setForeground ("green")
]]></beforeenter>
<enter type="script">
game.menuoutputsection = StartNewOutputSection()
</enter>
<turnscript name="runTextScrambler">
<enabled />
<script><![CDATA[
msg ("<style>a>.cmdlink{green !important}</style><h3><samp style=\"background:black;color:green;\">PLEASE PRESS 1 TO ENCODE, 2 TO DECODE, or {command:EXIT}</samp></h3>")
get input {
result = LCase(result)
if (not result = "exit") {
if ((not EndsWith(result, "1") and not EndsWith(result, "2"))) {
error ("<samp style=\"background:black;color:green;\">I said enter 1 or 2!!!")
}
if (result = "2") {
result = "-1"
}
game.s = result
msg ("<samp style=\"background:black;color:green;\"><b>Enter the text you wish to {if game.s=1:encode}{if game.s<>1:decode}</b>")
get input {
game.a = result
msg ("<samp style=\"background:black;color:green;\"><b>You entered: </b>" + game.a)
msg ("<samp style=\"background:black;color:green;\"><b>Enter seven figure number key.</b>")
get input {
regex = "^\\d{7}$"
if (not IsRegExMatch(regex, result)) {
error ("I said seven digits!")
msg ("<samp style=\"background:black;color:green;\">{b:Your result:}")
}
game.n = result
msg ("<samp style=\"background:black;color:green;\"><b>You entered: </b>" + game.n)
OutputTextNoBr ("<samp style=\"background:black;color:green;\">{b:Your result:}")
for (k, 1, LengthOf(game.a), 1) {
game.l = k-(k/7)*7+1
t = Asc(Mid(game.a,k,1))+(ToInt(game.s)*ToInt(Mid(game.n,game.l,1)))
if (t>90 or t<65) {
t = t-(ToInt(game.s)%26)
}
OutputTextNoBr ("<samp style=\"background:black;color:green;\">" +Chr(t))
game.t = Chr(t)
}
}
}
}
else {
HandleSingleCommand ("exit")
}
}
]]></script>
</turnscript>
<command name="exit">
<pattern>exit</pattern>
<script>
MoveObject (player, text scrambler.parent)
MoveObject (text scrambler, player)
</script>
</command>
</object>
This code is awesome, Doctor Agon!
Sorry for jacking your thread, XM, but I'm sure you'll agree that this code rocks!
TODO:
- Learn how to check if the panes and location bar are visible BEFORE hiding them and showing them upon exit.
- Change to the cursor for commands (remove the text input box, and replace with
>
) upon entering the text scrambler. (Also change the background color of said element.) - Learn how to check if the game is already set to cursor for commands before changing things in the script.

Doctor Agon
06 Sept 2017, 17:09Thanks Guys, I think you all ROCK!!!
I didn't come up with the program, I used it when I was younger. But, I thought it could be converted to Quest, as a lot of the string function elements seemed to be the same.
The number key can be any seven numbers, it's not tied to a rotational/ fixed number, say 1 or 3. Plus, the decoded message doesn't appear in the game listing.

K.V.
06 Sept 2017, 18:03
Doctor Agon
06 Sept 2017, 18:49Just glad I wasn't wasting my time putting this out there in the first place. I just hope it finds a use in XanMag's game, or anyone else's come to that.

Doctor Agon
06 Sept 2017, 19:36Just realised I may have broken several copyright laws, but seeing as the programs were initially in a magazine that was designed to be inputted into a computer in the first place, then stored back in the day on cassette, I was breaking the law then too.

DarkLizerd
06 Sept 2017, 20:20Can you send me the basic version?
I think I can see a few ways to make this more user friendly...

K.V.
06 Sept 2017, 20:23I just added it to the game I'm currently working on (which is coming soon). (I've got a strong feeling it will end up somewhere in the game XM's working on, too!)
I also added Pixie's Rot functions (with an A-Z string list, which has already been entered and I'm not deleting it! I'll use the revised scripts in the next game!).
You can carry the text scrambler around. When you USE it, the script puts it in player.parent, and you enter the scrambler. Upon EXIT, the script moves you back to text scrambler.parent and moves the scrambler to the player. (My example object may have funny color settings to match the game... I can't remember... No, I think I set to to return to the game.default* colors and such.)
It's super-cool, Doctor Agon!
(Just wait until DarkLizerd sees it1!)

K.V.
06 Sept 2017, 20:24@DL!
You saw the BASIC script while I was writing that you'd like it when you found it!!!
(No fair!!!)
@ Doctor Agon
The codes posted in this thread are just educational sources; aren't they?

Doctor Agon
06 Sept 2017, 20:49Here's the BASIC (Beginners All-purpose Symbolic Instruction Code) as it appears in the magazine 'INPUT' published by Marshall Cavendish 1984.
20 CLS
30 PRINT"ST-CYR CIPHER"
40 PRINT"WARNING"
50 PRINT"DON'T LEAVE SPACES BETWEEN WORDS"
70 PRINT"ENTER 1 IF YOU WISH TO ENCODE"
80 PRINT"ENTER -1 IF YOU WISH TO DECODE"
90 INPUT S
100 INPUT"ENTER YOUR MESSAGE";A$
120 INPUT"ENTER SEVEN FIGURE NUMBER KEY";N$
140 FOR K=1 TO LEN(A$)
150 L=K-INT(K/7)*7+1
160 T=ASC(MID$(A$,K,1))+(S*VAL(MID$(N$,L,1)))
170 IF T>90 OR T<65 THEN T=T-(S*26)
180 PRINT CHR$(T);
190 NEXT K
Lines 110 and 130, were just wait routines; a for/next loop then CLS(clear screen).
Line 170, I think checks if the output is in the range a-z.
I've also mentioned where the program comes from and the date of the publication, which I've done a few times now, so I hope that's OK, with regards copyright.

K.V.
06 Sept 2017, 23:28@ Doctor Agon
Would you like to name your text scrambling object? (It's in the game now, and there are already two uses for it.)
I was going to call it Doctor Agon's Text Scrambler, but I thought it would be nice to let you name it instead.

Doctor Agon
06 Sept 2017, 23:44Honestly, it's not mine. I'm just passing it on. I had such fun when I was a kid, typing in BASIC programs from magazines like 'INPUT' and Dragon User, unpicking the code to find out how it worked, and putting what I'd learnt into my own games.
(The Dragon32, (32K, which is tiny by today's standards), was my first computer; hence my name on here, Doctor Agon, or Dr.Agon, also because I'm Welsh.)
I'm just glad I could help solve a problem.

Doctor Agon
06 Sept 2017, 23:50@ DarkLizerd
I'd be interested in seeing your version of it too.

K.V.
07 Sept 2017, 00:04I had such fun when I was a kid, typing in BASIC programs from magazines like 'INPUT' and Dragon User, unpicking the code to find out how it worked, and putting what I'd learnt into my own games.
Me, too! (In fact, there's a Tandy Color Computer 2 in this game, as well. The player will have to switch on the TV, switch on the Tandy, then use it to write a program in BASIC.)
I've got all sorts of programming-related commands and things in this game. It's gonna be pretty cool (if you write Quest games)!
[ I'm not the only one working on this game, either! (Luckily, my fellow collaborators are far more creative than I am! Better writers too! (Which isn't saying much! Ha-ha!)) ]
(The Dragon32, (32K, which is tiny by today's standards), was my first computer; hence my name on here, Doctor Agon, or Dr.Agon.)
How about the DrAgon (64-bit)? ...or the DrAgon84 Text Scrambler Doo-Hickey Thing?
Honestly, it's not mine. I'm just passing it on.
Just like Elvis...
...and Creedence...
...and Zeppelin...
...and Clapton.
I could totally call it the Cavendish84 (or something like that) if you'd prefer, of course...

DarkLizerd
07 Sept 2017, 02:37I guess I missed it...
Looks like simple code...
A simple en-coder/de-coder should be as simple as a function...

K.V.
11 Sept 2017, 08:20Ftv's$ipwoes$wp%lrhrn!~wuq$Swftthrh" // <!-- Secret message to decode -->
[ 4269105 ] <-- Hidden message!!!