Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411505 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 08:05:01 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperPlaytestingINJECTION - Untrusted, but in Python and not as good
Pages: [1]
Print
Author Topic: INJECTION - Untrusted, but in Python and not as good  (Read 1904 times)
Schilcote
Level 1
*


View Profile
« on: October 25, 2014, 06:09:51 PM »

I made a game for Pyweek 19. It's called INJECTION. It's a puzzle game which must be solved by "hacking" the game itself, through a built-in read-eval-print console. Of course, you can't just, say, move the door out of your way (except on the first level) - that'd be too easy.

You can download it from the Pyweek website here (direct link)the GameJolt page. It comes in Python 3 source and a Windows EXE.

Known bugs/issues:

  • Occasionally the program completely stops receiving input. This is a bug in the underlying graphics library; I've made a pull request but the maintainer doesn't seem to be paying any attention. Try not to move the mouse or move the window around while the program is waiting for keyboard input.
  • Non-QWERTY keyboards layouts may or may not be fixed. I have no clue.

The source release requires Python 3 and Pygcurse, which is on pip (pip install pygcurse). The game also requires at least basic Python programming knowledge to play, though it comes with a full walkthrough in the readme if you get stuck.

I'm mainly wanting to see if people can actually... solve the puzzles. Bug reports are good too.

SCROONSHOOTS:

« Last Edit: February 02, 2015, 05:32:42 AM by Schilcote » Logged
debugchicken
Level 1
*


Out of the sky, into the dirt.


View Profile
« Reply #1 on: October 26, 2014, 09:22:02 AM »

Please compile the exe.   Coffee
Logged
Schilcote
Level 1
*


View Profile
« Reply #2 on: October 26, 2014, 01:45:14 PM »

Properly-working EXE now available.
Logged
debugchicken
Level 1
*


Out of the sky, into the dirt.


View Profile
« Reply #3 on: October 26, 2014, 04:08:55 PM »

I tried to get in the injection console but I couldn't. I Press ";" (semicolon) but it just does not work. I guess this has something to do with my keyboard being ABNT2 (Brazillian standart)  . I tried every other key in the keyboard and no luck. And when I press "ç" button, for some reason, the game crashes.

Also it would be nice if you could post the direct link to the rar.
Logged
Schilcote
Level 1
*


View Profile
« Reply #4 on: October 27, 2014, 09:47:52 AM »

I tried to get in the injection console but I couldn't. I Press ";" (semicolon) but it just does not work. I guess this has something to do with my keyboard being ABNT2 (Brazillian standart)  . I tried every other key in the keyboard and no luck. And when I press "ç" button, for some reason, the game crashes.

Also it would be nice if you could post the direct link to the rar.

I'm not sure how much the owners of the site would like me doing that.

Sounds like "ç" is your equivalent of the semicolon key (for god knows what reason), and you're hitting the "surface quit" bug. Try re-extracting the archive, rebooting your computer, etc etc...

Did the arrow keys work? Escape?
Logged
Schilcote
Level 1
*


View Profile
« Reply #5 on: November 02, 2014, 11:45:56 AM »

New version out. I think I've fixed the "surface quit" bug; turns out what was happening was that an object was storing its own copy of the screen object, which of course becomes invalid across save-load cycles. So when the console tried to write to the screen, it tried to write to an essentially random area of memory and SDL noticed that and handed back a confusing error message.

I also may have partially fixed non-QWERTY compatibility. May not have. Essentially, it now looks for an actual semicolon being typed rather than the semicolon button, if that makes any sense.
Logged
Krux
Level 2
**



View Profile
« Reply #6 on: November 04, 2014, 08:35:45 AM »

please either come with a binary (for all platforms) or give a build that works out of the box for non python programmers.
Logged
Schilcote
Level 1
*


View Profile
« Reply #7 on: November 04, 2014, 07:07:05 PM »

please either come with a binary (for all platforms) or give a build that works out of the box for non python programmers.

There's a win32 binary in the zip.

Do you want a MacOS binary? That'll be kinda hard; I'm using a utility called cx_freeze to pack the executable, and it doesn't cross-build; if you want it to work on OS X you have to run the freezer on OS X, and I don't have a Mac.
Logged
Schilcote
Level 1
*


View Profile
« Reply #8 on: November 11, 2014, 02:05:46 PM »

New version out!

Remember when I said command history was impossible? Turned out, I lied. I did have to make a deal with the devil inspect module and do some truly disgusting stack hax, but I made it happen.

I've also added auto-update capabilities; it'll check for and download new versions of itself now. Woo.

You can get the new version from the links in the first post.
Logged
Quicksand-S
Level 10
*****


View Profile WWW
« Reply #9 on: November 11, 2014, 11:55:01 PM »

I had no idea what was going on.

-The first thing I walked up to asked for a 128-digit code, which I naturally didn't have, so I walked over to what I thought was a door and "injected" it. This brought up a Python console that said I could type "help", "copyright", etc. for info but everything I typed gave me an error (ex. "NameError: name 'help' is not defined"). I wasn't sure if that was part of the game or a real error.

-I tried randomly entering numbers for the 128-digit code and when I reached the end of the line, it started endlessly printing the same line of digits over and over until I pressed Enter.

-If I press Up to go through all my previous commands, characters from longer lines are left visible, but non-interactive.

-After reading up on Python stuff and trying a few things, I returned to the game from my browser and nothing was working. It didn't respond at all, even though the text-input cursor still flashed. I couldn't even Alt-F4, but closing the other window closed the game just fine.

Once I'd read up a bit about basic Python functions and gotten past the bugs, the game was great. It reminded me of HackThisSite. Really cool concept. I did have issues in level 1 where I thought I was interacting with the keycode thing, but nothing I did to it had any effect. I ended up just bypassing it altogether, but it bugs me that I don't know why changing the code or entering it didn't do anything.

Gravpads' little wavy line symbols don't face in the direction of the gravpad's effect.

It's nice that, even though I'd never used Python before, I could learn enough in a short time that I was able to enjoy the game. I didn't get far yet, but I plan to try some more. There seem to be some major issues, though. In level 2, I was going through previous commands and noticed the first character was missing. I pressed backspace and the game closed.

It would be nice to be able to disable music. It doesn't play 90% of the time anyway, so I'd rather just listen to my own music.

At the time of this writing, I've just gone back and beaten levels 2 and 3.


Edit: In level 4, trying to tightly surround the boulder caused a crash. It was a stupid solution to try, but it was the first thing I did. Later, I found that the way the gravpads worked was a bit unintuitive. No matter which direction they're pushing things, they always face up and affect what's in front of them. I spent a while trying to get the stupid thing to turn by rewriting functions, but nothing worked. Then I realized I didn't have to do much to it at all. (Highlight to see text hidden because of minor spoilers)


Edit: Level 6 is too easy. I just had to move one object and completely ignored anything else.

Edit: Level 7 is tricky. I feel like I'm missing some important info because of my lack of Python experience, and the game freezes up within a minute or two every time the window loses focus while I'm reading things online.

Edit: I won. Cheesy I did it in a way that probably wasn't intended, though. After I couldn't figure out what "func" to put as an argument for the upload function (Really curious about that), I decided to try something simpler. I just walked out of the room diagonally, and entered the exit diagonally. Done.
« Last Edit: November 12, 2014, 01:16:32 AM by Quicksand-S » Logged

My Old Game: We Want YOU - Join the Fight for Freedom

Twitter - Mostly comments on games, old and new.
Schilcote
Level 1
*


View Profile
« Reply #10 on: November 12, 2014, 03:48:47 PM »

I had no idea what was going on.

That's forgivable, I think. Tongue

-The first thing I walked up to asked for a 128-digit code, which I naturally didn't have, so I walked over to what I thought was a door and "injected" it. This brought up a Python console that said I could type "help", "copyright", etc. for info but everything I typed gave me an error (ex. "NameError: name 'help' is not defined"). I wasn't sure if that was part of the game or a real error.

I swear help() worked before. It just gives you the standard Python REPL help (which would be significantly better than nothing, actually, since it prints docstrings) anyway.

What's most worrying about this is that you thought the injection console was proximity-dependent. You must have figured it out by level... uhh, two (I suddenly regret being cute and zero-indexing my level names), though, so that's probably okay.


-If I press Up to go through all my previous commands, characters from longer lines are left visible, but non-interactive.

Yeah, that's an unfortunate side-effect of the hacks I had to put in place to even get command history working in the first place. The character graphics library I'm using completely takes over when you try to take in a string with it, and it doesn't expect to have its character buffer magically be overwritten out of nowhere, so bad things happen. I'm still trying to get in contact with the guy who wrote it.


-After reading up on Python stuff and trying a few things, I returned to the game from my browser and nothing was working. It didn't respond at all, even though the text-input cursor still flashed. I couldn't even Alt-F4, but closing the other window closed the game just fine.

Ah, that would explain all the spam in my update server log. Good thing I implemented autosaves!

This is another problem with the graphics library. It only pulls keyboard-related events out of the event buffer, so whenever you move the window, focus on something else, etc... the event buffer fills up and the program just stops responding. For now, just make sure you close the injection console before you tab away. Should be an easy fix now that I've made my blood pact with inspect, though - I'll work on it after dinner.


I did have issues in level 1 where I thought I was interacting with the keycode thing, but nothing I did to it had any effect. I ended up just bypassing it altogether, but it bugs me that I don't know why changing the code or entering it didn't do anything.

Yeah, I semi-purposely allowed for a variety of solutions to level 1. And by semi-purposely I mean I designed it before I realized some objects shouldn't be accessible from the console. Completely accidentally, in other words.

For future reference, the object expects its code parameter to be a string; you probably set it to an int. I thought I'd fixed it so either one would work, but apparently not.

It's nice that, even though I'd never used Python before, I could learn enough in a short time that I was able to enjoy the game.

Oh wow, I didn't think someone who didn't know Python would be able to play at all.

Can you tell me more about the process by which you figured it out? Did you get the hint in the level name? This is important stuff to know - it's clear that I'm going to have to implement a proper tutorial.


It would be nice to be able to disable music. It doesn't play 90% of the time anyway, so I'd rather just listen to my own music.

That shouldn't be hard (err, you realize Windows has program-by-program volume control built-in, right? Right click the volume control icon and click "Open Volume Mixer") but it sounds to me like the real issue is that you're running out the clock on the music. I'd assumed people would take two or three minutes per level, and set the music up accordingly; how long did it take you, just about?


Edit: In level 4, trying to tightly surround the boulder caused a crash. It was a stupid solution to try, but it was the first thing I did.

Wait, what exactly did you do? When did it crash? That's very strange - any exception that gets raised in the level logic gets caught and printed out the next time you bring up the injection console.


Later, I found that the way the gravpads worked was a bit unintuitive.

I take it you never figured out how to get the objects' docstrings. For future reference, if you ever pick the game up again, "print(whatever.__doc__)" where "whatever" is the name of a game object will print out a complete description of how the given game element works.

Can you think of any more visual way to convey the idea that the gravpad doesn't rotate? What made you think you had to rotate it in the first place?


Edit: Level 6 is too easy. I just had to move one object and completely ignored anything else.

Wait how - wait - oh god why didn't I think of that

You're saying you moved the pressure plate in front of the door, right? Yeah, you're not supposed to be able to do that.

Edit: Level 7 is tricky. I feel like I'm missing some important info because of my lack of Python experience, and the game freezes up within a minute or two every time the window loses focus while I'm reading things online.

No, you were missing important info because you accidentally cheated through level 6 (5)... Tongue

Edit: I won. Cheesy I did it in a way that probably wasn't intended, though. After I couldn't figure out what "func" to put as an argument for the upload function (Really curious about that), I decided to try something simpler. I just walked out of the room diagonally, and entered the exit diagonally. Done.

... Unless you're talking about the last level (it sounds like this paragraph is about it, since that's the only one with an "upload function"), which if you start counting from one instead of zero would be level 8. In which case, yeah, the level is literally unsolvable if you haven't figured out docstrings... or even if you have, actually, since functions normally don't have them.

In my defense, the readme tells you all this stuff (that was sarcasm, I realize no-one reads readmes)...
except of course you probably didn't even know the readme was there, since it's mixed in with all the crap cx_freeze generates when it makes a standalone executable. See, all the problems are in someone else's code! My code is flawless!

... also what the hell? You can't move diagonally. There's an entire joke in the readme based around that fact.

Anyway, thanks for the feedback. Now if only someone would tell me whether or not I've fixed non-QWERTY support...
Logged
Quicksand-S
Level 10
*****


View Profile WWW
« Reply #11 on: November 12, 2014, 07:59:15 PM »

I swear help() worked before. It just gives you the standard Python REPL help (which would be significantly better than nothing, actually, since it prints docstrings) anyway.

I wasn't even typing it as "help()", just "help" like the message told me to, but yeah, it doesn't work.

Quote
For future reference, the object expects its code parameter to be a string; you probably set it to an int. I thought I'd fixed it so either one would work, but apparently not.

I thought of that, but wasn't sure how to do it because of my lack of Python experience.

Quote
Oh wow, I didn't think someone who didn't know Python would be able to play at all.

Can you tell me more about the process by which you figured it out? Did you get the hint in the level name?

I may not have used Python, but I've used maybe nine or ten other programming languages, so that helped me to guess other things once I knew about the "dir()" function. I found out about dir() from stackoverflow or something and only noticed later that you mentioned it in the Readme.

Quote
That shouldn't be hard (err, you realize Windows has program-by-program volume control built-in, right?

Yes, I do, but I don't like to use it. I guess I like settings for programs to be self-contained.

Quote
I'd assumed people would take two or three minutes per level, and set the music up accordingly; how long did it take you, just about?

No idea. At least two or three of the levels took me under a minute each, but the rest had me reading online about how Python works. I spent a decent amount of time looking into functions and how Python handles objects, variable assignments, bound methods, etc. with the game still running in the background. In one level, I thought I had to write my own function and assign it to an object (in order to make it spit out different numbers to the game), so I spent way too much time on that. I would say that looping music is pretty important, in any case. Sometimes people think they have a solution and spend a while trying to make it work before realizing there's another way.


Wait, what exactly did you do? When did it crash? That's very strange - any exception that gets raised in the level logic gets caught and printed out the next time you bring up the injection console.

What I did was put one gravpad at (21,19) and one at (21,17), when the boulder was still bouncing in between. This was before I realized I should probably stop the boulder. No exception message, just an instant crash.


Quote
I take it you never figured out how to get the objects' docstrings. For future reference, if you ever pick the game up again, "print(whatever.__doc__)" where "whatever" is the name of a game object will print out a complete description of how the given game element works.

I did find that at one point, but didn't realize I could do it with any object. I just found the default/base-level one.

Quote
Can you think of any more visual way to convey the idea that the gravpad doesn't rotate? What made you think you had to rotate it in the first place?

It does rotate, functionally, just not visually. That was what threw me off. I was changing which way it would send things, so it made sense to me that the change would also be shown visually by those little waves.


Quote
Edit: Level 6 is too easy. I just had to move one object and completely ignored anything else.

Wait how - wait - oh god why didn't I think of that

You're saying you moved the pressure plate in front of the door, right? Yeah, you're not supposed to be able to do that.

I'm not sure if I got the level number right, so I'll clarify here. In one level, I put a turret onto a pressure plate after putting the plate in front of the door didn't work (I got kicked out by the door closing each time). What I did on another level was just move the one boulder I had control over and put it on the plate up in the top right that I had no direct access to, so I didn't have to manipulate gravity or anything.

Quote
... also what the hell? You can't move diagonally. There's an entire joke in the readme based around that fact.

Yeah, I was talking about the last level and yep, you can move diagonally. You have to time it well, pressing both keys almost simultaneously, but it's actually easy to pull off.

I'll look into the docstring stuff. I do want to solve that last level properly. This game is great. I hope you're still planning on adding levels to it.
Logged

My Old Game: We Want YOU - Join the Fight for Freedom

Twitter - Mostly comments on games, old and new.
Schilcote
Level 1
*


View Profile
« Reply #12 on: November 13, 2014, 03:26:19 PM »

New version up on the autoupdate server. No new levels or anything; I just addressed some of Quicksand's bug reports and suggestions. The game will update itself automatically next time you start it up.
Logged
BomberTREE
Level 9
****



View Profile
« Reply #13 on: January 31, 2015, 10:11:02 PM »

This sounds so hard haha! Going to check it out when I'm done watching a movie  Smiley
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic