Lua scripting: Difference between revisions

From Bonfire by Hogswild Prasetto
bonfire-wiki>Hogswild
m added code box
bonfire-wiki>Hogswild
m More info
Line 8: Line 8:
This action will inject a lua script into your orc. Normally, the injection only initializes the script and keeps it in memory, so that no further injections are necessary. A good use of this action would be to place it at the very beginning of your macro and have its code nested under handy functions that we call later using a different action. Further executions of the same action on the same macro line will not re-inject the code when an instance of the same lua script with the same ID name already exists, so you can safely loop through your macro as usual without having it re-interpret your action's script.
This action will inject a lua script into your orc. Normally, the injection only initializes the script and keeps it in memory, so that no further injections are necessary. A good use of this action would be to place it at the very beginning of your macro and have its code nested under handy functions that we call later using a different action. Further executions of the same action on the same macro line will not re-inject the code when an instance of the same lua script with the same ID name already exists, so you can safely loop through your macro as usual without having it re-interpret your action's script.


Here is an example of a lua script being injected:
Here is an example of a lua script to be injected:
  function start ()
  function start ()
   
   
Line 32: Line 32:
   
   
  end
  end
This code injects only one function named '''start '''that does a series of setup adjustments to the character Bo, in order to have him hold his pipe. Remember that this code is not being executed upon injection; only later on we will call this and any other function that your script contains.
=== OrcLuaScriptFunction ===
This action will let you execute any of the functions contained in a lua script that were previously injected using the '''OrcLuaScript''' action.

Revision as of 11:38, 1 July 2019

Article under construction

Lua scripts and proceses are similar to that of macros and dialogue conditionals, where a series of operations and checks are made in order to allow players to essentially mod the game by adding new gameplay mechanics.

The feature is wrapped inside classic macros and dialogue trees in the form of two main dialogue actions:

OrcLuaScript

This action will inject a lua script into your orc. Normally, the injection only initializes the script and keeps it in memory, so that no further injections are necessary. A good use of this action would be to place it at the very beginning of your macro and have its code nested under handy functions that we call later using a different action. Further executions of the same action on the same macro line will not re-inject the code when an instance of the same lua script with the same ID name already exists, so you can safely loop through your macro as usual without having it re-interpret your action's script.

Here is an example of a lua script to be injected:

function start ()

    if orc.game.sceneis ('Outback1') then

        -- give him the pipe from the start

        orc.game.consolecommand ('asset bopipe')

        if orc.game.consoleasset == nil then

            orc.consolecommand ('batch target @self;asset World/Items/Pipe1;assetnameset bopipe;hrattachca;assetpos -0.0289,0.0571,-0.0238,-21.348,-118.294,217.56,true;assetscalereset')

        else

            orc.consolecommand ('batch target @self;hrattachca;assetpos -0.0289,0.0571,-0.0238,-21.348,-118.294,217.56,true;assetscalereset')

        end

        orc.consolecommand ('forceanim Idle SmokePipe1')

    end

end

This code injects only one function named start that does a series of setup adjustments to the character Bo, in order to have him hold his pipe. Remember that this code is not being executed upon injection; only later on we will call this and any other function that your script contains.

OrcLuaScriptFunction

This action will let you execute any of the functions contained in a lua script that were previously injected using the OrcLuaScript action.