Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: "Inventory" for HTML RPG  (Read 43597 times)

0 Members and 1 Guest are viewing this topic.

Dilbert

    Topic Starter
  • Moderator


  • Egghead

  • Welcome to ComputerHope!
  • Thanked: 44
    "Inventory" for HTML RPG
    « on: March 19, 2006, 04:36:44 PM »
    *Caution: Long introduction follows*

    When I was learning HTML, my method of learning about text, hyperlinks and basic formatting was the Choose Your Own Adventure games. Inspired by the many books, I have created several versions that are too small to publish or were so full of cliches that I would have been ridiculed. I love doing RPGs of this kind; it provides a challenge for both the writer and the reader.

    Each installment, I try to add something new. CYOA I was a 15-page total (including wins and losses) mini-adventure. CYOA II was never actually undertaken, as I tried to bite off things I'm not sure I can chew today.

    CYOA III was built entirely in FrontPage but didn't have too much more. Of note was the pictures, background music, and buttons. I tried including an inventory, but failed to find a method. I had one, but it was actually a decoration at best; not a fully functioning inventory system. However, I was able to get away with it as it was relatively unimportant. (Bolded part is important to note)

    CYOA IV was the first version to have multiple storylines but didn't require the completion of both. In 3, if you didn't complete both missions, you lost. This took a little of the CHOOSE out of it. Alternate storylines provided a gameplay that myself and my sisters enjoyed.

    I am beginning the planning stages for a CYOA V. It will have all of the innovative new features I had or wanted to have before. (This one I will not build in FrontPage, but I will use it just to steal button images ;)) One of the features that I desperately wanted to integrate into the system was a fully functional inventory system. This will make the game more dynamic by allowing more choices, and more chances to screw up.

    For example, in my last installmnent featuring the Great Pyramid, whenever the main character and his (your) friend needed to fight, there was always a sword convienently handy. I was required to do this because, with my knowledge at the time, if I wanted to do an inventory system, I'd have to exponentially increase the number of pages: One for with no items, one for with sword only, one for with bow only, one for both... too much of a headache. My project was nearing the 100-page mark as it was. So I had to bite the bullet and accept the inconsistiencies of my game. It wasn't easy.

    My other desired idea also came from CYOA IV. In the latter half of the main adventure, the two main characters are captured by a mad long-dead pharaoh who asks "morality" questions and tortures you or your companion, depending on what answer you gave. Four questions would be asked, and each bolt would take off 25% health. To make it more challenging, your friend is at 50% since he was captured first, and you have to balance to keep both of you alive. Not all that challenging, but it was designed with my then-9 year old sister in mind. (The torture scenes were not graphic and had no pictures at all; just a lighting sound ripped from Star Wars)

    What's the problem with the above paragraph? Well, in order to set up a health system, I had to create what I called a "knot of pages" with you at 100% friend at 50%, you at 75% him at 50%... you get the idea. I know there's an easier way to do all of this, but I didn't then.


    So, after all of that, you have to know exactly what I want and how I want to apply it. What I want is to create an inventory system that works on multiple pages. I think it will require frames to get it to stay from page to page, but that doesn't get the actual inventory going, obviously. The other thing I want is a health system, so I can damage players or NPCs as needed, or restore their health. I know it's going to require something along the lines of JavaScripting, and I'm not afraid of that, but I am not sure where to begin. What I need is advice on how to do this.

    To test out any replies that I'm getting, I will set up test page(s) with buttons to decrease a health bar and one to take in and out imagined inventory items. I'm sorry for the possibly excessive background, but I wanted to make sure every card was on the table. :)
    « Last Edit: March 19, 2006, 04:38:24 PM by Timothy_Bennett »
    "The geek shall inherit the Earth."

    Rob Pomeroy



      Prodigy

    • Systems Architect
    • Thanked: 124
      • Me
    • Experience: Expert
    • OS: Other
    Re: "Inventory" for HTML RPG
    « Reply #1 on: March 19, 2006, 09:37:54 PM »
    If you're serious about doing this with javascript, then pick up the nearest pen on your desk and jab yourself smartly in the eye with it, because honestly it would be less painful.  Javascript is okay with cookies, which you can use to carry variables over from one page to the next, but it is not great at truly dynamic content.

    If you've managed to persuade your mother that it is safe to host your own web site, then now would be a brilliant time to learn PHP, which you can install and run on your server.

    Incidentally, I remember your signature said something about the nightmare your parents had when you discovered the control panel.  Could this explain their reluctance to let you host a web site?  ;)
    « Last Edit: March 19, 2006, 09:38:37 PM by robpomeroy »
    Only able to visit the forums sporadically, sorry.

    Geek & Dummy - honest news, reviews and howtos

    Dilbert

      Topic Starter
    • Moderator


    • Egghead

    • Welcome to ComputerHope!
    • Thanked: 44
      Re: "Inventory" for HTML RPG
      « Reply #2 on: March 19, 2006, 10:55:36 PM »
      My mom said I can put something on the Internet when it has more value than a "hello world" type site. Truly, that's what the site I was making was. Oh well. She's still not convinced, but if I can show her something of great value, then it might be the leverage I need. If not... well, my sisters can play this at least. :)

      Quote
      If you're serious about doing this with javascript, then pick up the nearest pen on your desk and jab yourself smartly in the eye with it, because honestly it would be less painful.  Javascript is okay with cookies, which you can use to carry variables over from one page to the next, but it is not great at truly dynamic content.

      LOL. I wasn't trying to insinuate that I was going to use JavaScript no matter what. I had the feeling it was possible, so I mentioned it. I could also use VBScript if that can work, but so many people have that off to protect their systems that it's useless.

      Quote
      If you've managed to persuade your mother that it is safe to host your own web site, then now would be a brilliant time to learn PHP, which you can install and run on your server.

      Question: Can that work offline as well? I'm a big fan of being able to test things out offline before launching them, and I'd like to be able to play this offline just in case I'm still rejected. Which I doubt will happen, knowing my mother. ;)

      I'd be happy to learn whatever works to get the game running as efficiently as possible. I'm not a big fan of things that take up upwards of 400 MB if I can help it, and I'm sure that I could help it on my other games.

      Anyway, if PHP is the way to go, I'll Google some tutorials. I did just a second ago, and it seems to be able to function offline, like JavaScript. I hope it works offline, anyway. Just another language to pseudo-learn. :D

      Quote
      Incidentally, I remember your signature said something about the nightmare your parents had when you discovered the control panel.  Could this explain their reluctance to let you host a web site?  

      Her big fear is still hackers. And they are indeed a threat to computers everywhere, but my router seems to be doing excellently at keeping us safe. :)

      [edit]PHP appears like a cross between Visual Basic, JavaScript, and DOS Batch files. What do you know - the three languages I know best (Not counting English). This can't be too hard... (famous last words...)[/edit]
      « Last Edit: March 19, 2006, 11:19:50 PM by Timothy_Bennett »
      "The geek shall inherit the Earth."

      Rob Pomeroy



        Prodigy

      • Systems Architect
      • Thanked: 124
        • Me
      • Experience: Expert
      • OS: Other
      Re: "Inventory" for HTML RPG
      « Reply #3 on: March 20, 2006, 03:19:10 AM »
      Quote
      My mom said I can put something on the Internet when it has more value than a "hello world" type site.
      Surely she understands that all great programmers begin with "hello world"!!!  It's part of the learning process...
      Quote
      Question: Can [PHP] work offline as well?
      That depends on what you mean by "offline".

      PHP sits on the web server, and processes requests made to the web server, modifying the HTML output as required.  If your web server were offline, and you were merely accessing cached versions of pages, then no, PHP would not help.

      If your web server is working however, then the dynamic content will be generated.  And this is irrespective of whether the end user is on your LAN or beyond your router.

      So basically, you have the opportunity to test fully your site before you open up the relevant port on your router and let the world at large see your efforts.  I think that was what you were hoping.  :)
      Quote
      Her big fear is still hackers.
      Again, if she is so concerned about this, perhaps HER computer should not be connected to the internet at all.  Does she understand PC security?  No system is 100% safe.  But then that is just as true OFF the internet, what with identity theft criminals rummaging through your rubbish and all...
      Quote
      PHP appears like a cross between Visual Basic, JavaScript, and DOS Batch files.
      Well I can sort of see the point.  PHP is not strictly-typed (like for example C), so it can be almost as forgiving as javascript, and it shares a lot of functionality with VB.  I'm not sure the PHP developers would welcome the comparison with VB though!  PHP really excels at web-based taks, particularly since they involve lots of text processing.  This is where PHP is highly optimised.
      Quote
      This can't be too hard... (famous last words...)
      Hmm...

      At least you can come back here if you get stuck; plus there are LOADS of PHP resources out there, as you have already discovered.  If you go for PHP, bookmark >the online manual< and forget about using web design software for most of your development.  Go for something like PHPEditorIDE or Notepad++.  PHPEditorIDE is particularly good for starting off, because it includes PHP and CSS context-sensitive help.  I prefer Notepad++ though, because it is more robust.  Both provide syntax highlighting etc.  Both are free (naturally).  :)
      « Last Edit: March 20, 2006, 03:19:40 AM by robpomeroy »
      Only able to visit the forums sporadically, sorry.

      Geek & Dummy - honest news, reviews and howtos

      Dilbert

        Topic Starter
      • Moderator


      • Egghead

      • Welcome to ComputerHope!
      • Thanked: 44
        Re: "Inventory" for HTML RPG
        « Reply #4 on: March 20, 2006, 08:14:27 AM »
        Quote
        Surely she understands that all great programmers begin with "hello world"!!!  It's part of the learning process...

        Of course, she's only saying that I can't publish it since it's so small. I gotta agree with her on that one; it serves no purpose. However, I've been doing HTML for a few years and know my way around it enough to produce a great Web-based game. It's just getting all the features to work that are the issue.

        Quote
        That depends on what you mean by "offline".

        PHP sits on the web server, and processes requests made to the web server, modifying the HTML output as required.  If your web server were offline, and you were merely accessing cached versions of pages, then no, PHP would not help.

        If your web server is working however, then the dynamic content will be generated.  And this is irrespective of whether the end user is on your LAN or beyond your router.

        So basically, you have the opportunity to test fully your site before you open up the relevant port on your router and let the world at large see your efforts.  I think that was what you were hoping.  :)

        Right now, I've got just HTML pages, CSS files and the like sitting on my computer. How do I put these files physically on the server so I can test them?

        Quote
        Again, if she is so concerned about this, perhaps HER computer should not be connected to the internet at all.  Does she understand PC security?  No system is 100% safe.  But then that is just as true OFF the internet, what with identity theft criminals rummaging through your rubbish and all...

        LOL. She's breaking down, I just need one more piece, I think, to have her let me do it. :D

        Quote
        Well I can sort of see the point.  PHP is not strictly-typed (like for example C), so it can be almost as forgiving as javascript, and it shares a lot of functionality with VB.  I'm not sure the PHP developers would welcome the comparison with VB though!  PHP really excels at web-based taks, particularly since they involve lots of text processing.  This is where PHP is highly optimised.

        Oh, I know it's different. It's just that I see similarities:

        • The For, Do, and Do While loops are similar in nature to VB and syntax is like JavaScript
        • "echo" is like the "echo" in DOS BATCH files.
        • Mosy syntax is similar or identical to JavaScript.

        Frankly, I don't care what the PHP programmers say; it looks like it!
        Quote
        Hmm...

        At least you can come back here if you get stuck; plus there are LOADS of PHP resources out there, as you have already discovered.  If you go for PHP, bookmark >the online manual< and forget about using web design software for most of your development.  Go for something like PHPEditorIDE or Notepad++.  PHPEditorIDE is particularly good for starting off, because it includes PHP and CSS context-sensitive help.  I prefer Notepad++ though, because it is more robust.  Both provide syntax highlighting etc.  Both are free (naturally).  :)

        *bows* Thank you again.
        "The geek shall inherit the Earth."

        Rob Pomeroy



          Prodigy

        • Systems Architect
        • Thanked: 124
          • Me
        • Experience: Expert
        • OS: Other
        Re: "Inventory" for HTML RPG
        « Reply #5 on: March 20, 2006, 08:53:07 AM »
        Quote
        Right now, I've got just HTML pages, CSS files and the like sitting on my computer. How do I put these files physically on the server so I can test them?
        You installed Apache, didn't you?  My Apache experience is all on *nix systems, so bear with me.  I think the default web root is at C:\Program Files\Apache Group\Apache2\htdocs.  That's where your files go.

        Later on, it would be desirable to edit the Apache config file, and put your webroot somewhere else - typically a top level directory on a different partition/hard drive.  This slightly enhances security and tends also to enhance performance.  But you can save that for another day.  Apache config file editing is a black art and takes some getting used to.
        Only able to visit the forums sporadically, sorry.

        Geek & Dummy - honest news, reviews and howtos

        Dilbert

          Topic Starter
        • Moderator


        • Egghead

        • Welcome to ComputerHope!
        • Thanked: 44
          Re: "Inventory" for HTML RPG
          « Reply #6 on: March 20, 2006, 04:27:32 PM »
          Quote
          Quote
          Right now, I've got just HTML pages, CSS files and the like sitting on my computer. How do I put these files physically on the server so I can test them?
          You installed Apache, didn't you?  My Apache experience is all on *nix systems, so bear with me.  I think the default web root is at C:\Program Files\Apache Group\Apache2\htdocs.  That's where your files go.

          Later on, it would be desirable to edit the Apache config file, and put your webroot somewhere else - typically a top level directory on a different partition/hard drive.  This slightly enhances security and tends also to enhance performance.  But you can save that for another day.  Apache config file editing is a black art and takes some getting used to.

          Ok, the folder exists. Inside the folder is a bunch of files I've never seen before. Extensions incluse .ISO-RU, .NN, .BIG5, and a ton of other files I don't recognize. A few GIFs and PNGs. I did a search inside the Apache folder and got a ton of .h files. I think one of them will have the data I want, but to me it looks like the grails at Indiana Jones and the Last Crusade. The true file... will give me a functioning server... the FALSE file... will take it from me...

          I can open these files with Dev C++. Unfortunately, I barely know anything about C++, not even enough for a "Hello World" program. All my experience has been in VB. Which file is the true file? And by that I mean the one that allows me to change the path.

          I do have the hard drive space needed to partition my drive, but I don't have any programs that can do that. Also, if I were to repartition it back to one drive, would I lose all my data or only the one that I got rid of? Just a question that needs asking. If this works I'll have no reason to remove it, it's juat a thought.
          « Last Edit: March 20, 2006, 04:29:24 PM by Timothy_Bennett »
          "The geek shall inherit the Earth."

          Rob Pomeroy



            Prodigy

          • Systems Architect
          • Thanked: 124
            • Me
          • Experience: Expert
          • OS: Other
          Re: "Inventory" for HTML RPG
          « Reply #7 on: March 20, 2006, 11:03:32 PM »
          The htdocs folder shouldn't really have much in it on a clean install.  Is there any index.* file in there?  The files may well just be introductory files, with various different translations.  (.big5 idenitifies a Chinese version, for example.)

          You can safely delete everything in the htdocs folder anyway (or move the contents elsewhere).  Just plop in a basic index.html, and then browse to http://127.0.0.1 to verify that it's working.

          You'll probably find the configuration file httpd.conf in a folder called "etc".

          Partitioning is not my speciality; it may not be possible to merge two partitions, so I wouldn't count on it.  Ask the other guys around here.  :)
          « Last Edit: March 20, 2006, 11:04:55 PM by robpomeroy »
          Only able to visit the forums sporadically, sorry.

          Geek & Dummy - honest news, reviews and howtos

          Dilbert

            Topic Starter
          • Moderator


          • Egghead

          • Welcome to ComputerHope!
          • Thanked: 44
            Re: "Inventory" for HTML RPG
            « Reply #8 on: March 20, 2006, 11:30:57 PM »
            There are index.html.en, and index.html.et, and a lot of stuff like that. For cleanliness' sake, I deleted the folder's contents but will keep the recycled files just in case. :)

            Oh, cool! I can see my work on the web! And PHP will work here, correct? Sweet. This rocks; it's freaking awesome! Now all I have to do is finish the game, and open it to the public.

            *monotone* I rock. Out loud. */monotone*

            Sorry, that was just too cool. ;D Now that that bit's out of the way, I wonder exactly what PHP code would be good for something like this. I'll check out those tuts. :)
            « Last Edit: March 20, 2006, 11:33:48 PM by Timothy_Bennett »
            "The geek shall inherit the Earth."

            Rob Pomeroy



              Prodigy

            • Systems Architect
            • Thanked: 124
              • Me
            • Experience: Expert
            • OS: Other
            Re: "Inventory" for HTML RPG
            « Reply #9 on: March 21, 2006, 01:14:59 AM »
            Yes, you're up and running.  Now for the web page that your mother loves so much: helloworld.php


            <html>
            <body>
            <?php

              // If php is running correctly, this will display "Hello world!"
              echo '<p>Hello world!</p>';

            ?>
            </body>
            Only able to visit the forums sporadically, sorry.

            Geek & Dummy - honest news, reviews and howtos

            Rob Pomeroy



              Prodigy

            • Systems Architect
            • Thanked: 124
              • Me
            • Experience: Expert
            • OS: Other
            Re: "Inventory" for HTML RPG
            « Reply #10 on: March 21, 2006, 01:24:22 AM »
            As an aside, here's an example of the kind of thing you can do with PHP.  The following is a PHP script, not an image file:



            If you refresh this page later on, you'll see the hands update.  Note that the clock is showing UK time!  I can't take the credit for this clock script by the way.  I was about to write such a script, but I hate re-inventing the wheel, so I had a quick look for a PHP analogue clock, and I found >this<.
            « Last Edit: March 21, 2006, 01:27:20 AM by robpomeroy »
            Only able to visit the forums sporadically, sorry.

            Geek & Dummy - honest news, reviews and howtos

            Dilbert

              Topic Starter
            • Moderator


            • Egghead

            • Welcome to ComputerHope!
            • Thanked: 44
              Re: "Inventory" for HTML RPG
              « Reply #11 on: March 21, 2006, 08:36:16 AM »
              Quote
              Yes, you're up and running.  Now for the web page that your mother loves so much: helloworld.php


              <html>
              <body>
              <?php

                // If php is running correctly, this will display "Hello world!"
                echo '<p>Hello world!</p>';

              ?>
              </body>

              I made a PHP file with the information you gave, and tried it. The output was the full code. I tried a HTML with that PHP embedded, and the output was this:

              Hello world!'; ?>
              "The geek shall inherit the Earth."

              Rob Pomeroy



                Prodigy

              • Systems Architect
              • Thanked: 124
                • Me
              • Experience: Expert
              • OS: Other
              Re: "Inventory" for HTML RPG
              « Reply #12 on: March 21, 2006, 09:09:17 AM »
              You need to follow the installation instructions for PHP fully, including the part about how to set up Apache once PHP is installed.  Apache needs to know that .php files have to be handed off to the PHP engine before displaying the results.
              Only able to visit the forums sporadically, sorry.

              Geek & Dummy - honest news, reviews and howtos

              Dilbert

                Topic Starter
              • Moderator


              • Egghead

              • Welcome to ComputerHope!
              • Thanked: 44
                Re: "Inventory" for HTML RPG
                « Reply #13 on: March 21, 2006, 04:08:43 PM »
                I'm in the httpd.conf file and I'm having trouble finding it. Is that the correct file to set up the PHP? (It was in C:\Program files\Apache Group\Apache2\conf, by the way)
                "The geek shall inherit the Earth."

                Rob Pomeroy



                  Prodigy

                • Systems Architect
                • Thanked: 124
                  • Me
                • Experience: Expert
                • OS: Other
                Re: "Inventory" for HTML RPG
                « Reply #14 on: March 22, 2006, 03:18:30 AM »
                Yes, but have you followed >these< installation instructions, followed by >these<?
                Only able to visit the forums sporadically, sorry.

                Geek & Dummy - honest news, reviews and howtos