Periods in #text#

MrFRZ
I am trying to create a hacking simulation game and to do this, i need fake ip addresses to be saved in #text#. For some unknown reason, when I try to save, for example, 164.584.3.89 in #text# it gives me an "i don't understand your command" message, like I haven't programmed a command for it when I have. To be more clear here is my code:

The command pattern is: connect #text#
This cmd is used to connect to the victim's computer. So to connect to the example ip above, the player needs to type: connect 164.584.3.89

if (text = "164.584.3.89") {
if (game.pov.parent = Local) {
ClearScreen
msg ("[Info]: Searching for server...<br/>[Info]: Server found...<br/>[Info]: Connecting...<br/>[Info]: Connection established.")
}
else {
msg ("[Info]: Searching for server...<br/>[Error]: Server could not be located.<br/>[Info]: Unable to connect at this time.")
}
}

I have tried replacing the ip with a random word and it works like it should, same if i put numbers in, and even a period works, as long as nothing is after it.
For example, replacing the ip (164.584.3.89) with any of these allows the code to work: blu blu32 42 42. hair7.
but as soon as something goes behind the period, the game says "I don't understand your command" a few times.
Ex: blu1.2 wont work

So I've figured out that my code isn't the problem, but what I'm putting into #text# is. Basically I need some way around this, either a way to get the ip to go into #text# or another way to do it entirely. Any and all help will be appreciated and I hope one of you can help me. I would like to continue working on this game soon if I can.

R2T1
Afraid you may be out of luck here. The period or dot or fullstop is used internally to separate commands so that at the prompt you could enter L.I.X ME and quest would read it as 3 separate commands - Look then Inventory then Examine Me.
I remember seeing an earlier post regarding this either here or it may have been on http://www.intfiction.org/forum/

This is a common approach in most modern IF, so I don't think you are going to achieve what you want unless you can trap the individual characters into an array as they are typed and re-construct the URL string.

jaynabonne
You could change it to have a "connect" command that then prompts for the IP, using "get input" to read it. It's a bit more clunky, but it works around this "feature" of the parser. Or you modify HandleCommand (copy it to your game and change it) to not split on periods...

The Pixie
jaynabonne wrote:Or you modify HandleCommand (copy it to your game and change it) to not split on periods...

I would say this was a good idea anyway. Does anyone use a full stop to concatenate commands when playing games? All it is good for is cheating the turn counter, as it lets the player do multiple actions in a single turn.

Silver
The Pixie wrote:

"jaynabonne"

Or you modify HandleCommand (copy it to your game and change it) to not split on periods...


I would say this was a good idea anyway. Does anyone use a full stop to concatenate commands when playing games? All it is good for is cheating the turn counter, as it lets the player do multiple actions in a single turn.



Is that right? Knowing that is a massive help for games testing (cut and paste a single line that takes you right up to the point you want to test).

jaynabonne
The problem (and this is potentially a big one) is that, as far as I know, turn scripts execute after each *line* is processed, not each individual command. So if you had (for example) a chase game where the monster advances toward the player using a turn script, then the player could speed ahead by executing multiple commands in a single turn. To me, it's a big issue, even if your usage is more mundane than monsters. :)

Silver
I haven't used turn scripts yet but cheers for the heads up.

Pertex
jaynabonne wrote:The problem (and this is potentially a big one) is that, as far as I know, turn scripts execute after each *line* is processed, not each individual command. So if you had (for example) a chase game where the monster advances toward the player using a turn script, then the player could speed ahead by executing multiple commands in a single turn. To me, it's a big issue, even if your usage is more mundane than monsters. :)


So do you think the possibility of entering several commands in one line sould be removed?

The Pixie
Yes.

Or it could be an option on the game object.

jaynabonne

Yes.

Or it could be an option on the game object.



Took the words right out of my mouth. :)

I don't know if many Quest authors realize the feature (which means it's probably not planned for in their games), and they do run into it with periods in their object names. I hit it myself the first time when I had a character named "Mr. XXXX" (can't remember what the XXXX was). It took me a little while to figure out why it wasn't working.

An option might be straightforward (just an attribute on the game object to start would suffice).

MrFRZ
jaynabonne wrote:You could change it to have a "connect" command that then prompts for the IP, using "get input" to read it. It's a bit more clunky, but it works around this "feature" of the parser. Or you modify HandleCommand (copy it to your game and change it) to not split on periods...


How would I do both of these? (I'm new at quest, although I have a bit of knowledge with programming)
And preferably, if I could change it to not handle periods as multiple commands that's what I'd rather do, so I can just code like I have been coding. I believe your second suggestion is doing exactly this, right? Modifying a setting so it no longer recognizes the period as a fullstop? And will this only alter the period problem or will it change the functioning of the game in other ways too?

HegemonKhan
I don't know what Jay is refering to with a 'connect' command (HK edit: maybe he's refering to a 'hook' key~keyboard command), as I'm a noob with programming in general and still trying to learn quest's coding on top of just learning to code in general, but another possible option is to ignore having the person use a dot in their typed-in inputs, and~or return a string to the person to see it as a proper IP with the dots, such as:

<command>
<pattern>connect #text1# #text2# #text# #text4#</pattern>
<script>
msg ("You inputed the IP: " + text1 + "." + text2 + "." + text3 + "." + text4")
//
// or
// octet_1 = text1
// octet_2 = text2
// octet_3 = text3
// octet_4 = text4
// you can create a function: whatever_function (octet_1, octet_2, octet_3, octet_4)
//
// and then, etc scripts of yours
</script>
</command>

<function name="whatever_function" parameters="octet_1, octet_2, octet_3, octet_4" type="string">
value = "You inputed the IP: " + octet_1 + "." + octet_2 + "." + octet_3 + "." + octet_4
return (value)
</function>

~~ I can't remember if you use commas or semicolons for the parameters, meh

-------------------------------------

HK wrote:Alex has done a great job, it's impossible to alter~delete the quest engine core code (underlying~default~built-in code) through the GUI~Editor. (though, if you open up the actual quest's program folders and library files, and alter~delete them, then yes you can mess up quest).

What the GUI~Editor does, is to force you to click on the 'COPY' button (after you highlight something on the left side's 'tree of stuff', on the right side in the upper right corner, will be the 'copy' button), when you want to alter it's default~underlying~built-in code (such as the 'take' verb, for example). This creates a copy for you to alter it as you want, leaving~protecting the original code from your altering of it.

-------

By the way, to see all of the underlying~default~built-in code~stuff, in the GUI~Editor:

on the left side ( in the 'tree of stuff' ), at the bottom (lower left corner of computer monitor~screen), is:

Filter -> ~Show Library Files (this is a bit tricky to click on due to its popup getting in the way, argh)

you want to click on this (filter and then its 'show library files' or whatever it is called).

what this does is a toggle button, showing (or hiding) all the default~underlying~built-in code stuff as light greyed text in the left side's 'tree of stuff'


in the GUI~Editor: Filter -> Show Library Elements -> (find the 'HandleCommand' command) -> copy -> (alter~edit it)

or, drill into quest's actual program folders, finding the core library file (*.aslx), that has the 'HandleCommand' coding in it.

however, as to how 'entrenched' it is within all of the other underlying code, I've no idea... might be a simple fix... or a massive one.

MrFRZ
Ok, first I want to say thanks to all you guys trying to help me out, usually when I ask questions on a forum no one really responds, so this is awesome. Next, I just have a few things I need clarifying. I've kinda followed along with what Jay and HK were suggesting, in altering the game's code to not accept the periods as a new command. By doing this, it will allow the player to type "connect 123.456.7.89" and the ip to be saved in the #text# string right? Assuming that is what the outcome will be, I have found the HandleCommand Function and copied it like suggested to only alter this game. I can edit the function now, but the script is confusing, and although I can sort of follow along, I'm not sure what to change/delete to get the desired outcome.

I have included the function's code below and marked (with <<<<) what I THINK is the are of the period/fullstop part making it separate the text into commands. What should I change on this and am I on the right track?


handled = false
if (game.menucallback <> null) {
if (HandleMenuTextResponse(command)) {
handled = true
}
else {
if (game.menuallowcancel) {
ClearMenu
}
else {
handled = true
}
}
}
if (not handled) {
StartTurnOutputSection
if (StartsWith (command, "*")) {
msg ("")
msg (SafeXML (command))
}
else {
shownlink = false
if (game.echocommand) {
if (metadata <> null and game.enablehyperlinks and game.echohyperlinks) {
foreach (key, metadata) {
if (EndsWith(command, key)) { <<<<
objectname = StringDictionaryItem(metadata, key)
object = GetObject(objectname)
if (object <> null) {
msg ("")
msg ("&gt; " + Left(command, LengthOf(command) - LengthOf(key)) + "{object:" + object.name + "}")
shownlink = true
}
}
}
}
if (not shownlink) {
msg ("")
OutputTextRaw ("&gt; " + SafeXML(command))
}
}
if (game.command_newline) {
msg ("")
}
commands = Split(command, ".")
game.pov.commandmetadata = metadata
if (ListCount(commands) = 1) {
game.pov.commandqueue = null
HandleSingleCommand (Trim(command))
}
else {
game.pov.commandqueue = commands
HandleNextCommandQueueItem
}
}
}

HegemonKhan
mrfryz wrote:By doing this, it will allow the player to type "connect 123.456.7.89" and the ip to be saved in the #text# string right?


yes

<command>
<pattern>(#text# and~or #object#)</pattern>
<script>
// quest automatically sets: (#text# or #object#) -> (text or object) = your_input
</script>
</command>

example:

<command>
<pattern>color #text1# #text2# #text3#</pattern>
<script>
// you input: color red blue yellow
msg ("Colors: " + text1 + " " + text2 + " " + text3)
// it outputs~returns: Colors: red blue yellow
</script>
</command>

------------------------------

I'll leave Jay to help you with the HandleCommand, as I'm not ready in trying to understand and work with the underlying code, I'm not quite at its level of programming yet, laughs.

----------------------------

if you don't know about this, quest's 'wiki' coding documentation, here it is:

http://docs.textadventures.co.uk/quest/
http://docs.textadventures.co.uk/quest/elements/
http://docs.textadventures.co.uk/quest/ ... mmand.html

lots of info and code syntax help

MrFRZ
Ok, I get what you're saying and where you're going, and I've tested the code and it works. But I don't think this handles the problem of the period. With this, I can modify the code where anytime you connect to an ip you just put spaces instead of periods (123 34 2 instead of 123.34.2) and it will work like I want, but I'd rather have the periods in there too. I want the game to be immersive (as much as a text game can be at least), and having the periods taken out just seems odd and not real hacker-like if you understand what i mean, because ips are supposed to have periods. If I have to, i'll use this though, and I'm glad you taught me this, it gives me ideas for other planned games.

So when you say Jay will help me with the HandleCommand, is that where I fix the period issue and am able to enter connect 1.2.3 and not get these errors?

EDIT:
Would it be possible to create a new variable that wont handle periods like #text#?
I've noticed #object# acts differently than #text#.
For Example:
if I set the command pattern to -> connect #text#
then enter connect 1.2.3
the game returns:
I don't understand your command
I don't understand your command
I don't understand your command

if I set the command pattern to -> connect #object#
then enter connect 1.2.3
the game returns:
I can't see that

Since the top one gives 3 errors, it must mean the command is being run 3 times, one for each number, which is separated by the periods.
However the bottom one only gives 1 error, which means it must be counting 1.2.3 as one thing, or one object, meaning it's disregarding the periods.
If my logic is correct, and you can create new variables, would this be a simple workaround?

MrFRZ
Pertex wrote:

"jaynabonne"

The problem (and this is potentially a big one) is that, as far as I know, turn scripts execute after each *line* is processed, not each individual command. So if you had (for example) a chase game where the monster advances toward the player using a turn script, then the player could speed ahead by executing multiple commands in a single turn. To me, it's a big issue, even if your usage is more mundane than monsters. :)



So do you think the possibility of entering several commands in one line sould be removed?



In response to this feature being removed, I vote yes defiantly. I feel like hardly anyone knows about this command option, especially the majority who are coming to the site just to play and don't know coding. Also, since most don't know of this, people making text games will be usually unaware of the feature, and it allows a loophole in the game like stated earlier. It just allows one to cheat the turn system. Plus if you're entering commands, most likely you won't want to enter multiple commands at once, because you need to read what the game says afterwards. In all, I think this is more of a pain than a gain. Only causing troubles with coding, or cheating in games. I would rather it be removed in the next update, or at least a toggleable option, default set to off preferably.

jaynabonne
To modify HandleCommand to stop splitting the command line on periods, change this line:

        commands = Split(command, ".")

to this:

        commands = NewList()
list add(commands, command)

The original line is taking the command line and splitting it into a list of commands, splitting on any "."s. I changed it to create a list with just the command string in it.

Using an object name gives you the same problem (it still splits the command line on periods - reference my "Mr. XXXX" problem). So you really would need to do the above if you want it to be a single command like "connect 1.2.3.4".

jaynabonne
With regards to my other suggestion before of having just a "connect" command and then use "get input", it would be something like:

  <command>
<pattern>connect</pattern>
<script>
msg ("Enter the IP to connect to ")
get input {
ip_address = result
// do something with it
}
</script>
</command>

It turns it into a two step process (first type "connect" and then type the IP when prompted) but it would work around the problem.

Pertex
ok, I will add this for the next version

HegemonKhan
ah, cool Jay, so the fix is indeed simple as it is just limited to the single line, the separator character in the 'split' function, in the HandleCommand (and not also the 'get input' too, as you say this is a workaround), or can there still be problems elsewhere in the the core code if you change this code line?

for mrfrz' reference:

http://docs.textadventures.co.uk/quest/functions/
http://docs.textadventures.co.uk/quest/ ... split.html

MrFRZ
Ok sweet, thanks guys! Now I can continue my game! And the references helped too, I had skimmed the main tutorial to get the hang of using quest quickly, but I didn't know there was so much on this program elsewhere. Thanks again!

HegemonKhan
the code line resources used to be (not that long ago) on a wiki, which had a very convenient 'All code functions and scripts and etc' page, but this doesn't seem to have been or have been able to be transfered to the new webpages location: docs (google docs?). I really miss that page, as it was my 'Quest Coding Bible' resource page, laughs, having all of the coding lines there:

from my old post:

viewtopic.php?f=10&t=4466&p=29454&hilit=spell+library#p29454

other links:

01. viewtopic.php?f=18&t=2901 (equipment)
02. viewforum.php?f=18 (libraries: guides)
03. viewtopic.php?f=18&t=2660
04. viewtopic.php?f=18&t=2557
05. viewtopic.php?f=18&t=3515 (Sora's Stackable Library)
06. http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S) ~~~~~ 'my coding bible'
07. http://quest5.net/w/index.php?title=Cat ... t#mw-pages (page 2, range: S-Z) ~~~~~~ 'my coding bible'
08. http://quest5.net/wiki/How_to (guides, scroll down for the bottom half of guides too)
09. http://quest5.net/wiki/Main_Page
10. http://quest5.net/wiki/Tutorial
11. http://quest5.net/wiki/Simple_Combat_System_(Advanced) .
12. http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) (magic system, scroll down, especially at the very bottom are the links for Pixie's Spell library)
13. viewtopic.php?f=18&t=4057 (interface allowing for clicking hyperlinks for adjusting stats~attributes at a level up)

-------------------------------

another resource is the library files forum:

viewforum.php?f=18

and it's a bit hidden (as the 'how to' link) within the quest doc resource link, some guides:

http://docs.textadventures.co.uk/quest/guides/

Pixie (one of the biggest code~library contributors) has a Spell~Magic library (that is still buried~hidden) within the tutorial:

http://docs.textadventures.co.uk/quest/ ... types.html (scroll down a bit)

err, seems that pixie's spell library+demo files didn't get transfered over to the new docs pages...

it's not at the bottom of here anymore: http://docs.textadventures.co.uk/quest/ ... nced_.html

the old wiki link info from an old post of mine: 12. http://quest5.net/wiki/Using_Types_and_Tabs_(Advanced) (magic system, scroll down, especially at the very bottom are the links for Pixie's Spell library)

lastly, Chase has a good equipment ('Wearables') Library too (can find it within the library forum, see link above), and Pixie also has an equipment coding in his~her Simple Combat Library, Pertex has equipment coding too as well in his Combat Library.

some resources to help you learn quest and its coding more quickly

-----------

HK Edit:

P.S.

this can be very useful too (if you ever have to convert from an older quest version to a newer one):

http://docs.textadventures.co.uk/quest/ ... notes.html

version history of changes~upgrades to quest

--------

Sora's (item) Stackable Library: see #5 in my old 'other links' up near top of post.

R2T1
HegemonKhan wrote:the code line resources used to be (not that long ago) on a wiki, which had a very convenient 'All code functions and scripts and etc' page, but this doesn't seem to have been or have been able to be transfered to the new webpages location: docs (google docs?). I really miss that page, as it was my 'Quest Coding Bible' resource page


HK, check out the Reference section on this page

Pertex
I think, HK means this page: http://docs.textadventures.co.uk/quest/ ... tions.html

HegemonKhan
thanks Pertex and R2T1, I think the quest document pages covers everything that the old wiki 'all functions and etc' page covered, from my memory. I just wasn't too sure priorly to now, but I think all of the scripts~functions~etc are covered, transfered over.

I know on the main page, you got them split into their categories (at the top and also the left side) as: scripts, tutorial, functions, types, elements, etc, and both the normal function page and the alphabetically-ordered function page are helpful.

But, I still miss the format (multiple columns and etc) of the old wiki 2 (A-S and S-Z) pages of the 'all functions and etc', laughs. I'll get used to the new quest doc pages, with time.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums