Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Nov 26, 2021
2 parents 06d6c64 + 73c13c7 commit 1e57ed6
Show file tree
Hide file tree
Showing 42 changed files with 649 additions and 154 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><img src="https://raw.githubusercontent.com/JujuAdams/Chatterbox/master/LOGO.png" style="display:block; margin:auto; width:170px"></p>
<h1 align="center">2.1.1</h1>
<h1 align="center">2.2.0</h1>

<p align="center">Narrative engine for GameMaker Studio 2.3.2 by <b>@jujuadams</b></p>
<p align="center">Narrative engine for GameMaker Studio 2.3 by <b>@jujuadams</b></p>

&nbsp;

Expand Down
158 changes: 84 additions & 74 deletions chatterbox.yyp

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions datafiles/testcase_jump_include_variable.yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Start
---
<<declare $a = "Tar">>
<<declare $b = "get">>
<<jump ($a + $b)>>
===

title: Target
---
This is the target node.
===
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion objects/oTest/oTest.yy → objects/oBasics/oBasics.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions objects/oTestCaseDirection/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
if (CHATTERBOX_DIRECTION_MODE != 0)
{
__ChatterboxError("CHATTERBOX_DIRECTION_MODE should be 0 for this test");
}

if (CHATTERBOX_DIRECTION_FUNCTION != TestCaseDirectionFunction)
{
__ChatterboxError("CHATTERBOX_DIRECTION_FUNCTION should be TestCaseDirectionFunction for this test");
}

ChatterboxLoadFromFile("testcase_direction.yarn");
box = ChatterboxCreate();
ChatterboxJump(box, "Start");
5 changes: 5 additions & 0 deletions objects/oTestCaseDirectionAsExpression/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if (CHATTERBOX_DIRECTION_MODE != 1)
{
__ChatterboxError("CHATTERBOX_DIRECTION_MODE should be 0 for this test");
}

ChatterboxLoadFromFile("testcase_direction_as_expression.yarn");
box = ChatterboxCreate();
ChatterboxJump(box, "Start");
5 changes: 5 additions & 0 deletions objects/oTestCaseDirectionAsWeirdo/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if (CHATTERBOX_DIRECTION_MODE != 2)
{
__ChatterboxError("CHATTERBOX_DIRECTION_MODE should be 2 for this test");
}

ChatterboxLoadFromFile("testcase_direction_as_weirdo.yarn");
box = ChatterboxCreate();
ChatterboxJump(box, "Start");
3 changes: 3 additions & 0 deletions objects/oTestCaseJumpIncludeVariable/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ChatterboxLoadFromFile("testcase_jump_include_variable.yarn");
box = ChatterboxCreate();
ChatterboxJump(box, "Start");
44 changes: 44 additions & 0 deletions objects/oTestCaseJumpIncludeVariable/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
draw_set_font(fntDefault);

//Iterate over all text and draw it
var _x = 10;
var _y = 10;

if (ChatterboxIsStopped(box))
{
//If we're stopped then show that
draw_text(_x, _y, "(Chatterbox stopped)");
}
else
{
//All the spoken text
var _i = 0;
repeat(ChatterboxGetContentCount(box))
{
var _string = ChatterboxGetContent(box, _i);
draw_text(_x, _y, _string);
_y += string_height(_string);
++_i;
}

//Bit of spacing...
_y += 30;

if (ChatterboxIsWaiting(box))
{
//If we're in a "waiting" state then prompt the user for basic input
draw_text(_x, _y, "(Press Space)");
}
else
{
//All the options
var _i = 0;
repeat(ChatterboxGetOptionCount(box))
{
var _string = ChatterboxGetOption(box, _i);
draw_text(_x, _y, string(_i+1) + ") " + _string);
_y += string_height(_string);
++_i;
}
}
}
31 changes: 31 additions & 0 deletions objects/oTestCaseJumpIncludeVariable/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
if (ChatterboxIsStopped(box))
{
//If we're stopped then don't respond to user input
}
else if (ChatterboxIsWaiting(box))
{
//If we're in a "waiting" state then let the user press <space> to advance dialogue
if (keyboard_check_released(vk_space))
{
ChatterboxContinue(box);
}
else if (keyboard_check_pressed(ord("F")))
{
//The user can also press F to fast forward through text until they hit a choice
ChatterboxFastForward(box);
}
}
else
{
//If we're not waiting then we have some options!

//Check for any keyboard input
var _index = undefined;
if (keyboard_check_released(ord("1"))) _index = 0;
if (keyboard_check_released(ord("2"))) _index = 1;
if (keyboard_check_released(ord("3"))) _index = 2;
if (keyboard_check_released(ord("4"))) _index = 3;

//If we've pressed a button, select that option
if (_index != undefined) ChatterboxSelect(box, _index);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions objects/oTestCaseVariableAccess/Create_0.gml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//This should throw an error if CHATTERBOX_ERROR_UNDECLARED_VARIABLE is <true>

ChatterboxLoadFromFile("testcase_variable_access.yarn");
box = ChatterboxCreate("testcase_variable_access.yarn");
ChatterboxJump(box, "Start");
Expand Down
13 changes: 13 additions & 0 deletions options/operagx/options_operagx.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion options/windows/options_windows.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rooms/rmMain/rmMain.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions rooms/rmTest/rmTest.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions scripts/ChatterboxAddFindReplace/ChatterboxAddFindReplace.gml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// <<hammertime>>
/// <<stop>>
/// Replaces a portion of Chatterbox script with a different portion of text
/// This is performed before any compilation or parsing so can be used to insert commands into your scripts
///
/// @param oldString
/// @param newString
/// @param oldString The old string to replace
/// @param newString The new string to insert in place of the old string

function ChatterboxAddFindReplace(_old, _new)
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/ChatterboxGetVisited/ChatterboxGetVisited.gml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function ChatterboxGetVisited()
var _key = "visited(" + string(_filename) + CHATTERBOX_FILENAME_SEPARATOR + string(_node_title) + ")";
}

var _value = global.chatterboxVariablesMap[? _key];
var _value = CHATTERBOX_VARIABLES_MAP[? _key];
if (_value == undefined) return 0;
return _value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// Returns an array of node titles for the given source
///
/// @param sourceName

function ChatterboxSourceGetNodeTitles(_sourceName)
{
if (!ChatterboxIsLoaded(_sourceName))
{
__ChatterboxError("Source file \"", _sourceName, "\" has not been loaded");
return [];
}

var _i = 0;
var _array = [];

repeat (array_length(global.chatterboxFiles[? _sourceName].nodes))
{
array_push(_array,global.chatterboxFiles[? _sourceName].nodes[_i].title);
++_i;
}

return _array;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion scripts/ChatterboxVariableDefault/ChatterboxVariableDefault.gml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,35 @@

function ChatterboxVariableDefault(_name, _value)
{
if (string_pos(" ", _name))
{
__ChatterboxError("Chatterbox variable names must not contain spaces (\"", _name, "\")");
exit;
}

if (!is_numeric(_value) && !is_string(_value) && !is_bool(_value))
{
__ChatterboxError("Chatterbox variable values must be a number, a string, or a boolean (variable = \"", _name, "\", datatype = \"", typeof(_value), "\", value = ", _value, ")");
exit;
}

global.chatterboxVariablesMap[? _name] = _value;
if (ds_map_exists(global.__chatterboxDefaultVariablesMap, _name))
{
if (CHATTERBOX_ERROR_REDECLARED_VARIABLE)
{
__ChatterboxError("Trying to re-declare default value for Yarn variable $", _name, " (=", __ChatterboxReadableValue(_value), ")");
}
else
{
__ChatterboxTrace("Warning! Trying to re-declare default value for Yarn variable $", _name, " (=", __ChatterboxReadableValue(_value), ")");
}
}
else
{
CHATTERBOX_VARIABLES_MAP[? _name] = _value;
global.__chatterboxDefaultVariablesMap[? _name] = _value;
ds_list_add(CHATTERBOX_VARIABLES_LIST, _name);

__ChatterboxTrace("Declared Yarn variable $", _name, " (= ", __ChatterboxReadableValue(_value), ")");
}
}
Loading

0 comments on commit 1e57ed6

Please sign in to comment.