Targeting objects

Hey all. So, I’m more of a writer than a developer, but I had the idea to make a puzzle game where you’re a hacker of sorts, and you collect addresses and data to figure out what values you need to change on the network, and how, to progress and get more information to breach the network further and get deeper into this facility. The ideal is that it’s a sort of sandbox where the player can tinker with anything, even the game itself for the more cunning players.

The code for the tool right now is thus:

[code]understand “interface” as hacking.
understand “hack” as hacking.
addresstarget is text that varies. addresstarget is usually “00000001”.
attributevalue is text that varies. attributevalue is usually “false”.

hacking is an action applying to nothing.

Carry out hacking:
say “[bold type]Your A.H.D buzzes, asking for a digital address to target. [roman type]”;
get typed command as playerinput;
now addresstarget is playerinput;
say “[bold type]’’[addresstarget]’’ blinks on the screen, awaiting a value input: [roman type]”;
get typed command as playerinput;
now attributevalue is playerinput;
say “[bold type]Confirm change at address ‘’[addresstarget]’’ to ‘’[attributevalue]’’.[roman type]”;
if player consents:
say “’’[addresstarget]’’ changed to ‘’[attributevalue]’’.”;
say “You exit out of the hacking interface.”;[/code]

The “???” is where the actual value edition would happen, but a simple now is statement isn’t going to cut it. I’ve been rifling through the documentation trying to figure out a solution for hours, but my search hasn’t yielded anything. While I could set up more simplified statements for each individual object, that’s messy and inefficient considering the nature of this game, and that there could be over 100 objects with changeable values. To keep it brief, how can I, if at all possible target the object the player inputs and change its value to their second input while keeping the tool modular?

Checking out “get typed command as playerinput,” I take it that you’ve already dropped in the code from Flexible Survival that makes that work? That’s not a standard phrase but it seems to come from here. I think you need playerinput to be described as a text variable for it to work. That code was from an older version of Inform so I wouldn’t guarantee that it works.

As for the main question… depends on what you’re trying to do and how you’re trying to implement it. If you want to have addresstarget be interpreted as an object in the model world, getting a text snippet and converting it to an object name is not at all natural in Inform. In that case it’d probably be better to try to implement a command that accepts things like “HACK ROCK TO BLUE”–that’ll let the game understand “rock” as the rock, if you like. Or if you have something where the rock is object 32 and the player has to figure that out and type “HACK 32 TO BLUE” you can do that too, it’s possible to have a command understand a number and you could connect numbers to the objects.

If the hacking isn’t connected to objects but just to some address somewhere, one thing you might be able to do is implement a table with the allowable addresses in one column and the things you hack it to in another column. Then you could look up addresstarget in one column and change the other entry to attribute value.

Anyhow, I can try to come up with some more specific code for some of these things, if you have an example of what you want to accomplish.

As for tinkering with the game itself, that sounds yikes difficult particularly in Inform… which also means it’d be fun to discuss, if you have some more ideas as to exactly what you want to do there.

Yeah, I should probably have mentioned that in the OP. That miraculous little chunk of code works, and the tool grabs and prints the values fine, just inform throws errors when I try to actually give it teeth as it were, almost undoubtedly because of my aforementioned lack of experience.

The code in mine that makes playerinput tick is:

[code]To get typed command as (S - a snippet): (-
KeyboardPrimitive(buffer, parse);
{S} = 100 + WordCount(); -)

playerinput is a snippet that varies.[/code]

And here’s the tool printing inputs as intended, just not actually able to change anything of course:

Your A.H.D buzzes, asking for a digital address to target: proxylocation

““proxylocation”” blinks on the screen, awaiting a value input: debug

Confirm change at address ““proxylocation”” to ““debug””.yes

““proxylocation”” changed to ““debug””.

Yeah, the addresses aren’t literally objects but values – just, the documentation and what I read online discouraged me from calling them values because inform doesn’t like values that aren’t of a kind. So every address is JUST the boolean, just the number, just the text, etc. 00000001 is just a truth state with no other attributes, and the other addresses and values that the tool would be able to modify would be similar.

In summary, when I say tinkering with the game itself, it’s more like… the tool can do only what it’s designed to do – that is, edit values similar to the addresses… but it doesn’t necessarily have restrictions on the specific values you can hit. I want to say it’s kind of like you’re in the matrix, the game recognizes that the world you’re in is itself digital, and the biggest hurdle to what the proxy can do is what you personally know. If you find, for instance, the value for the proxy’s position, you can change that value and teleport around the facility to the rooms you know the name of. I might even have a few rooms sitting around that are easter eggs or special endings for that very purpose(Imagine teleporting yourself into a room called Debug only to hear a voice saying “Bug found, debugging.” and getting incinerated or somesuch).

I’m not the greatest at explaining myself, so I’ll show you an example of the kinds of values I’d hope for the tool to be able to hit:

facility power level is a number that varies. facility power level is usually 100. facility breaker state is a truth state that varies. facility breaker state is usually true. lobby scroller display is text that varies. lobby scroller display is usually "MindSec, your life beyond life!"

So I’d be able to set facility power level to any number I want, flip the facility breaker state between true and false, and input my own text for the lobby scroller display. Past that, I can just create new rules to handle special cases. Oh, and I like your structure of “hack x to y” better than my original setup for certain. I can see the tool as it now getting a bit tedious with extended use.

Though, I can’t take a snippet or text and directly patch it onto a number or truth state. Seems like a simple case of needing an if else chain to check and automagically use value converters or state that the given value is impossible(eg “facility breaker state” can’t be set to “12” because it is a boolean.").

On the front end, the player inputs, say, “hack facility power level to 1000”, the output is “Confirm change of ‘facility power level’ to 1000.”, if player consents then the change is executed and they receive a confirmation of “facility power level successfully changed to 1000”.

Hopefully that’s a good conceptualization of it.

Thank you so much for your time and help so far! I’m just a stranger that came to this forum out of the blue asking about this, and you didn’t hesitate to help out. That means a lot. :slight_smile:

I have to go to sleep and might not be able to talk too much about this tomorrow, but instead of trying to patch the snippet to a truth state yourself it’s easier to get this done in the parser. You can do something like this:

[code]A numerical address is a kind of thing. [or maybe object]
A numerical address has a number called quantity.

Numberhacking is an action applying to one visible thing and one number. Understand “hack [any numerical address] to [number]” as numberhacking.

Carry out numberhacking: Now the quantity of the noun is the number understood.
Report numberhacking: Say “Value of [noun] set to [number understood].”[/code]

Then if “000001” is the name of a numerical address, the game will automatically understand “HACK 000001 to 54” as referring to it.

The issue here is that you have other things you don’t want to set to numbers… but you can make other actions that apply to different kinds of address. (I think truth states may require a kludge, where you need to create dummy objects named “true” and “false,” because Inform doesn’t directly understand truth states… but that only requires dealing with two things.)

Anyway, I can elaborate on this later, but this shows you the kind of thing you can do pretty naturally.

(And no probs! Talking about Inform code is fun for me.)