Lua API Reference: Difference between revisions

From Bonfire by Hogswild Prasetto
bonfire-wiki>Sonic260
bonfire-wiki>Sonic260
Some typo fixes and added consistent table width.
Line 3: Line 3:
== Lua Console Commands ==
== Lua Console Commands ==
This table comprises the list of Lua-related console commands to actually inject, run, or even delete scripts from the console target's inventory. These can be placed into a scroll, macro, or NPC's CustomCall action during dialogue.
This table comprises the list of Lua-related console commands to actually inject, run, or even delete scripts from the console target's inventory. These can be placed into a scroll, macro, or NPC's CustomCall action during dialogue.
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Command
! Command
! Usage
! Usage
Line 11: Line 11:
| oluainj luaScriptName
| oluainj luaScriptName
| Injects a Lua script within the console target's inventory.
| Injects a Lua script within the console target's inventory.
Lua Scripts must be stored within the Lua directory, located at
Scripts must be stored within the Lua directory, located at


''%appdata%/Prasetto/Bonfire/Mods/lua''
''%appdata%/Prasetto/Bonfire/Mods/lua''
Line 18: Line 18:
| oluacf
| oluacf
| oluacf luaScriptName,functionName
| oluacf luaScriptName,functionName
|Executes a single function within an injected Lua script once
|Executes a single function within an injected script once
|-
|-
| oluaiifr
| oluaiifr
| oluaiifr luaScriptName,functionName,duration
| oluaiifr luaScriptName,functionName,duration
|Causes a single Lua function to iterate, and execute repeatedly for a set ''duration''. When the duration, the iteration will stop.
|Causes a single function to iterate, and execute repeatedly for a set ''duration''. When the duration is exceeded the iteration will stop.
'''Tip''': Set ''duration ''to "Infinity" will make the script run forever.
'''Tip''': Setting ''duration ''to "Infinity" will make the script run forever.


|-
|-
Line 30: Line 30:


oluaria
oluaria
|Stops an iterating function within a Lua script. Using '''oluaria''' with no parameters will stop ''all ''iterating scripts within the console target.
|Stops an iterating function within a Lua script. Using '''oluaria''' with no parameters will stop ''all ''iterating scripts on the console target.
|-
|-
| oluarem
| oluarem
Line 38: Line 38:
== Automatic Functions / Code ==
== Automatic Functions / Code ==
This code will execute automatically when injected into the target's inventory using the '''oluainj''' command. This removes the need to run functions manually with '''oluacf''' or '''oluaiifr'''. ''Note: ''The '''start()''' and '''update()''' functions will not run automatically if injected as an OrcLuaScript action with macros.
This code will execute automatically when injected into the target's inventory using the '''oluainj''' command. This removes the need to run functions manually with '''oluacf''' or '''oluaiifr'''. ''Note: ''The '''start()''' and '''update()''' functions will not run automatically if injected as an OrcLuaScript action with macros.
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 49: Line 49:
| update
| update
| void
| void
| The update() function will start an iterator that runs for Infinity seconds upon injection.
| The update() function will start an iterator that runs for Infinity upon injection.
|-
|-
| [chunk space]
| [chunk space]
Line 61: Line 61:


=== Targeting ===
=== Targeting ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 68: Line 68:
| orcobjective
| orcobjective
| Orc
| Orc
|Returns this instance’s current “target” as another Orc instance. Functions and properties can be manipulated on the other instance by calling '''orc.orcobjective.'''* before every command:
|Returns this instance’s current “target” as another Orc instance. Functions and properties can be called on the other instance by calling '''orc.orcobjective.'''* before every command:
* orc.'''orcobjective'''.istheplayer – Returns true if this objective is the player
* orc.'''orcobjective'''.istheplayer – Returns true if this objective is the player
* orc.'''orcobjective'''.height = 1.5 – sets the objective’s height to 1.5
* orc.'''orcobjective'''.height = 1.5 – sets the objective’s height to 1.5
It is also possible to store the objective in a separate variable for use later:
It is also possible to store the objective in a separate variable:
* local target = orc.'''orcobjective'''
* local target = orc.'''orcobjective'''
* target.istheplayer
* target.istheplayer
* target.height = 1.5
* target.height = 1.5
'''Warning: '''An instance’s objective changes frequently, so it is recommended that you store the objective in a separate variable as soon as possible for reference. The objective can also return ‘'''nil'''’, so it is recommended that you first perform a nil check before attempting to call a function or property on them..  
'''Warning: '''An instance’s objective changes frequently, so it is recommended that you store the objective in a separate variable as soon as possible for reference. The objective can also return ‘'''nil'''’, so it is recommended that you first perform a nil check before attempting to call a function or property on them.  
|-
|-
| canseeorcobjective
| canseeorcobjective
| bool
| bool
| Returns true if the objective (this instance’s current “target”) is with line of sight
| Returns true if the objective (this instance’s current “target”) is within line of sight
|-
|-
| canseeinterest
| canseeinterest
Line 95: Line 95:


=== Positioning ===
=== Positioning ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 109: Line 109:


=== Physical Attributes ===
=== Physical Attributes ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 224: Line 224:


=== Flags / Booleans ===
=== Flags / Booleans ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 283: Line 283:


=== Misc Properties ===
=== Misc Properties ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 324: Line 324:


=== Targeting ===
=== Targeting ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 357: Line 357:


=== Sex ===
=== Sex ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 392: Line 392:


=== Data Flags ===
=== Data Flags ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 416: Line 416:
=== Sounds ===
=== Sounds ===
These functions will play an in-game sound, with a volume level between 0.0 and 1.0
These functions will play an in-game sound, with a volume level between 0.0 and 1.0
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 446: Line 446:
|}
|}
=== Misc Functions ===
=== Misc Functions ===
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 486: Line 486:
== Orc.Game Properties ==
== Orc.Game Properties ==
These are special commands that access internal, game-related properties within Bonfire. They can all be accessed by typing orc.'''game.* '''before each call. For example, to pull up a random integer, you would write orc.'''game.'''randomInt(1,10) to pull a random integer between 1 and 10.
These are special commands that access internal, game-related properties within Bonfire. They can all be accessed by typing orc.'''game.* '''before each call. For example, to pull up a random integer, you would write orc.'''game.'''randomInt(1,10) to pull a random integer between 1 and 10.
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 493: Line 493:
| deltatime
| deltatime
| float
| float
| A Unity property representing the elapsed time, in seconds, since the last frame.
| A Unity property representing the elapsed time--in seconds--since the last frame.
This is useful for scripts that rely on an internal timer.
This is useful for scripts that rely tracking time.


More information can be found in the Unity Scripting API [https://docs.unity3d.com/ScriptReference/Time-deltaTime.html here]:  
More information can be found in the Unity Scripting API [https://docs.unity3d.com/ScriptReference/Time-deltaTime.html here]:  
Line 500: Line 500:
| consoleasset
| consoleasset
| Asset
| Asset
| Returns the last asset created with the asset console command.
| Returns the last asset created with the '''asset''' console command.
|}
|}


== Orc.Game Functions ==
== Orc.Game Functions ==
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type
Line 563: Line 563:
== Asset Properties ==
== Asset Properties ==
These functions affect assets that have been spawned within the game. To invoke them, you would write ''assetVariableName.assetFunction(). ''At the moment, not much is known about asset manipulation, so the amount of known commands is limited.
These functions affect assets that have been spawned within the game. To invoke them, you would write ''assetVariableName.assetFunction(). ''At the moment, not much is known about asset manipulation, so the amount of known commands is limited.
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Property Name
! Property Name
! Type
! Type
Line 574: Line 574:


== Asset Functions ==
== Asset Functions ==
{| class="wikitable"
{| class="wikitable" style="width: 100%"
! Function Name
! Function Name
! Return Type
! Return Type

Revision as of 14:49, 12 April 2020

This page contains documentation for all the known functions within the Lua Bonfire API. For more information for running Lua code in Bonfire, please see the Lua scripting page.

Lua Console Commands

This table comprises the list of Lua-related console commands to actually inject, run, or even delete scripts from the console target's inventory. These can be placed into a scroll, macro, or NPC's CustomCall action during dialogue.

Command Usage Effect
oluainj oluainj luaScriptName Injects a Lua script within the console target's inventory.

Scripts must be stored within the Lua directory, located at

%appdata%/Prasetto/Bonfire/Mods/lua

oluacf oluacf luaScriptName,functionName Executes a single function within an injected script once
oluaiifr oluaiifr luaScriptName,functionName,duration Causes a single function to iterate, and execute repeatedly for a set duration. When the duration is exceeded the iteration will stop.

Tip: Setting duration to "Infinity" will make the script run forever.

oluaria oluaria luaScriptName,functionName

oluaria

Stops an iterating function within a Lua script. Using oluaria with no parameters will stop all iterating scripts on the console target.
oluarem oluarem luaScriptName Removes the Lua script from the target's inventory. This will also stop any related iterators.

Automatic Functions / Code

This code will execute automatically when injected into the target's inventory using the oluainj command. This removes the need to run functions manually with oluacf or oluaiifr. Note: The start() and update() functions will not run automatically if injected as an OrcLuaScript action with macros.

Function Name Return Type Description /Usage
start void The start() function will execute once upon injection.
update void The update() function will start an iterator that runs for Infinity upon injection.
[chunk space] N/A “Chunk Space” refers to any code lying outside of a function within a Lua file. This code will execute once upon injection AND whenever the holder enters a new scene.

This is typically used for setting variables and preemptively granting data flags.

Orc Properties

These are properties--or variables--belonging to an Orc instance, and are accessible by writing orc.* before every call. In all cases "orc" will always refer to the instance who is running the script from within their inventory. For example: "orc.istheplayer" returns "true" if this orc is the player, and "orc.height = 1.5" sets this orc's height to 1.5.

Targeting

Property Name Type Description / Usage
orcobjective Orc Returns this instance’s current “target” as another Orc instance. Functions and properties can be called on the other instance by calling orc.orcobjective.* before every command:
  • orc.orcobjective.istheplayer – Returns true if this objective is the player
  • orc.orcobjective.height = 1.5 – sets the objective’s height to 1.5

It is also possible to store the objective in a separate variable:

  • local target = orc.orcobjective
  • target.istheplayer
  • target.height = 1.5

Warning: An instance’s objective changes frequently, so it is recommended that you store the objective in a separate variable as soon as possible for reference. The objective can also return ‘nil’, so it is recommended that you first perform a nil check before attempting to call a function or property on them.

canseeorcobjective bool Returns true if the objective (this instance’s current “target”) is within line of sight
canseeinterest bool An “interest” is like a lighter version of “objective." It refers to the orc our instance is looking at, but not necessarily targeting.
istheplayer bool Returns true if instance is the player.
distancetoobjective float Returns the distance to the objective.

Positioning

Property Name Type Description / Usage
positionx

positiony

positionz

float The instance’s current x, y, or z position in the world.

Physical Attributes

Property Name Type Description / Usage
ballsize float Max is 2.0
beardlength float
beardstubble float
bodyfat float
bodyhair float
coatdensity float
earshape float
earsize float
extrabutt float
footsize float
haircolor1_[r,g,b] float Hair Color A in the character editor
haircolor2_[r,g,b] float Hair Color B in the character editor
hairlength float
handgirth float
headcrown float
height float Max is 1.5, but clamps to 1.0 during stage 1 of corruption.
jawsize float
lipgirth float
muscle float
penisextra float
penisgirth float Max is 4.0, but clamps to 2.0 during corruption
penisshower float
penissize float
skincolormid_[r,g,b,m] float Skin Color – Upper Layer
skincolortop_[r,g,b,m] float Skin Color – Sun Bleach
skincolorund_[r,g,b,m] float Skin Color – Lower Layer
tusksize float

Flags / Booleans

Property Name Type Description / Usage
afterglowing bool Returns true if the instance is afterglowing right after orgasming during a sex scene
busywalking bool Returns true if the instance is currently walking to a destination
cumming bool Returns true if, during a sex scene, the instance is orgasming
immutable bool Returns true if this instance is either a ghost or special character that cannot be altered by transformation spells nor corruption
isairborne bool Returns true if the instance is floating in mid air
isbusy bool Returns true if the instance is doing literally anything else besides standing
isfapping bool Returns true if the instance is doing a standing fap. (Does not apply to Self-Action, or solo fapping on the Inn or Island Beds)
isgeniefragment bool Returns true if this instance is an NPC genie fragment (ie: Eves, Levi; not a geniefied orc)
isghost bool Returns true if the instance is a ghost
issexing bool Returns true if the instance is in a sex animation (This includes Self-Action, and Handjobs in the Bath House)
istalking bool Returns true if the instance is in a dialogue
onatask bool Returns true if the instance is busy doing some task like casting a spell or sexing
perfectglowing bool Returns true if the instance has achieved a perfect synchronized orgasm during a sex scene

Misc Properties

Property Name Type Description / Usage
arousal float Returns the instance’s current arousal level.

The value range is 0.0 – 1.0

corruption float Returns the instances level of corruption.

The value range is 0.0 – 3.0, where 1.0 is the cap before becoming a genie

infinity float Returns a floating number representing infinity.
orcname string The instance’s name
mana float Returns the instance’s current mana amount
maxmana float Returns the instance’s total mana pool.

Note: this is a read-only property.

manareg float Returns the instance’s current mana regeneration rate

Note: this is a read-only property.

Orc Functions

Targeting

Function Name Return Type Usage Description
findclosest Orc findclosest(range:float) Returns an Orc instance within a set range. Returns nil if none is found.
findnextclosest Orc findnextclosest(range:float, target:Orc) Returns an Orc instance within range of another instance. Returns nil if none is found.
getclosest void getclosest(range:float) Changes this instance’s current objective to the closest orc in range. orcobjective will be nil if none is found.
getclosestpureorc void getclosestpureorc(range:float) Changes this instance’s current objective to the closest, non-corrupted instance in range. orcobjective will be nil if none is found.
orcobjset void orcobjset(orcName:string) Set this instance’s current objective to the orc with a name matching orcName. orcobjective will be nil if none is found.

Sex

Function Name Return Type Description / Usage
cum void The instance will cum once. If this occurs during sex, this will contribute to the orgasm meter.
endsex void This instance will stop sexing.
fapstart void Makes the instance fap.
fapstop void Stops the instance from fapping.
sexanal1 void Starts the doggy style sex scene at the nearest circle.
sexanal2 void Starts the missionary style sex scene at the nearest circle.
sex69 void Starts a 69 where the instance is standing

Data Flags

Function Name Return Type Usage Description
hasitemflag bool hasitemflag(flagName:string, flagData:string) Returns “true” if the instance has a data called flagName, regardless of its actual value.
ifitemflag bool ifitemflag(flagName:string, flagData:string) Returns “true” if the instance has a data flag called flagName, with a value matching flagData.
setitemflag void setitemflag(flagName:string,flagData:string) Sets the value of a data flag called flagName to flagData. If this flag doesn’t exist, a new flag matching flagName will be created.

Sounds

These functions will play an in-game sound, with a volume level between 0.0 and 1.0

Function Name Return Type Usage
soundbrass void soundbrass(volume:float)
soundbreath void soundbreath(volume:float)
soundbreathlesser void soundbreathlesser(volume:float)
sounddeepbreath void sounddeepbreath(volume:float)
sounddeepbreathlesser void sounddeepbreathlesser(volume:float)
soundtimpani void soundtimpani(volume:float)

Misc Functions

Function Name Return Type Usage Description
consolecommand void consolecommand(command:string) Executes a console command (including a batch command). The default target is the Orc instance calling the function
forcerotation void forcerotation(x:float, y:float, z:float) Rotates the orc. Note: It is recommended that you only rotate on the y-axis. Rotating on x or z could tilt the orc.
luacopyover void luacopyover(a:Orc, b:Orc, scriptName:string) Copies a lua script from a’s inventory to b’s inventory, if it exists.
luaiterator void luaiterator(scriptName:string, functionName:string, duration:float) Executes and iterates a function within a script, for a set duration.

Use orc.Infinity to make the script run forever

remscript void remscript(scriptName: string) Removes the specified script from this instance's inventory
tp2pos void tp2pos(x:float, y:float, z:float) Warps the instance to the x, y, and z coordinates specified

Orc.Game Properties

These are special commands that access internal, game-related properties within Bonfire. They can all be accessed by typing orc.game.* before each call. For example, to pull up a random integer, you would write orc.game.randomInt(1,10) to pull a random integer between 1 and 10.

Property Name Type Description / Usage
deltatime float A Unity property representing the elapsed time--in seconds--since the last frame.

This is useful for scripts that rely tracking time.

More information can be found in the Unity Scripting API here:

consoleasset Asset Returns the last asset created with the asset console command.

Orc.Game Functions

Function Name Return Type Usage Description
backeaseinout float backeaseinout(value; float) Takes a value between 0.0 and 1.0 and returns a cubic curve between the two numbers that is close, but not equal to, either. Intended to be used with lerp
cos float cos(value:float) Returns the cosine
sine float sin(value:float) Returns the sine
cycle float cycle(value:float, length:float) Based on the Mathf.Repeat() function in Unity. It returns the modulo (%) of two numbers, except this works for floating point numbers as well. It does not allow negative inputs.
flatstutter float flatstutter(value:float) Same as backeaseinout, except the number jerks as it approaches either end.
lerp float lerp(min:float, max:float, speed:float) Linearly interpolates between two values at a specified speed.
movetowards float movetowards(value1:float, value2:float, rate:float) Returns a number between value1 and value2, increased by rate. Useful for creating a growth script where an attribute increases to the max level.
randomint int randomint(min:int, max:int) Returns a random integer between the min value and the max value.
distancebetweenorcs float distancebetweenorcs(orcA:Orc, orcB:Orc) Returns the distance between two orc instances
orcfromcommandname Orc orcfromcommandname(orcName:String) Returns an orc named orcName from within the current scene, without changing the orc’s interest or objective in the process.

Asset Properties

These functions affect assets that have been spawned within the game. To invoke them, you would write assetVariableName.assetFunction(). At the moment, not much is known about asset manipulation, so the amount of known commands is limited.

Property Name Type Description / Usage
consoleasset Asset Returns the last asset created with the asset console command.

Asset Functions

Function Name Return Type Usage Description
distancetoasset float game.distancetoasset(target:Orc, spawnedAsset:Asset) Returns the distance between the Orc instance and a specific asset
rotate void rotate(x:float, y:float, z:float, local:bool) Rotates the asset on the x, y, and z axis. Local determines if this rotation occurs on the asset’s local axis.
translate void translate(x:float, y:float, z:float, locaI:bool) Moves the asset on the x, y, and z axis. Local determines if this rotation occurs on the asset’s local axis.