Howdy, Stranger!

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

Okay seriously last question.

I feel so bad for asking so many questions but this is the first time I ever took a project in twine so seriously
<<if $Level >= 2>><<set $EnemyName to either("Strong Bandit","Feral Orc","Mechanical monster","HyenaThief")>> <<else>> <<set $EnemyName to either("Rookie","Thief","Contraption","Drunk Dwarf")>> <<endif>>
for some reason this code keeps getting either a missing
child tag <<endif>> was found outside of a call to its parent macro <<if>> or the <<else>> was outside macro
Any solutions?
sorry to bug

Comments

  • Actually I fixed this using an array, but if anyone knew what was wrong that would still be awesome
  • edited March 2017
    Nvm
    <<set $EnemyNames1 = ["Drunk dwarf","Thief","Contraption","Guild rookie"]>>
    
    <<set $EnemyNames2 = ["Strong Bandit","Feral Orc","Old Mech","Hyena Thief"]>>
    
    <<if $Level is 1>> <<set $EnemyName to $EnemyNames1.random()>> <<endif>>
    <<if $Level > 2>> <<set $EnemyName to $EnemyNames2.random()>> <<endif>>
    
    Even with arrays the $EnemyNames1 didn't work while the other did and i see no error with either.
  • edited March 2017
    Nope I literally copy and pasted the exact same code as the second (changed the names in the array and it still didn't work. I had a version of this working earlier today but changed it to include more enemy names.
    <<if $Level is 1>> <<set $EnD to random(2,10)>> <<set $EnemyHP to random(5,10)>> <<set $XP to random(1,10)>> <<endif>>
    <<if $Level is 2>> <<set $EnemyHP to random(10,20)>> <<set $XP to random(5,15)>> <<set $EnD to random(10,15)>> <<endif>>
    <<if $Level is 3>> <<set $EnemyHP to random(15,30)>> <<set $XP to random(5,20)>> <<set $EnD to random(10,20)>><<endif>>
    <<if $Level is 4>> <<set $EnemyHP to random(20,40)>> <<set $XP to random(10,20)>> <<set $EnD to random(15,25)>><<endif>
    
    <<set $EnemyNames1 = ["Drunk dwarf","Guild rookie","thief","Contraption"]>>
    
    <<set $EnemyNames2 = ["Strong Bandit","Feral Orc","Old Mech","Hyena Thief"]>>
    
    <<if $Level is 1>> <<set $EnemyName to $EnemyNames1.random()>> <<endif>>
    <<if $Level > 2>> <<set $EnemyName to $EnemyNames2.random()>> <<endif>>
    <<set $Surp to either("You","Enemy")>>
    <<set $Turn to "You">>
    
    Your are attacked by $EnemyName .
    <<if $Surp is "Enemy">> Enemy attacks first! <<set $PlyrHP to $PlyrHP -= $EnD>> <<else>> You attack first! <<endif>>
    
    
    [[Scroll]]
    

    here is the whole list, latest twine2 running on sugarcube 2.12.1.
    I know the level code isn't the best atm but It works and I intend to fix it up later with a few new tricks i learned but yeah $Name isnt working.

    Also the error is now
    Error: <<set>>: bad evaluation: Cannot read property 'random' of undefined
    
    of $EnemyNames1.
  • There's nothing wrong with your first example as shown. Was that a copy/paste or did you retype it? If it was a copy/paste, then the issue lies elsewhere. If you retyped it, then either you fixed it when doing so or, again, the issue lies elsewhere.

    As far as the second and third examples go. Where are you setting $Level and what are you setting it to? Your logic is also likely hosed, but we'll get to that later.
  • edited March 2017
    @TheMadExile
    Copy and paste than retyped the names
    ["Drunk dwarf","Guild rookie","thief","Contraption"]
    
    and changed
    $EnemyNames2
    
    to
    $EnemyNames1
    
    , nothing is wrong with the leveling side of the variables, all it's used for in this case is to check if the PLyr has the right level and I checked the level side well, everything works there. Also the second example
    <<if $Level > 2>>
    
    definintely works. The problem seems to lie here
    <<set $EnemyNames1 = ["Drunk dwarf","Guild rookie","thief","Contraption"]>
    
    or here
    <<if $Level is 1>> <<set $EnemyName to $EnemyNames1.random()>> <<endif>>
    
    .
    If I were to update sugar cube would it effect anything, I hear there is a new version. Maybe it is a bug.
    This is by far the simplest thing I am doing, changing the names should be a breeze right
  • Got it to work! Erased everything and rewrote it! Yay! But sure If you have any suggestion for my "Hose" logic.
  • edited March 2017
    Crap again, getting some bad evaluations here
    <<set $Sword ={Name:"Sword", Material:either("orch","Izbolt","Steel","iron), Damage:10}>>
    
    <<set $Bow ={Name:"Bow", Material: either("orch","Izbolt","Steel","iron"), Damage:12}>>
    ~~~~~~~~~~~~~~~~~~~~~~
    <<set $Polearm = {Name:"Spear", Material: either("orch","Izbolt","Steel","iron"), Damage:11}>>
    ~~~~~~~~~~~~~~~~~~~~~~
    <<set $Axe = {Name:"hand axe", Material: either("orch","Izbolt","Steel","iron"), Damage:10}>>
    
    any takers? I am literally going to be working on this most of the night

    Edit; Fixed
Sign In or Register to comment.