The Standard Library
The Gamefic SDK includes a
standard library that provides lots of useful components for game worlds.
The standard library defines ten types of entities:
All other entity types extend from
Both player characters and non-player characters can be made from the
A physical location in the game world. You can place an entity in a
Room by setting its
Gamefic.script do # Put a "thing" and the player inside a room @room = make Room, name: 'room' @thing = make Thing, name: 'thing', parent: @room introduction do |actor| actor.parent = @room end end
An entity that is not intended to be movable or portable by characters, similar to how Inform can define an object to be “fixed in place.”
An entity that characters can pick up with a command like
Note: any entity can be made portable by setting its
portable attribute, but Items are portable by default.
Portal provides a passage between rooms. They can be named using ordinal directions (e.g., “north” and “south”) or simply by their destination.
connect method connects rooms to each other.
Gamefic.script do @forest = make Room, name: 'forest', description: 'A placid forest.' @lake = make Room, name: 'lake', description: 'The edge of a lake.' connect @forest, @lake, 'east' introduction do |actor| actor.parent = @forest actor.perform :look end end
Thing that can contain other things. Receptacles can also be
enterable, which means that characters can get inside them.
Gamefic.script do @room = make Room, name: 'room' @cupboard = make Receptacle, name: 'cupboard', parent: @room @dish = make Item, name: 'dish', parent: @room @closet = make Receptacle, name: 'closet', enterable: true, parent: @room introduction do |actor| actor.parent = @room actor.tell 'You can put the dish in the closet or the cupboard.' actor.tell 'You can get inside the closet but not the cupboard.' end end
The default behavior for most entities is to list them when the player examines the room:
> look around Kitchen You're in a kitchen. You see a sink.
Scenery, on the other hand, is an entity that can be examined but does not get listed.
Gamefic.script do @kitchen = make Room, name: "kitchen", description: %( You're in a kitchen. The sink won't be included in the list of visible entities, but you can still examine it. ) @sink = make Scenery, name: "sink", description: "Most kitchens have one.", parent: @kitchen @dish = make Item, name: "plate", description: "A ceramic plate.", parent: @kitchen introduction do |actor| actor.parent = @kitchen end end
> look around Kitchen You're in a kitchen. The sink won't be included in the list of visible entities, but you can still examine it. You see a plate. > examine sink Most kitchens have one.
Other entities can also be excluded from the list of visible entities by setting its
itemized attribute to
Scenery with slightly modified action responses. As a general guideline,
Scenery is something that can’t be carried,
like a table or the sky; and
Rubble is something that might appear to be portable but is otherwise useless, like trash or debris.
Similar to a
Receptacle, except you put things “on” a
Supporter instead of “in” it.
Next: Creating custom commands