Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I am Having trouble with a link

The problem i am having is that when  click the link "NEXT ROUND" on passge no.2 it sends me  to an error screen saying "Address not Valid".
  I have checked and double checked and the links are right,they should work.Whats wrong with them???

Heres the Code:

PASSAGE no.1

[img[$playertank.image]]
Name: <<print $playertank.name>>
Country of origin: <<print $playertank.country>>
Health: <<print $playertank.health>>
Main Gun: (<<print $playertank.damage>> Damage)
<<if $AItank.health lte 0>>[[WIN|WIN]]
<<else>><<set $AItank.health = $AItank.health - $playertank.damage>>[[NEXT ROUND|Combat 2]]
<<elseif>>
<<endif>>



[img[$AItank.image]]
Name: <<print $AItank.name>>
Country of Origin: <<print $AItank.country>>
Health: <<print $AItank.health>>
Main Gun: (<<print $AItank.damage>> Damage)

<<if $playertank.health lte 0>>[[WIN|win]]
<<else>><<set $playertank.health = $playertank.health - $AItank.damage>>
<<elseif>>
<<endif>>

PASSAGE no.2

[img[$playertank.image]]
Name: <<print $playertank.name>>
Country of origin: <<print $playertank.country>>
Health: <<print $playertank.health>>
Main Gun: (<<print $playertank.damage>> Damage)
<<if $AItank.health lte 0>>[[WIN|WIN]]
<<else>><<set $AItank.health = $AItank.health - $playertank.damage>>[[NEXT ROUND|Combat 3]]
<<elseif>>
<<endif>>



[img[$AItank.image]]
Name: <<print $AItank.name>>
Country of Origin: <<print $AItank.country>>
Health: <<print $AItank.health>>
Main Gun: (<<print $AItank.damage>> Damage)

PASSAGE no.3

[img[$playertank.image]]
Name: <<print $playertank.name>>
Country of origin: <<print $playertank.country>>
Health: <<print $playertank.health>>
Main Gun: (<<print $playertank.damage>> Damage)
<<if $AItank.health lte 0>>[[WIN|WIN]]
<<else>><<set $AItank.health = $AItank.health - $playertank.damage>>[[Next ROUND|Combat]]
<<elseif>>
<<endif>>



[img[$AItank.image]]
Name: <<print $AItank.name>>
Country of Origin: <<print $AItank.country>>
Health: <<print $AItank.health>>
Main Gun: (<<print $AItank.damage>> Damage)

<<if $playertank.health lte 0>>[[WIN|win]]
<<else>><<set $playertank.health = $playertank.health - $AItank.damage>>
<<elseif>>
<<endif>>



<<if $playertank.health lte 0>>[[WIN|win]]
<<else>><<set $playertank.health = $playertank.health - $AItank.damage>>
<<elseif>>
<<endif>>

Along with two passages that select your tank and the enemys tank

YOUR TANK:


<<silently>>
<<set $playertank to {}>>

<<set $panzer_I to {
  name: "Panzer_I",
  country: "Germany",
  health: 54,
  damage: 7,
  image: "PanzerI",
}>>

<<set $playertank to $panzer_I>>
<<endsilently>>

[img[$playertank.image]]
Name: <<print $playertank.name>>
Country of origin: <<print $playertank.country>>
Health: <<print $playertank.health>>
Main Gun: 2x 7.92mm MG13 (<<print $playertank.damage>> Damage)

[[Combat|Combat]]


ENEMYS TANK:


<<silently>>
<<set $AItank to {}>>

<<set $TKS to {
  name: "TKS",
  country: "Poland",
  health: 25,
  damage: 7,
  image: "TKS 2",
}>>

<<set $AItank to $TKS>>
<<endsilently>>

[img[$AItank.image]]
Name: <<print $AItank.name>>
Country of Origin: <<print $AItank.country>>
Health: <<print $AItank.health>>
Main Gun: 1x 7.92mm Hotchkiss (<<print $AItank.damage>> Damage)

[[p|Panzer 1]]


Comments

  • your need to state which story format your are using as answer can be different for each one.

    If the Combat 3 passage exists then I believe the [[NEXT ROUND|Combat 3]] link should work.

    There are some other problems with your example code:

    1. Passage name are case sensitive, so unless you have two passages named WIN and win,  you will need to correct the case on some of your links.

    2. When using a <<if>><<elseif>><<else>><<endif>> sequence the <<elseif>> macro should come before the <<else>> macro.
    Also as the <<elseif>> macros in your examples have no expression they should be removed, as shown in the following copy of your code.

    (note: the following is using TWEE notation, lines starting with two colons indicate a new passage, the text on the same line as the two colons is the new passage's title)

    :: PASSAGE no.1
    [img[$playertank.image]]
    Name: <<print $playertank.name>>
    Country of origin: <<print $playertank.country>>
    Health: <<print $playertank.health>>
    Main Gun: (<<print $playertank.damage>> Damage)
    <<if $AItank.health lte 0>>[[WIN|WIN]]
    <<else>><<set $AItank.health = $AItank.health - $playertank.damage>>[[NEXT ROUND|Combat 2]]
    <<endif>>
  • Thankyou,i am using sugarcane.
        Tried everything you said and it still wont work.Anything else i can try?????
    I have attached the code for you to look at,please tell me if it works for you(it does not work for me).
    I have also removed the images.(the file size was too big with them,to upload it here).
  • Your example worked for me and I saw the YOU WIN message.

    There are a couple of potential issues with it though:

    1. After you build your $TKS (and $panzer_I) object variable you then assign that object to the $AItank (and $playertank) variable.
    Are you aware that $TKS and $AItank are pointing to the same object and if you change the value of $AItank.name that it would also change the value of $TKS.name?

    <<set $TKS to {
    name: "TKS",
    country: "Poland",
    health: 25,
    damage: 7,
    image: "TKS"
    }>>
    <<set $AItank to $TKS>>

    <<set $AItank.name to "banana">>
    TKS: <<print $TKS.name>>
    AItank: <<print $AItank.name>>
    I am guessing that what you are actually trying to do is define a generic Tank object and then assign a copy of that object to a variable, the follow example shows you how to do that:

    /% Define the base TKS Tank object. %/
    <<set $TKS to {
    name: "TKS",
    country: "Poland",
    health: 25,
    damage: 7,
    image: "TKS"
    }>>

    /% Assign an instance of the TKS object to a varaible. %/
    <<set $AItank to JSON.parse(JSON.stringify($TKS))>>

    <<set $AItank.name to "banana">>
    TKS: <<print $TKS.name>>
    AItank: <<print $AItank.name>>
    2. If the Reader travels backwards (using browser back button) through the example they will see "if expression" errors.
    Moving all the initial object and variable setup into the StoryInit special passage fixes this issue, which is where these type of things belong anyway.

    I have attached a restructured version of your example for you to look at and test.

    I am assuming that you are using the latest 1.4.2 version of Twine, which browser (brand,version,32/64bit) and operation system (brand,version,32/64bit) are you using to test your story?
  • i am using internet explorer and windows 8.1 not sure about the 32/64 bit tho (i will find out)
        Thankyou for your help,but i am still having the same problem using your code.
  • In the past there have been issues with things not working correctly in Internet Explorer (IE).

    Because I don't have a copy of Windows 8.1, could you try two things for me.

    1. See if there are any Javascript errors within the Developer Tools Console, this link will explain how to open the Developer Tools and then how to view the Console. Once the Console is open you may need to refresh the page using the F5 key before stepping through your story to the passage that causes the issue, once there see if there are any error messages within the Console and report them here.

    2. Try playing both my and your example files using a different browser like FireFox or Chrome, to see if the issue still exists.

    The first test will see if it may be IE that is cause the issue, the second test may see if it is Windows 8.1 that is the issue as my example works on WinXP / Win7 using Firefox and Chrome.
  • Ok will try suggested things.
  • Thankyou for the help,i have found out that the problem was IE because the code worked when i tested it on a game website.
        Thanks again for all the help. :) :) :)
  • Internet Explorer disables Web Storage when opening files locally (via file://), rather than remotely (via http:// or https://).  In that situation, the vanilla story formats (of which Sugarcane is one) switch to using the location hash to store the story state.  The way they encode the story state into the hash apparently grows too large for IE with what you're doing.
  • ok thankyou very much for all your help.
Sign In or Register to comment.