Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

A "floating object" is an object (usually scenery) that can appear in multiple locations. For example, if you have ten forest locations and you want to implement a tree (or trees) in every forest location, you don't want to create ten trees with lots of duplicated code, you just want to create one tree and move it around as the player moves around.

I tried doing this with code similar to the following:

: if (is_at "room01" && is_just_entered()) {
   : create "front_gate";
}
: if (is_at "room02" && is_just_entered()) {
   : create "front_gate";
}

I tried putting this in on_describe{} and on_tick{}. In both cases, the front_gate was moved, but it didn't appear in the list of objects until I refreshed the display with LOOK. Apparently, both of these blocks are executed AFTER the display has been drawn.

Then I tried something like this in the on_command{} block in locations{}:

: match "n _" {
   : create "front_gate" target = "room02" ;
}

The front_gate moved, but I didn't, as it didn't fall through to the normal movement routine, as it should have.

I had to force a move with:

: match "n _" {
   : create "front_gate" target = "room02" ;
   : goto target = "room02";
   : redescribe;
}

This seems a bit extreme.

So what's the best way to implement floating objects?