A Fact encapsulates an item of knowledge (or supposed knowledge) keyed on the fact tags in the appropriate object's informedNameTab. Note that for the purposes of thid module, a Fact is not something that is necessarily true, but simply somethhing that some actor or Consultable in the game has asserted to be true.
class
Fact : object
Superclass Tree (in declaration order)
Fact
object
Subclass Tree
(none)
Global Objects
(none)
Summary of Properties
adjustedPriority
defaultTruthValue
desc
factDescs
initiallyKnownBy
listOrder
name
pcComment
pcCommentTab
priority
relevant
sourcepat
sourcesListed
sourcesTab
targetsTab
topics
Summary of Methods
addSource
addTarget
construct
currentlyKnownBy
getPcComment
getSources
getTargets
initializeFact
qualifiedDesc
setPcComment
sourceIntro
Properties
Deduct our listOrder from our priority to get the adjustedPriority that will actualy be used to sort facts in the desired order. This allows game authors to use either property (or possibly a combination of both) to determine the listing order.
The truth value that most characters in this game are likely to assign to this fact. The other possible values defined in the library are likely, dubious, unlikely and untrue. Game authors are free to invent other values if they wish.
Our descripition. This should a single-quoted string with no closing punctuation that could follow 'that'; for example 'Spain is a country in Europe' or 'it rained yesterday'
A list of alternate fact descriptions that can be referenced by the optional msg parameter of various TopicEntry methods. If present, the elements of the list should be single-quoted strings.
The list of actors and other objects - typically Consultables - that start the game knowing about us. If any actors in the list should start out dissenting from the defaultTruthValue for this fact then this can be set by using two item list of the form [actor, value] in place of just the actor, e.g. you could have [me, bob, susan, [thomas, dubious]].
Alternatively we can use our list order to determine the order in which facts will be listed. By default we use give everything a list order of 1.
Our name is the fact tag (used in gInformed() stateement or the like) that identifies us.
A single-quoted string containing the initial player character's initial comment or thought on this Fact; this can be left at nil if the PC doesn't have one. This will be appended to the description of this Fact when listed by a Thought, so should be a sentence fragment starting with a lower case letter (or some form of parenthetic punctuation) and without a full stop at the end.
A table containing player characters' comments on this Fact. We use a LookpTable here in case the player character changes, so we can retrieve the comment relevant to the current player character
Our priority (what is our relevant importance). Facts with a higher priority will be listed earlier in any list of facts. We set a defaul priority of 100.
Most Facts start out relevant and continue to be so, but some may cease to be relevant when game circumstances change, in which case we can change relevant to nil (or set it to an expression that evaluates to nil), so that it's no longer listed in response to THINK ABOUT.
Our RexPattern for searching for a string of characters between square brackets, e.g. [bob]
Used internally to build a list of sources (of this fact) to be listed (typically in response to a THINK ABOUT command.
LookUpTable containing lists of which sources have imparted this Fact to which actor; actor defaults to gPlayerChar we use a LookUpTable here in case the player character changes during the courss of play.
LookUpTable containing lists of whom actor has imparted this Fact; actor defaults to gPlayerChar we use a LookUpTable here in case the player character changes during the courss of play.
The list of topics (Topics and Things, i.e. game objects) that this fact relates to.
Methods
addSource (source, actor, =, gPlayerChar) | facts.t[231] |
Add a source (of information) to our sourcesTab table.
addTarget (target, actor, =, gPlayerChar) | facts.t[252] |
Add a target to our targetTab table
construct (name_, desc_, topics_, initiallyKnownBy_) | facts.t[450] |
Our constructor for creating a new Fact object dynamically under progrem control. name_ is the fact tag name; desc_ is the Fact's descroption; topics_ is the list of topics to which this new Fact relates; initiallyKnownBy_ is the actor or list of actors who start out knowing aboout this new Fact.
Obtain a list of everything that knows this fact
Get the current player character's comment on this Fact; source is the source from which the PC learned the Fact and topic is the topic the Player Character is thinking about. By default this method returns different results for different player characters, but game code will need to override this method to return different comments for different sources and/or topics.
Get a list of the sources who have imparted this Fact to actor; actor dafaults to the player character and must normally have been the player character at some point for this to return anything but an empty list.
Get a list of the targets actor has imparted this Fact to; actor dafaults to the player character and must normally have been the player character at some point for this to return anything but an empty list.
Initialise this fact at preInit.
qualifiedDesc (source, topic, sender) | facts.t[42] |
We can if we wish vary the way this fact is described according to the source that's supplying it and the topic matched by the TopicEntry that's called this method; by default we just return desc here. Note that any such variation shouldn't change the content of the description but only the way it's phrased; e.g. 'Madrid is the capital of Spain' rather than 'the capital of Spain is Madrid' depending on whether the topic is Madrid or Spain.
By default we try to adapt the desc to the source and sender if it contains an actorParamName in square brackets, e.g. [bob], which we replace with 'Bob', 'I' or 'he' according to context.
Set actor's comment on this fact; normally actor will be the current player character; txt is a single-quoted string containing the comment, which will usually be appended to the description of the fact.
If our caller wants to list sources of information (listSources = true), then return a string containing a suitably formatted list of sources; otherwise return nil. This can then be used by TopicEntries (typically Thoughts) that want to list the sources of information along with the content of that information.
Adv3Lite Library Reference Manual
Generated on 03/07/2024 from adv3Lite version 2.1