Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: confused by xml

  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    confused by xml

    I was messing around just trying to make a simple game.
    1. search for monsters.
    2. attack monsters (either with weapon or magic)
    3. update a text box with what happened.

    So I did this with:
    http://blockly-demo.appspot.com/stat...en.html#kbu3ai
    it has an option of output to xml code.

    OH the blockly doesn't work with ie9.
    I use chome. (it also works in firefox; i use that too; but I think it performs better in chrome.)

    However I can't seem to find how to get this code to work in an html file.

    Here is what I have tried.

    1. one
      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
        <script >
      <!-- Share your blocks with this link:http://blockly-demo.appspot.com/static/apps/code/en.html#kbu3ai -->
      
      
       <xml>
        <block type="procedures_defnoreturn" x="748" y="-94">
          <mutation></mutation>
          <title name="NAME">monsteratk</title>
          <statement name="STACK">
            <block type="controls_if" inline="false">
              <mutation else="1"></mutation>
              <value name="IF0">
      
      blah, blah, same as below but this has the "<xml>" that come from the blockly output.
      
                    </block>
                  </next>
                </block>
              </statement>
            </block>
          </statement>
        </block>
      </xml>
        
        </script>
        <title>dpmoble</title>
      </head>
      <body>
      <h1>Search in a Dungeon!</h1>
      
      <hr>
      <hr>Search 
      <!-- trying to use search style one -->
      <button onclick="search();" value="search" name="search" type="button">search</button>
       <!-- trying to use search style xml -->
      <input type="button" name="search"  value="search-x" onclick="search();" /> 
      <!-- trying to use search style two -->
      <button onclick="search" value="search" name="search" type="button">search-2</button>
       
       <br>
      <br>
      <hr>&nbsp;
      <p>You found a:&nbsp;<input
       value="Search for somthing first." name="txtmonster">
      &nbsp;Monster life: &nbsp;<input
       value="Search for somthing first." name="txtmonsterlife">
      </p>
      <p>What do you want to do? &nbsp; <button
       onclick="heroatk" value="fight" name="fight"
       type="button">punch/weapon</button>
      <button onclick="heromagic" value="magic" name="magic"
       type="button">Use magic</button>
      </p>
      <p>result: &nbsp;<textarea cols="20" rows="20"
       name="results"></textarea>
      </p>
      <p><button onclick="reset" value="reset"
       name="reset" type="reset">reset</button>
      </p>
      </body>
      </html>


    Originally my goal was the javascript out put from
    http://blockly-demo.appspot.com/stat...en.html#kbu3ai

    but I couldn't get that to work either.
    I'm open to either way at this point.

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK it told me my post was too long.
    so here is the other xml style I tried.

    i had to shorten it to just the script part. & remove the all but the search & hero attack.
    The blockly link is still good, but it may only last for a few days.
    Code:
      <script >
    <!-- Share your blocks with this link:http://blockly-demo.appspot.com/static/apps/code/en.html#kbu3ai -->
    
      <block type="procedures_defnoreturn" x="269" y="-91">
        <mutation></mutation>
        <title name="NAME">dosearch</title>
        <statement name="STACK">
          <block type="variables_set" inline="false">
            <title name="VAR">randomnum</title>
            <value name="VALUE">
              <block type="math_random_int" inline="true">
                <value name="FROM">
                  <block type="math_number">
                    <title name="NUM">1</title>
                  </block>
                </value>
                <value name="TO">
                  <block type="math_number">
                    <title name="NUM">6</title>
                  </block>
                </value>
              </block>
            </value>
            <next>
              <block type="controls_if" inline="false">
                <mutation elseif="1" else="1"></mutation>
                <value name="IF0">
                  <block type="logic_compare" inline="true">
                    <title name="OP">LTE</title>
                    <value name="A">
                      <block type="variables_get">
                        <title name="VAR">randomnum</title>
                      </block>
                    </value>
                    <value name="B">
                      <block type="math_number">
                        <title name="NUM">2</title>
                      </block>
                    </value>
                  </block>
                </value>
                <statement name="DO0">
                  <block type="variables_set" inline="false">
                    <title name="VAR">monsterlife</title>
                    <value name="VALUE">
                      <block type="math_number">
                        <title name="NUM">1</title>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" inline="false">
                        <title name="VAR">monster</title>
                        <value name="VALUE">
                          <block type="text">
                            <title name="TEXT">monster1</title>
                          </block>
                        </value>
                        <next>
                          <block type="text_print" inline="false">
                            <value name="TEXT">
                              <block type="variables_get">
                                <title name="VAR">monster</title>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" inline="false">
                                <title name="VAR">monsteratk</title>
                                <value name="VALUE">
                                  <block type="math_number">
                                    <title name="NUM">1</title>
                                  </block>
                                </value>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </statement>
                <value name="IF1">
                  <block type="logic_compare" inline="true">
                    <title name="OP">LTE</title>
                    <value name="A">
                      <block type="variables_get">
                        <title name="VAR">randomnum</title>
                      </block>
                    </value>
                    <value name="B">
                      <block type="math_number">
                        <title name="NUM">4</title>
                      </block>
                    </value>
                  </block>
                </value>
                <statement name="DO1">
                  <block type="variables_set" inline="false">
                    <title name="VAR">monsterlife</title>
                    <value name="VALUE">
                      <block type="math_number">
                        <title name="NUM">2</title>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" inline="false">
                        <title name="VAR">monster</title>
                        <value name="VALUE">
                          <block type="text">
                            <title name="TEXT">monster4</title>
                          </block>
                        </value>
                        <next>
                          <block type="text_print" inline="false">
                            <value name="TEXT">
                              <block type="variables_get">
                                <title name="VAR">monster</title>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" inline="false">
                                <title name="VAR">monsteratk</title>
                                <value name="VALUE">
                                  <block type="math_number">
                                    <title name="NUM">2</title>
                                  </block>
                                </value>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </statement>
                <statement name="ELSE">
                  <block type="variables_set" inline="false">
                    <title name="VAR">monsteratk</title>
                    <value name="VALUE">
                      <block type="math_number">
                        <title name="NUM">3</title>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" inline="false">
                        <title name="VAR">monsterlife</title>
                        <value name="VALUE">
                          <block type="math_number">
                            <title name="NUM">3</title>
                          </block>
                        </value>
                        <next>
                          <block type="variables_set" inline="false">
                            <title name="VAR">monster</title>
                            <value name="VALUE">
                              <block type="text">
                                <title name="TEXT">monster6</title>
                              </block>
                            </value>
                            <next>
                              <block type="text_print" inline="false">
                                <value name="TEXT">
                                  <block type="variables_get">
                                    <title name="VAR">monster</title>
                                  </block>
                                </value>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </next>
          </block>
        </statement>
      </block>
      <block type="variables_set" inline="false" x="12" y="-63">
        <title name="VAR">randomnum</title>
        <value name="VALUE">
          <block type="math_number">
            <title name="NUM">0</title>
          </block>
        </value>
        <next>
          <block type="variables_set" inline="false">
            <title name="VAR">herolife</title>
            <value name="VALUE">
              <block type="math_number">
                <title name="NUM">4</title>
              </block>
            </value>
            <next>
              <block type="variables_set" inline="false">
                <title name="VAR">attack</title>
                <value name="VALUE">
                  <block type="math_number">
                    <title name="NUM">1</title>
                  </block>
                </value>
                <next>
                  <block type="variables_set" inline="false">
                    <title name="VAR">atkbonus</title>
                    <value name="VALUE">
                      <block type="math_number">
                        <title name="NUM">2</title>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" inline="false">
                        <title name="VAR">mgcbonus</title>
                        <value name="VALUE">
                          <block type="math_number">
                            <title name="NUM">2</title>
                          </block>
                        </value>
                        <next>
                          <block type="variables_set" inline="false">
                            <title name="VAR">monster</title>
                            <value name="VALUE">
                              <block type="text">
                                <title name="TEXT"></title>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" inline="false">
                                <title name="VAR">monsterlife</title>
                                <value name="VALUE">
                                  <block type="math_number">
                                    <title name="NUM">0</title>
                                  </block>
                                </value>
                                <next>
                                  <block type="variables_set" inline="false">
                                    <title name="VAR">monsteratk</title>
                                    <value name="VALUE">
                                      <block type="math_number">
                                        <title name="NUM">0</title>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="variables_set" inline="false">
                                        <title name="VAR">status</title>
                                        <value name="VALUE">
                                          <block type="text">
                                            <title name="TEXT"></title>
                                          </block>
                                        </value>
                                        <next>
                                          <block type="variables_set" inline="false">
                                            <title name="VAR">level</title>
                                            <value name="VALUE">
                                              <block type="math_number">
                                                <title name="NUM">0</title>
                                              </block>
                                            </value>
                                          </block>
                                        </next>
                                      </block>
                                    </next>
                                  </block>
                                </next>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
      <block type="procedures_defnoreturn" x="653" y="368">
        <mutation></mutation>
        <title name="NAME">heroatk</title>
        <statement name="STACK">
          <block type="controls_if" inline="false">
            <mutation else="1"></mutation>
            <value name="IF0">
              <block type="logic_compare" inline="true">
                <title name="OP">EQ</title>
                <value name="A">
                  <block type="variables_get">
                    <title name="VAR">monsterlife</title>
                  </block>
                </value>
                <value name="B">
                  <block type="math_number">
                    <title name="NUM">0</title>
                  </block>
                </value>
              </block>
            </value>
            <statement name="DO0">
              <block type="text_append" inline="false">
                <title name="VAR">status</title>
                <value name="TEXT">
                  <block type="text">
                    <title name="TEXT">It seems you killed the last monster but you managed to find another.</title>
                  </block>
                </value>
                <next>
                  <block type="text_print" inline="false">
                    <value name="TEXT">
                      <block type="variables_get">
                        <title name="VAR">status</title>
                      </block>
                    </value>
                    <next>
                      <block type="procedures_callnoreturn">
                        <mutation name="dosearch"></mutation>
                        <next>
                          <block type="variables_set" inline="false">
                            <title name="VAR">randomnum</title>
                            <value name="VALUE">
                              <block type="math_random_int" inline="true">
                                <value name="FROM">
                                  <block type="math_number">
                                    <title name="NUM">1</title>
                                  </block>
                                </value>
                                <value name="TO">
                                  <block type="math_number">
                                    <title name="NUM">6</title>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <next>
                              <block type="controls_if" inline="false">
                                <mutation else="1"></mutation>
                                <value name="IF0">
                                  <block type="logic_compare" inline="true">
                                    <title name="OP">LTE</title>
                                    <value name="A">
                                      <block type="variables_get">
                                        <title name="VAR">randomnum</title>
                                      </block>
                                    </value>
                                    <value name="B">
                                      <block type="math_number">
                                        <title name="NUM">4</title>
                                      </block>
                                    </value>
                                  </block>
                                </value>
                                <statement name="DO0">
                                  <block type="text_append" inline="false">
                                    <title name="VAR">status</title>
                                    <value name="TEXT">
                                      <block type="text">
                                        <title name="TEXT">You hit the monster.</title>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="text_print" inline="false">
                                        <value name="TEXT">
                                          <block type="variables_get">
                                            <title name="VAR">status</title>
                                          </block>
                                        </value>
                                        <next>
                                          <block type="variables_set" inline="false">
                                            <title name="VAR">monsterlife</title>
                                            <value name="VALUE">
                                              <block type="math_arithmetic" inline="true">
                                                <title name="OP">MINUS</title>
                                                <value name="A">
                                                  <block type="variables_get">
                                                    <title name="VAR">monsterlife</title>
                                                  </block>
                                                </value>
                                                <value name="B">
                                                  <block type="math_arithmetic" inline="true">
                                                    <title name="OP">ADD</title>
                                                    <value name="A">
                                                      <block type="variables_get">
                                                        <title name="VAR">attack</title>
                                                      </block>
                                                    </value>
                                                    <value name="B">
                                                      <block type="variables_get">
                                                        <title name="VAR">atkbonus</title>
                                                      </block>
                                                    </value>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                          </block>
                                        </next>
                                      </block>
                                    </next>
                                  </block>
                                </statement>
                                <statement name="ELSE">
                                  <block type="text_append" inline="false">
                                    <title name="VAR">status</title>
                                    <value name="TEXT">
                                      <block type="text">
                                        <title name="TEXT">You missed the monster.</title>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="text_print" inline="false">
                                        <value name="TEXT">
                                          <block type="variables_get">
                                            <title name="VAR">status</title>
                                          </block>
                                        </value>
                                      </block>
                                    </next>
                                  </block>
                                </statement>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </statement>
            <statement name="ELSE">
              <block type="text_append" inline="false">
                <title name="VAR">status</title>
                <value name="TEXT">
                  <block type="text">
                    <title name="TEXT">Your dead hit restart.</title>
                  </block>
                </value>
              </block>
            </statement>
          </block>
        </statement>
      </block>
      </script>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •