Colossal Caves Adventure - accessing a data source using javascript

I played with the idea of ​​creating a javascript version of the original Colossal Caves Adventure coming to teach myself the language. The original adventure data file can be found here -

http://jerz.setonhill.edu/if/crowther/

I hope an experienced javascripter can offer me a better way to save and access a text data file (only a few hundred lines long). At the moment, I’m thinking about inserting text into a hidden element on an html page and accessing it this way, but I know that it lacks elegance. What are your thoughts?

+3
source share
2 answers

AJAX, . - , AJAX. ( JS, AJAX)

, <input type="hidden" s. JavaScript , id, . .

<input type="hidden" name="r121" value="You come upon a fissure" />

r 121: " "

+1

javascript, , script. .

, , advdat.js, :

advdat = {  1: "YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK\
                BUILDING . AROUND YOU IS A FOREST. A SMALL\
                STREAM FLOWS OUT OF THE BUILDING AND DOWN A GULLY.",
            2: "YOU HAVE WALKED UP A HILL, STILL IN THE FOREST\
                THE ROAD NOW SLOPES BACK DOWN THE OTHER SIDE OF THE HILL.\
                THERE IS A BUILDING IN THE DISTANCE.",
            3: "YOU ARE INSIDE A BUILDING, A WELL HOUSE FOR A LARGE SPRING.",...
          };

script . advdat.

0

Source: https://habr.com/ru/post/1795948/


All Articles