Help with the "Lantern" IDE

Greetings. 1st post.

I’m picking up a text adventure I started writing over 10 years ago, and for some reason I stopped.

Originally I was using Quest, and I may continue to do that, but with the renaissance in 8-bit computing (especially with products like the Spectrum Next and Ultimate 64), I was hoping to write something to actually use on older systems. With that in mind, I have stumbled across “Lantern”, which is not mentioned here (that I can see) in the List of authoring systems, that I can see. Lantern’s website throws up certificate errors, but if you tell your browser or AV you want to go there anyway, it should let you through. www•textadventure•net.

Lantern can import Trizbort maps, and can create adventures for several 8 bit systems including the Amstrad CPC, Apple][e, BBC, C64, Spectrum, and TRS-80, as well as for CP/M and MS-DOS.

What I can’t work out is how to have it automatically list the visible exits in a room.

I.e., If you are in a “room” with exits east and west, it should say

”You are in a room.

There are exits East and West”

But all it says is:

“You are in a room.”

Any idea how to accomplish this?

Are you sure it’s meant to say that. Because the exits could be part of the room description message where, perhaps, they could be worded better. Sorry, I don’t know this system. But thanks for pointing it out, I didn’t know about it.

I installed it, but it wants .NET unfortunately. And I cant be bothered with all that madness.

Well firstly, thank you for the reply.

Yes, unfortunately it requires .net (6 I think), but it gives an option to install it and then runs.

I did get an error when running originally, my display was set to 125% (recommended in the settings), after discussing the crash errors with ChatGPT and a bit of trial and error, setting it to 100% and scaling the text to 125% (so it’s still readable) seems to have fixed that.

Onto what I am after… Yes, exits can be listed directly in the description, but I want them to eventually be relative to the players direction rather than fixed to the cardinal points.

Oh I see, like “go right” and “go left” perhaps?

exactly that.

With the help of chatGPT, and some of the built in code snippits, I’ve cracked it.

So for any others reading this who want to do the same, here’s what I did. You can use whatever names you like, you don’t have to use the ones I did, but you need to make sure you reference them correctly. :wink:

Under the verbs tab, create a new verb: exits

Under the variables tab, create 3 new variables: tempRoom, exitCount, and exitIndex; and 1 new array: validExits; and give the array 10 slots. (you can increase or decrease this depending on the number of exits you want to reference).

Under the functions tab, create a new function: check_exits, and give it the following code:

exitCount = 0;
tempRoom = player.location;
if (tempRoom.n < 127) 
{
     validExits[exitCount]=0;
     exitCount++;
}
if (tempRoom.s < 127) 
{
     validExits[exitCount]=1;
     exitCount++;
}
if (tempRoom.e < 127) 
{
     validExits[exitCount]=2;
     exitCount++;
}
if (tempRoom.w < 127) 
{
     validExits[exitCount]=3;
     exitCount++;
}
if (tempRoom.ne < 127) 
{
     validExits[exitCount]=4;
     exitCount++;
}
if (tempRoom.nw < 127) 
{
     validExits[exitCount]=5;
     exitCount++;
}
if (tempRoom.se < 127) 
{
     validExits[exitCount]=6;
     exitCount++;
}
if (tempRoom.sw < 127) 
{
     validExits[exitCount]=7;
     exitCount++;
}
if (tempRoom.u < 127) 
{
     validExits[exitCount]=8;
     exitCount++;
}
if (tempRoom.d < 127) 
{
     validExits[exitCount]=9;
     exitCount++;
}
if (exitCount == 0) {
    println("There are no exits.");
} else {
    exitIndex = 0;
    if (exitCount == 1) {
        print("There is an exit to the ");
    } else {
        print("There are exits to the ");
    }
    while (exitIndex < exitCount) {
        // Print direction
        if (validExits[exitIndex] == 0) print("North");
        else if (validExits[exitIndex] == 1) print("South");
        else if (validExits[exitIndex] == 2) print("East");
        else if (validExits[exitIndex] == 3) print("West");
        else if (validExits[exitIndex] == 4) print("Northeast");
        else if (validExits[exitIndex] == 5) print("Northwest");
        else if (validExits[exitIndex] == 6) print("Southeast");
        else if (validExits[exitIndex] == 7) print("Southwest");
        else if (validExits[exitIndex] == 8) print("Up");
        else if (validExits[exitIndex] == 9) print("Down");
        // Determine how to join
        if (exitCount == 2 && exitIndex == 0) {
            print(" and ");
        } else if (exitCount > 2) {
            if (exitIndex < exitCount - 2) {
                print(", ");
            } else if (exitIndex == exitCount - 2) {
                print(", and ");
            }
        }
        exitIndex++;
    }
    println(".");
}

Under the sentences tab, create a new sentence. Choose the new verb you created (exits), leave 1st Object, Preposition, and 2nd Object blank, choose check_exits as the function, and select instead for the Type.
It should then appear on the right as (instead) exits --->check_exits

I can’t embed media, so I can’t post a screenshot, here is a copy and paste of the output.

Test
Version 1.0
Me+ChatGPT :wink:
You are facing North.

Entrance
The start.

look
Entrance
The start.

exits
There is an exit to the East.

e
Maze Room
A crossroads.
a thing

exits
There are exits to the North, South, East, and West.

1 Like

Alternative code for the function check_exits which is a little more concise, and is transferable to relative directions (forward, back, back-left, &c.)

exitCount = 0;
tempRoom = player.location;
if (tempRoom.n < 127) 
{
     validExits[exitCount]=0;
     exitCount++;
}
if (tempRoom.s < 127) 
{
     validExits[exitCount]=1;
     exitCount++;
}
if (tempRoom.e < 127) 
{
     validExits[exitCount]=2;
     exitCount++;
}
if (tempRoom.w < 127) 
{
     validExits[exitCount]=3;
     exitCount++;
}
if (tempRoom.ne < 127) 
{
     validExits[exitCount]=4;
     exitCount++;
}
if (tempRoom.nw < 127) 
{
     validExits[exitCount]=5;
     exitCount++;
}
if (tempRoom.se < 127) 
{
     validExits[exitCount]=6;
     exitCount++;
}
if (tempRoom.sw < 127) 
{
     validExits[exitCount]=7;
     exitCount++;
}
if (tempRoom.u < 127) 
{
     validExits[exitCount]=8;
     exitCount++;
}
if (tempRoom.d < 127) 
{
     validExits[exitCount]=9;
     exitCount++;
}
if (exitCount == 0) {
    println("You can't see a way out.");
} else {
    exitIndex = 0;
    print("You can go ");
    while (exitIndex < exitCount) {
        // Print direction
        if (validExits[exitIndex] == 0) print("North");
        else if (validExits[exitIndex] == 1) print("South");
        else if (validExits[exitIndex] == 2) print("East");
        else if (validExits[exitIndex] == 3) print("West");
        else if (validExits[exitIndex] == 4) print("Northeast");
        else if (validExits[exitIndex] == 5) print("Northwest");
        else if (validExits[exitIndex] == 6) print("Southeast");
        else if (validExits[exitIndex] == 7) print("Southwest");
        else if (validExits[exitIndex] == 8) print("Up");
        else if (validExits[exitIndex] == 9) print("Down");
        // Determine how to join
        if (exitCount == 2 && exitIndex == 0) {
            print(" and ");
        } else if (exitCount > 2) {
            if (exitIndex < exitCount - 2) {
                print(", ");
            } else if (exitIndex == exitCount - 2) {
                print(", and ");
            }
        }
        exitIndex++;
    }
    println(".");
}
1 Like

This is great, I didn’t realise you could write these functions in Lantern. Is it a specific language? Looks similar to either c or pascal.

Nice work!

it’s a “c type” language apparently

EDITED code for compactness, added in all directions, and also covered looping into the same room you have just left :wink:

I’ve now nailed tracking the player’s facing direction. I’ve only added goE and goW at this point, but I just need to copy/edit that code for the other 6 compass points (only worth doing up/down if the player is swimming because we don’t want them standing on their head when they get the bottom of a ladder, do we?

Here’s the code - and the test output:

I’ve added the status/exit calls into the command so I don’t have to keep typing them right now, I also split the print_exits out from the check_exits so we can query the exits at any time and not spam the player..

game_start //automatically runs before the player does anything

check_exits();
print_exits();
status_output();

status_output

print("You are ");
     if (facing == 0) println("facing North.");
else if (facing == 1) println("facing South.");
else if (facing == 2) println("facing East.");
else if (facing == 3) println("facing West.");
else if (facing == 4) println("facing Northeast.");
else if (facing == 5) println("facing Northwest.");
else if (facing == 6) println("facing Southeast.");
else if (facing == 7) println("facing Southwest.");
else                  println("disorientated.");

check_exits

exitCount = 0;
tempRoom = player.location;
if (tempRoom.n    < 127) { validExits[exitCount] =  0; exitCount++; }
if (tempRoom.s    < 127) { validExits[exitCount] =  1; exitCount++; }
if (tempRoom.e    < 127) { validExits[exitCount] =  2; exitCount++; }
if (tempRoom.w    < 127) { validExits[exitCount] =  3; exitCount++; }
if (tempRoom.ne   < 127) { validExits[exitCount] =  4; exitCount++; }
if (tempRoom.nw   < 127) { validExits[exitCount] =  5; exitCount++; }
if (tempRoom.se   < 127) { validExits[exitCount] =  6; exitCount++; }
if (tempRoom.sw   < 127) { validExits[exitCount] =  7; exitCount++; }
if (tempRoom.up   < 127) { validExits[exitCount] =  8; exitCount++; }
if (tempRoom.down < 127) { validExits[exitCount] =  9; exitCount++; }
if (tempRoom.in   < 127) { validExits[exitCount] = 10; exitCount++; }
if (tempRoom.out  < 127) { validExits[exitCount] = 11; exitCount++; }

print_exits

if (exitCount == 0) { println("There are no obvious exits."); }
else {
    exitIndex = 0; print("You can go ");
    while (exitIndex < exitCount) {
             if (validExits[exitIndex] ==  0) print("North");
        else if (validExits[exitIndex] ==  1) print("South");
        else if (validExits[exitIndex] ==  2) print("East");
        else if (validExits[exitIndex] ==  3) print("West");
        else if (validExits[exitIndex] ==  4) print("Northeast");
        else if (validExits[exitIndex] ==  5) print("Northwest");
        else if (validExits[exitIndex] ==  6) print("Southeast");
        else if (validExits[exitIndex] ==  7) print("Southwest");
        else if (validExits[exitIndex] ==  8) print("Up");
        else if (validExits[exitIndex] ==  9) print("Down");
        else if (validExits[exitIndex] == 10) print("In");
        else if (validExits[exitIndex] == 11) print("Out");
             if (exitCount == 2 && exitIndex == 0) print(" or ");
        else if (exitCount > 2) {
                 if (exitIndex < exitCount - 2)       print(", ");
            else if (exitIndex == exitCount - 2) print(", or ");
        }
        exitIndex++;
    }
    println(".");
}

goN

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom
      && prevRoom.n  != tempRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goS

prevRoom = player.location;
player.location = prevRoom.s;
check_exits();
     if (tempRoom.s  == prevRoom
      && prevRoom.s  != tempRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goE

prevRoom = player.location;
player.location = prevRoom.e;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom
      && prevRoom.e  != tempRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goW

prevRoom = player.location;
player.location = prevRoom.w;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom 
      && prevRoom.w  != tempRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goNE

prevRoom = player.location;
player.location = prevRoom.ne;
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom
      && prevRoom.ne != tempRoom) facing = 8;
check_exits();
print_exits();
status_output();


goNW

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom
      && prevRoom.nw != tempRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goSE

prevRoom = player.location;
player.location = prevRoom.se;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom) facing = 4;
else if (tempRoom.se == prevRoom
      && prevRoom.se != tempRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goSW

prevRoom = player.location;
player.location = prevRoom.sw;
check_exits();
     if (tempRoom.s  == prevRoom) facing = 0;
else if (tempRoom.n  == prevRoom) facing = 1;
else if (tempRoom.w  == prevRoom) facing = 2;
else if (tempRoom.e  == prevRoom) facing = 3;
else if (tempRoom.sw == prevRoom
      && prevRoom.sw != tempRoom) facing = 4;
else if (tempRoom.se == prevRoom) facing = 5;
else if (tempRoom.nw == prevRoom) facing = 6;
else if (tempRoom.ne == prevRoom) facing = 7;
print_exits();
status_output();

goUp

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
print_exits();
status_output();

goDn

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
print_exits();
status_output();

goIn

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
print_exits();
status_output();

goOut

prevRoom = player.location;
player.location = prevRoom.n;
check_exits();
print_exits();
status_output();

sentences

(instead) n    --->goN
(instead) s    --->goS
(instead) e    --->goE
(instead) w    --->goW
(instead) ne   --->goNE
(instead) nw   --->goNW
(instead) se   --->goSE
(instead) sw   --->goSW
(instead) up   --->goUp
(instead) down --->goDn
(instead) in   --->goIn
(instead) out  --->goOut

Which yields:

Test
Version 1.0
Me+ChatGPT :wink:
You can go East.
You are facing North.

Entrance
The start.

e
You can go North, South, East, or West.
You are facing East.

w
You can go East.
You are facing West.

My next task is to convert the movement into relative directions :slight_smile: