Back to front pageView on Hacker News (opens in a new tab)Show HN: Untrusted, a JavaScript adventure game you play by modifying its source (opens in a new tab)alex.nisnevich.com555 pointsby alnis (on Hacker News)12 years agoComments (235) 72 threadsShow all commentsShowing thread 4 of 72[-]jpolitz12 years ago1 reply#This worked for the whole first chapter for me (and has some obvious further applications): startLevel["constructor"]("m", "console.log(m);" + "var old = m.placeObject;\n" + "m.placeObject = function(x,y,t) { \n" + "console.log(t);\n" + "if (t === 'exit' || t === 'computer') {\n" + "console.log('adding' + t);\n" + "return old['ca' + 'll'](m, x,y,t) }};")(map); EDIT: I wonder if you could wrap the user's code in, e.g. https://code.google.com/p/es-lab/wiki/SecureEcmaScript, and use this to gamify finding bugs in that sandbox :-)[-]jacktoole112 years ago1 reply#nice!similarly, var oldPlaceObject = map.placeObject; var newPlaceObject = function(x, y, type) { if (type !== 'block') { map.placeObject = oldPlaceObject; map.placeObject(x, y, type); map.placeObject = newPlaceObject; } }; map.placeObject = newPlaceObject; was my solution to multiple levels ;).kybernetikos12 years ago#I also had to overwrite the map.verifyXitems (or whatever it was) to return true regardless.
Show HN: Untrusted, a JavaScript adventure game you play by modifying its source (opens in a new tab)alex.nisnevich.com555 pointsby alnis (on Hacker News)12 years ago
jpolitz12 years ago1 reply#This worked for the whole first chapter for me (and has some obvious further applications): startLevel["constructor"]("m", "console.log(m);" + "var old = m.placeObject;\n" + "m.placeObject = function(x,y,t) { \n" + "console.log(t);\n" + "if (t === 'exit' || t === 'computer') {\n" + "console.log('adding' + t);\n" + "return old['ca' + 'll'](m, x,y,t) }};")(map); EDIT: I wonder if you could wrap the user's code in, e.g. https://code.google.com/p/es-lab/wiki/SecureEcmaScript, and use this to gamify finding bugs in that sandbox :-)
jacktoole112 years ago1 reply#nice!similarly, var oldPlaceObject = map.placeObject; var newPlaceObject = function(x, y, type) { if (type !== 'block') { map.placeObject = oldPlaceObject; map.placeObject(x, y, type); map.placeObject = newPlaceObject; } }; map.placeObject = newPlaceObject; was my solution to multiple levels ;).
kybernetikos12 years ago#I also had to overwrite the map.verifyXitems (or whatever it was) to return true regardless.
Comments (235) 72 threads
Show all comments
Showing thread 4 of 72
similarly,
was my solution to multiple levels ;).