Unexplained compile error (Im discombobulated)

Discussion in 'Archives' started by ZamorakianFaith, Jun 3, 2007.

Unexplained compile error (Im discombobulated)
  1. Unread #1 - Jun 3, 2007 at 2:31 AM
  2. ZamorakianFaith
    Joined:
    Apr 28, 2005
    Posts:
    406
    Referrals:
    0
    Sythe Gold:
    0

    ZamorakianFaith Forum Addict
    Banned

    Unexplained compile error (Im discombobulated)

    Alright.... please dont leech this script kay?

    Im working on an example script... just by looking at it you can probably tell what it is.... anyway, Im getting an error that I cant figure out at all:

    Line 33: [Error] (37:14): Unknown identifier 'chance' in script rpginclude.txt

    heres the main script "rpg.scar"

    Code:
    program RPG;
    
    {.include rpginclude.txt}
    
    
    
    //Readys the monster list for usage
    Procedure declaremonsters;
    begin
    m[1]:='Wolf'
    m[2]:='Bat'
    m[3]:='Spider'
    m[4]:='Rouge'
    m[5]:='Spirit'
    m[6]:='Slime'
    m[7]:='Soul Collecter'
    m[8]:='Reaper'
    m[9]:='Mage'
    m[10]:='Swordsman'
    m[11]:='Dwarf'
    m[12]:='Elf'
    m[13]:='Bowman'
    m[14]:='Valkrie'
    m[15]:='Sythe'
    end;
    
    
    
    
    
    
    procedure start;
    begin
    writeln('           //////////////////////////////////')
    writeln('/////////////    Welcome to RPG By ZFaith  /////////////')
    writeln('           //////////////////////////////////')
    wait(5000)
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    repeat
    wait(random(200))//(creates a flicker effect)
    anim('Press F11 to enter the dungeon.')
    until(isfkeydown(11)=true)
    anim('You warily enter the dungeon- sword in hand.')
    anim('You warily enter the dungeon- sword in hand.')
    end;
    
    
    begin
    cleardebug
    writeln('Please Wait While RPG by ZFAITH compiles...')
    wait(5000)
    anim('Loading')
    declarestats;
    anim('Loading')
    declaremonsters;
    anim('Loading')
    start
    end.
    and heres the include code "rpginclude.scar"

    Code:
    var
    monsterint:integer;
    monst:string;
    m:array [1..15] of string;
    chance,at,st,df,es,hp,hitpoints:integer;
    
    
    procedure declarestats;
    begin
    //STATS\\
    HP:= 10;
    AT:= 1;
    ST:= 1;
    DF:= 1;
    ES:= 1;
    chance:= 7; // The probability (1:7 default) that you will encounter a monster.
    
    //STATS\\
    end;
    
    function anim(text:string):boolean;
    var
    t:integer;
    begin
    result:=true
    repeat
    writeln(text)
    writeln('-')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('\')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('|')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('/')
    t:=t+1
    wait(100)
    cleardebug;
    until(t=5)
    end;
    
    procedure getmonster;
    begin
    monsterint:=random(15)
    if monsterint>15 then
     begin
     monsterint:=7
     end;
    if monsterint<1 then
     begin
     monsterint:=8
     end;
    end;
    
    
    procedure idle;
    var
    answer:string;prob:integer;
    begin
    prob:=random(chance)
    anim('...you venture further into the dungeon...')
    anim('...you venture further into the dungeon...')
    anim('...you venture further into the dungeon...')
    if prob = 3 then
     begin
    getmonster;
    monst:=m[monsterint]
    hitpoints:=random(hp)
    if hitpoints = 0 then
     begin
     hitpoints:= 7
     end;
    writeln('You have encountered a level '+inttostr(hitpoints)+' '+monst+'!')
    wait(3000)
    cleardebug
    anim('Get Ready')
    answer:=readln('What do you want to do? type "Run" or "Fight"')
    if answer = 'run' then
     begin
     cleardebug
     anim('You run away...')
     idle
     end;
    if answer = 'fight' then
     begin
     cleardebug
     //fight
     end;
    repeat
    wait(random(200))//(creates a flicker effect)
    anim('Press F11 to veture further.')
    until(isfkeydown(11)=true)
    end;

    It was working awesome until I ended up with conflicting procedures. It would be awesome if you could make scar call procedures from anywhere in the script- not having to put succeeding procedures above one another to avoid processing errors. I dont even know if this is possible though.

    Help greatly appreciated- thanks!

    Peace

    ZF
     
  3. Unread #2 - Jun 3, 2007 at 9:09 AM
  4. Starblaster100
    Joined:
    Apr 21, 2005
    Posts:
    335
    Referrals:
    2
    Sythe Gold:
    0

    Starblaster100 Forum Addict

    Unexplained compile error (Im discombobulated)

    Well im not sure why you made an include when you could have just put it all together, but thats OK.

    I put it all into 1 script and it compiled fine. Just a small error with the procedure "Idle"

    Code:
    program New;
    var
    monsterint:integer;
    monst:string;
    m:array [1..15] of string;
    chance,at,st,df,es,hp,hitpoints:integer;
    
    
    procedure declarestats;
    begin
    //STATS\\
    HP:= 10;
    AT:= 1;
    ST:= 1;
    DF:= 1;
    ES:= 1;
    chance:= 7; // The probability (1:7 default) that you will encounter a monster.
    
    //STATS\\
    end;
    
    function anim(text:string):boolean;
    var
    t:integer;
    begin
    result:=true
    repeat
    writeln(text)
    writeln('-')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('\')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('|')
    wait(100)
    cleardebug;
    writeln(text)
    writeln('/')
    t:=t+1
    wait(100)
    cleardebug;
    until(t=5)
    end;
    
    procedure getmonster;
    begin
    monsterint:=random(15)
    if monsterint>15 then
     begin
     monsterint:=7
     end;
    if monsterint<1 then
     begin
     monsterint:=8
     end;
    end;
    
    
    procedure idle;
    var
    answer:string;prob:integer;
    begin
      prob:=random(chance)
      anim('...you venture further into the dungeon...')
      anim('...you venture further into the dungeon...')
      anim('...you venture further into the dungeon...')
      if prob = 3 then
      begin
        getmonster;
        monst:=m[monsterint]
        hitpoints:=random(hp)
        if hitpoints = 0 then
          hitpoints:= 7
        writeln('You have encountered a level '+inttostr(hitpoints)+' '+monst+'!')
        wait(3000)
        cleardebug
        anim('Get Ready')
        answer:=readln('What do you want to do? type "Run" or "Fight"')
        if answer = 'run' then
        begin
          cleardebug
          anim('You run away...')
          idle
        end;
        if answer = 'fight' then
        begin
          cleardebug
          //fight
        end;
      end;
      repeat
        wait(random(200))//(creates a flicker effect)
        anim('Press F11 to veture further.')
      until(isfkeydown(11)=true)
    end;
    
    //Readys the monster list for usage
    Procedure declaremonsters;
    begin
    m[1]:='Wolf'
    m[2]:='Bat'
    m[3]:='Spider'
    m[4]:='Rouge'
    m[5]:='Spirit'
    m[6]:='Slime'
    m[7]:='Soul Collecter'
    m[8]:='Reaper'
    m[9]:='Mage'
    m[10]:='Swordsman'
    m[11]:='Dwarf'
    m[12]:='Elf'
    m[13]:='Bowman'
    m[14]:='Valkrie'
    m[15]:='Sythe'
    end;
    
    
    
    
    
    
    procedure start;
    begin
    writeln('           //////////////////////////////////')
    writeln('/////////////    Welcome to RPG By ZFaith  /////////////')
    writeln('           //////////////////////////////////')
    wait(5000)
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    anim('You face the opening to an unknown dungeon...')
    repeat
    wait(random(200))//(creates a flicker effect)
    anim('Press F11 to enter the dungeon.')
    until(isfkeydown(11)=true)
    anim('You warily enter the dungeon- sword in hand.')
    anim('You warily enter the dungeon- sword in hand.')
    end;
    
    
    begin
    cleardebug
    writeln('Please Wait While RPG by ZFAITH compiles...')
    wait(5000)
    anim('Loading')
    declarestats;
    anim('Loading')
    declaremonsters;
    anim('Loading')
    start
    end.
    
    You probably want to use scripting standards, as it's easier to find errors then.

    And to make it so you can call procedures below you, we use the forward command:

    Code:
    //This will NOT work!
    program New;
    
    Procedure Two;
    Begin
      Writeln('Im trying to call the procedure below me!');
      One;
    end;
    
    Procedure one;
    Begin
      Writeln('Procedure one called!');
    end;
    
    begin
      Two;
    end.
    
    Code:
    //this WILL work
    program New;
    
    Procedure one; forward;
    
    Procedure Two;
    Begin
      Writeln('Im trying to call the procedure below me!');
      One;
    end;
    
    Procedure one;
    Begin
      Writeln('Procedure one called!');
    end;
    
    begin
      Two;
    end.
    
    Hope that helps
     
  5. Unread #3 - Jun 3, 2007 at 8:56 PM
  6. ZamorakianFaith
    Joined:
    Apr 28, 2005
    Posts:
    406
    Referrals:
    0
    Sythe Gold:
    0

    ZamorakianFaith Forum Addict
    Banned

    Unexplained compile error (Im discombobulated)

    that's awesome. Thanks man. You have no idea how much you helped- im lazy lol.
     
< Selling level 54 non-combat pure/combat | Buying Up To 25m. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site