A character sheet, used to keep characteristics of any non-player character which should be persistent, allowing re-use of characters over time and across Lua scripts.
Additionally, one character sheet is initialised to keep the player’s information. Attributes in that character sheet begin as default values, and should be modified by the player’s conduct in the game.
Character is inspired by the GURPS table-top roleplaying system. In addition to details such as the character’s name, face, rank and so forth are a number of attributes. These attributes usually range from 4 to 64, although lower and higher numbers are valid. The attributes define the persona of the character, and represent the chance of that character’s success in various endeavours. These chances are tested by the virtual roll of four sixteen-sided dice. The target is to “roll under” for success.
So, if a character is trying to steal something, and there is an attribute called “theft” (hypothetical as I write), then we can determine whether that character succeeds by rolling the dice. A character who is a good thief would have a high number in their “theft” attribute, making it more likely that the dice roll result will be lower. If it’s lower, the theft succeeds.
Character sheets inherit their methods, and many default values, from the class itself.
Whilst some role-playing attributes are defined here, and can be given some random values using RollNew(), in practice any arbitrary attribute can be added to a character on demand, and these attributes can be safely tested on any character, whether defined or not. Undefined values return failure if tested using TestRoll().
Saving characters
There is a global table called PersistentCharacters. Character sheets can be stored in this table using the Save() method. This method checks whether the character sheet already exists in that table, and also updates the values of the persistence members (see below). Saved characters become available to other scripts.
Saved characters are indexed numerically, and can be retrieved with ipairs() and counted with the # operator. The player’s sheet is stored as PersistentCharacters.player, and is the special case.
Summary Character A character sheet, used to keep characteristics of any non-player character which should be persistent, allowing re-use of characters over time and across Lua scripts. Attributes player Boolean value; true if this instance of the table is for the player. name Name of character female Gender of character. seed Seed for predictable randomness, if one is required. title Job title, for use in BBS faces available Boolean value; whether this character is available for use by a mission. useCount Count of the number of times a script has used this character. lastSavedTime The game time, in seconds since 12:00 01-01-3200, that this character was last saved. lastSavedSystemPath The system path of the station or system at which this character was last saved. luck Integer attribute for roll-play style dice tests. charisma Integer attribute for roll-play style dice tests. notoriety Integer attribute for roll-play style dice tests. lawfulness Integer attribute for roll-play style dice tests. engineering (Crew skill) piloting (Crew skill) navigation (Crew skill) sensors (Crew skill) Methods New Returns a new character sheet, inheriting from Character, based on an optional template. Clone Clones a character sheet. DiceRoll Returns the results of a simulated 4xD16 roll. RollNew Uses DiceRoll to initialise the following attributes to random values:- luck, charisma, notoriety, lawfulness. TestRoll Uses DiceRoll to generate a random number, which it compares with the provided attribute. Save If the character is not already in the table of persistent characters, inserts the character into that table. Find Returns an iterator across all PersistentCharacters who match the specified filter. FindAvailable Returns an iterator across all PersistentCharacters where available is true CheckOut “Checks out” a persistent character, flagging it for exclusive use. UnSave Removes a character from the PersistentCharacters table Notes ChatForm. SetFace() You can pass a character directly to the SetFace() method of a ChatForm. Arbitrary attributes You are not limited to the documented attributes, and can define more on the fly.
Boolean value; true if this instance of the table is for the player. Only one character sheet should be that of the player. Useful if there’s the slightest chance of the player’s own sheet getting mixed up with those of NPCs.
future
experimental
Name of character
future
experimental
Gender of character. If true, character is female. If false, male.
future
experimental
Seed for predictable randomness, if one is required.
future
experimental
Job title, for use in BBS faces
future
experimental
Boolean value; whether this character is available for use by a mission. Used to “lock” a persistent character, so that two missions don’t use the same character at the same time. Not particularly meaningful for transient characters.
future
experimental
Count of the number of times a script has used this character. Used to determine how well used a character is.
future
experimental
The game time, in seconds since 12:00 01-01-3200, that this character was last saved.
future
experimental
The system path of the station or system at which this character was last saved. Save() sets this to that of Game.player, since character sheets have no intrinsic location. Can be directly set immediately after the call to Save() if it needs to be some other path.
future
experimental
Integer attribute for roll-play style dice tests. Luck is intended to reflect the character’s innate good fortune. Tested with 4xD16; useful values are 4 (never lucky) to 65 (always lucky). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
Integer attribute for roll-play style dice tests. Charisma is intended to reflect the character’s ability to win contracts or favrouable deals. Tested with 4xD16; useful values are 4 (always hated) to 65 (always liked). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
Integer attribute for roll-play style dice tests. Notoriety is intended to reflect how well the character’s reputation (good or bad) is known. Tested against 4xD16; useful values are 4 (complete nobody) to 65 (celebrity). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
Integer attribute for roll-play style dice tests. Lawfulness is intended to reflect the character’s willingness to break the law. Tested with 4xD16; useful values are 4 (going straight) to 65 (criminal). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
(Crew skill)
Integer attribute for roll-play style dice tests. Engineering is intended to reflect the character’s mechanical, electrical or other tecnical skills. Tests might be made against this attribute to see whether a character can repair a damaged piece of equipment, partially repair a ship, fit new equipment and so on. Tested with 4xD16; useful values are 4 (always fails) to 65 (always succeeds). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
(Crew skill)
Integer attribute for roll-play style dice tests. Piloting is intended to reflect the character’s skill at flying spacecraft. Tested with 4xD16; useful values are 4 (always crashes) to 65 (aerobat). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
(Crew skill)
Integer attribute for roll-play style dice tests. Navigation is intended to reflect the character’s skill at course plotting, mapping and so on. This might be tested to see whether a ship can gain additional range on a hyperspace jump, by having this character involved, or if, during a mission, a character succeeds in identifying a location based on clues, etc. Tested with 4xD16; useful values are 4 (always lost) to 65 (human compass). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
(Crew skill)
Integer attribute for roll-play style dice tests. Sensors is intended to reflect the character’s ability to get the most from a ship’s scanner, radar, etc. This skill might be tested to see if a hidden ship can be found, or an unknown item in space can be identified. Tested with 4xD16; useful values are 4 (blind) to 65 (no hiding from this guy). Modifiers can cause numbers outside this range to become useful (see TestRoll).
future
experimental
Returns a new character sheet, inheriting from Character, based on an optional template.
character = Character.New(template)
character a character sheet, which inherits from Character class
template (optional) a table containing default values
regular_joe = Character.New()
lucky_guy = Character.New({luck = 180})
future
experimental
Clones a character sheet.
clone = original:Clone()
clone a new character sheet, which inherits from Character class and is based on the original
-- How to clone lucky_guy new_guy = lucky_guy:Clone()
future
experimental
Returns the results of a simulated 4xD16 roll. Results are random, but distributed in a bell curve about the value 34. The minimum result is 4, and the maximum result is 64.
roll = Character.DiceRoll()
roll Integer value between 4 and 265 (inclusive), most likely 34
new_character.charisma = Character.DiceRoll()
future
experimental
Uses DiceRoll to initialise the following attributes to random values:- luck, charisma, notoriety, lawfulness.
If optional parameter “crew” is specified and is true, then also:- engineering, piloting, navigation, sensors.
crew If true, then RollNew() also sets random crew skills, which will normally become much higher than the default values.
new_character:RollNew()
new_character:RollNew(true)
future
experimental
Uses DiceRoll to generate a random number, which it compares with the provided attribute. If the generated number is less than the sum of the attribute and the provided modifier, it returns true. If it is greater, or the attribute does not exist, it returns false.
success = somebody:TestRoll('notoriety')
If the DiceRoll is from 4-8, then it was a critical failure and that attribute is abused. It is decremented by one for future tests.
If the DiceRoll is from 60-64, then it was a critical success and that attribute is exercised. It is incremented by one for future tests.
success Boolean value indicating that the test roll passed or failed
attribute The key of an attribute in this instance of the character table (such as luck, charisma, or any arbitrarily added attribute) modifier An arbitrary integer used to increase or decrease the odds of returning true or false. Positive values increase the odds of a true result, and negative values increase the odds of false. Default is zero.
if (player:TestRoll('lawfulness',20)) then UI.Message('A fellow criminal!')
If the character is not already in the table of persistent characters, inserts the character into that table. Also set available to true, and update the timestamp and location members.
Index of this character in PersistentCharacters table
attribute The key of an attribute in this instance of the character table (such as luck, charisma, or any arbitrarily added attribute) modifier An arbitrary integer used to increase or decrease the odds of returning true or false. Positive values increase the odds of a true result, and negative values increase the odds of false. Default is zero.
local BBS_characterID = BBS_character:Save()
Returns an iterator across all PersistentCharacters who match the specified filter.
iterator = Character.Find(filter)
filter an optional function. If specified, the function will be called once for each saved character with the Character object as the only parameter. If the filter function returns true then the body will be returned by the iterator, otherwise it will be omitted. If no filter function is specified then all bodies are returned.
iterator a function which will generate the returned results, returning one each time it is called until it runs out, after which it returns nil.
Print names of all female characters who have charisma > 36
for party_girl in Character.Find( function (NPC) return (NPC.female and (NPC.charisma > 36)) end) do print(party_girl.name) end
future
experimental
Returns an iterator across all PersistentCharacters where available is true
iterator = Character.FindAvailable()
iterator a function which will generate the returned results, returning one each time it is called until it runs out, after which it returns nil.
Print names of all characters
for person in Character.FindAvailable() do print(person.name) end
future
experimental
”Checks out” a persistent character, flagging it for exclusive use. Sets available to false, meaning that FindAvailable() will not return this character.
ch:CheckOut()
A character is checked back in using Save().
true The character was available, and has been marked unavailable false The character wasn’t available, or didn’t exist
future
experimental
Removes a character from the PersistentCharacters table
ch:UnSave()
Availability
future
experimental
You can pass a character directly to the SetFace() method of a ChatForm.
ch = Character:New() form:SetFace(ch)
You are not limited to the documented attributes, and can define more on the fly. Any attribute is testable using TestRoll(), and will return false if the attribute is undefined, meaning that it is not necessary to add an attribute to all instances of Character. This is handy for mission-specific skills or attributes.
some_character.geology = 45 -- a fairly high value
some_character.geology = Character.DiceRoll()
-- returns true or false, depending on chance if some_character:TestRoll('geology') then success() end
-- always returns false if other_character:TestRoll('geology') then success() end