none
Loading RRS feed

  • Question

  • Can't figure out how to load it.
    player()
    variables()
    Menu()
    
    Sub variables
      x = 0
      y = 0
    EndSub
    
    Sub Save_game
      path = Program.Directory + "\Overworld Slayer.txt"
       variables[1]= x 
     variables[2]= y 
       variables[3] =  level 
      variables[4] =playerhp 
      variables[5]  =playerstr 
      variables[6]  =playerdef 
       variables[7] =playergold 
       variables[8]  =playerxp 
       variables[9] =totalplayerhp 
      File.WriteContents(path, variables)
    EndSub
    
    Sub load_game
      path = Program.Directory + "\Overworld Slayer.txt" 
     x= variables[1]
     y = variables [2]
      level   =variables[3] 
     playerhp  =variables[4] 
      playerstr = variables[5]  
      playerdef =variables[6]  
     playergold  = variables[7] 
     playerxp = variables[8] 
     totalplayerhp  = variables[9] 
    EndSub
    
    Sub player
        weapon = "sword"
        level = 1
        totalplayerhp = 50
        playerhp = 50
        playerstr = 10
        playerdef = 10
        playergold = 0
        playerxp = 0
    EndSub
        
    Sub skeleton
          enemyname = "Skeleton"
          enemyhp = 10
              totalenemyhp = 10
          enemystr = 2
          enemydef = 1
          xpdrop = 5
          golddrop = 3
    EndSub 
        
    Sub zombie
          enemyname = "Zombie"
          enemyhp = 20
          totalenemyhp = 20
          enemystr = 4
          enemydef = 2
          xpdrop = 10
          golddrop = 6
    EndSub 
        
    Sub demon
          enemyname = "Demon"
          enemyhp = 30
              totalenemyhp = 30
          enemystr = 6
          enemydef = 3
          xpdrop = 15
          golddrop = 9
        EndSub 
        
        Sub skeletonking
          enemyname = "Skeleton King"
          enemyhp = 250
              totalenemyhp = 250
          enemystr = 15
          enemydef = 15
          xpdrop = 200
          golddrop = 200
    EndSub 
        
    Sub zombiehulk
          enemyname = "Zombie Hulk"
          enemyhp = 300
          totalenemyhp = 300
          enemystr = 20
          enemydef = 20
          xpdrop = 250
          golddrop = 250
    EndSub 
        
    Sub demongeneral
          enemyname = "Demon General"
          enemyhp = 500
              totalenemyhp = 500
          enemystr = 25
          enemydef = 25
          xpdrop = 500
          golddrop = 500
        EndSub 
        
        Sub Satan
          enemyname = "Satan"
          enemyhp = 1000
              totalenemyhp = 1000
          enemystr = 50
          enemydef = 50
          xpdrop = 1000
          golddrop = 1000
        EndSub 
    
    Sub Menu
      TextWindow.WriteLine("1. New Game")
       TextWindow.WriteLine("2. Load Game")
      space()
      menu1 = TextWindow.ReadNumber()
      If menu1 = 1 Then
        TextWindow.Clear()
        intro()
      ElseIf menu1 = 2 then
          TextWindow.Clear()
        variables = File.ReadContents(path)
        load_game()
      selectlocation()
      Else
        wrongoption()
        Menu()
      EndIf
    EndSub
    
    Sub space
      TextWindow.WriteLine(" ")
    endsub
    
    Sub enter
      TextWindow.WriteLine("Press Enter")
      TextWindow.PauseWithoutMessage()
      TextWindow.Clear()
    endsub
    
    Sub wrongoption
      TextWindow.Clear()
      TextWindow.WriteLine("You can only select the ones listed")
      space()
      enter()
    EndSub
    
    Sub intro
      TextWindow.WriteLine("Story: You have been reborned in Hell and vowed to slay Satan")
      space()
      enter()
      selectlocation()
    EndSub
    
    Sub selectlocation
        TextWindow.WriteLine("Coordinates: " + "(" + x + "," + y + ")")
        space()
        TextWindow.WriteLine("Level: " + level)
        space()
        TextWindow.WriteLine("Exp: " + playerxp + "     Gold: " + playergold)
        space()
        TextWindow.WriteLine("Player HP: " + playerhp + "/" + totalplayerhp)
        space()
        TextWindow.WriteLine("1. North")
        TextWindow.WriteLine("2. East")
        TextWindow.WriteLine("3. West")
        TextWindow.WriteLine("4. South")
        space()
        TextWindow.WriteLine("0. Save")
        space()
        selectlocation1 = TextWindow.ReadNumber()
        If selectlocation1 = 0 Then
          Save_game()
          TextWindow.Clear()
          TextWindow.WriteLine("Game has been saved")
          space()
          enter()
          Program.End()
       elseIf selectlocation1 = 1 Then
          TextWindow.Clear()
          y = y+1
          enemy()
        ElseIf selectlocation1 = 2 then
          TextWindow.Clear()
          x=x+1
          enemy()
        elseif selectlocation1 = 3 then
          TextWindow.Clear()
          x = x-1
          enemy()
        elseif selectlocation1 = 4 then
          TextWindow.Clear()
          y =y-1
          enemy()
        Else
          wrongoption()
          enter()
          selectlocation()
        EndIf
    EndSub
      
    Sub enemy
      TextWindow.Clear()
       If x = 6 And y = 66 Then
         Satan()
         player()
          battle()
        ElseIf x = 6 and y = 46 then
          demongeneral()
          player()
          battle()
        elseif x = 3 and y  = 66 then
          zombiehulk()
          player()
          battle()
        elseif x = 9 and y = 66 then
          skeletonking()
          player()
          battle()
          endif
        enemy1 = Math.GetRandomNumber(100)
       If enemy1 < 40 Then
          skeleton()
          player()
          battle()
        ElseIf enemy1 <70 then
          zombie()
          player()
          battle()
        elseif enemy1 <100 then
          demon() 
          player()
          battle()
        EndIf
    EndSub
      
    Sub battle
          TextWindow.Clear()
          TextWindow.WriteLine("You encountered a " + enemyname +".")
          space()
    TextWindow.WriteLine("Player HP: " + playerhp + "/" + totalplayerhp)
          TextWindow.WriteLine(enemyname + ": " + enemyhp +"/" + totalenemyhp)
          space()
          TextWindow.WriteLine("1. Use your " + weapon)
          TextWindow.WriteLine("2. Inventory")
          TextWindow.WriteLine("3. Run Away")
          TextWindow.WriteLine("4. Do Nothing")
          space()
          battle1 = TextWindow.ReadNumber()
          If battle1 = 1 Then
         playerattack()
       ElseIf battle1 = 2 then
         TextWindow.WriteLine("Nothing Here Yet!")
         enter()
         battle()
       elseif battle1 = 3 then
         TextWindow.WriteLine("Nothing Here Yet!")
         enter()
         battle()
       elseif battle1 = 4 then
         TextWindow.WriteLine("Nothing Here Yet!")
         enter()
         battle()
        Else
         wrongoption()
         battle()
       endif
    EndSub
          
    sub playerattack
            space()
          If enemyhp <= 0 Then
            mobwin()
            EndIf
      TextWindow.WriteLine("You attacked and dealt " +playerstr + ".")
          space()
    TextWindow.WriteLine(enemyname + " attacked and dealt " + enemystr+".")
          enemyhp = enemyhp - playerstr
          playerhp = playerhp - enemystr 
          space()
          enter()
          battle()
    endsub
    
    sub mobwin
        TextWindow.Clear()
        TextWindow.WriteLine("You defeated " + enemyname + ".")
        space()
        TextWindow.WriteLine("You gain " + xpdrop + " exp.")
        TextWindow.WriteLine("You gain " + golddrop + " gold.")
        playerxp = playerxp + xpdrop
        playergold = playergold + golddrop
        space()
        enter()
        selectlocation()
    EndSub

    Friday, September 12, 2014 4:06 AM

Answers

  • Insert   path = Program.Directory + "\Overworld Slayer.txt"  in sub variables.  (or head line) 
    path is not assigned before loading.


    • Edited by NaochanONEditor Friday, September 12, 2014 6:32 AM
    • Marked as answer by Dinomite07 Friday, September 12, 2014 4:30 PM
    Friday, September 12, 2014 6:31 AM
    Answerer
  • And insert   variables=File.ReadContents(path)   right after the insert from NaochanON.

    Jan [ WhTurner ] The Netherlands

    • Marked as answer by Dinomite07 Friday, September 12, 2014 4:30 PM
    Friday, September 12, 2014 9:17 AM
    Answerer

All replies

  • Insert   path = Program.Directory + "\Overworld Slayer.txt"  in sub variables.  (or head line) 
    path is not assigned before loading.


    • Edited by NaochanONEditor Friday, September 12, 2014 6:32 AM
    • Marked as answer by Dinomite07 Friday, September 12, 2014 4:30 PM
    Friday, September 12, 2014 6:31 AM
    Answerer
  • And insert   variables=File.ReadContents(path)   right after the insert from NaochanON.

    Jan [ WhTurner ] The Netherlands

    • Marked as answer by Dinomite07 Friday, September 12, 2014 4:30 PM
    Friday, September 12, 2014 9:17 AM
    Answerer