Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions Scripts/Bindings/BindExamples.sh

This file was deleted.

6 changes: 0 additions & 6 deletions Scripts/Source/AutoBindToPlayer.psc

This file was deleted.

8 changes: 0 additions & 8 deletions Scripts/Source/BindMeToGeneratedObjectFormID.psc

This file was deleted.

6 changes: 0 additions & 6 deletions Scripts/Source/BindMeToHodByEditorID.psc

This file was deleted.

6 changes: 0 additions & 6 deletions Scripts/Source/BindMeToMultipleTargets.psc

This file was deleted.

6 changes: 0 additions & 6 deletions Scripts/Source/BindMeToPlayer.psc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scriptName DocStringBindToHod extends Actor
scriptName _Bind_Actor_EditorID extends Actor
{!BIND HodRef}

event OnInit()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scriptName DocStringBindToNPCs extends Actor
scriptName _Bind_Actor_Multiple extends Actor
{
!BIND HodRef
!BIND SvenRef
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scriptName DocStringBindToMultipleTargets extends Actor
scriptName _Bind_Actor_Multiple_OneLine extends Actor
{
!BIND SvenRef|0x1348A|$Player|HildeRef
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scriptName DocStringBindToPlayer extends Actor
scriptName _Bind_Actor_Player extends Actor
{!BIND}

event OnInit()
Expand Down
10 changes: 10 additions & 0 deletions Scripts/Source/_Bind_Object_EditorID.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
scriptName _Bind_Object_EditorID extends ObjectReference
{
# I can't think of objects with Editor IDs except for Actors
!BIND SvenRef
}

event OnInit()
string script = StringUtil.Substring(self, 1, StringUtil.Find(self, " ") - 1)
Debug.Trace("[!BIND] Script " + script + " bound to " + self + " " + GetBaseObject().GetName())
endEvent
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
scriptName BindMeToHodByID extends Actor
scriptName _Bind_Object_FormID extends ObjectReference
{
# The Merchant Chest in WEMerchantChests
!BIND 0xBBCD1
}

event OnInit()
string script = StringUtil.Substring(self, 1, StringUtil.Find(self, " ") - 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scriptName BindMeToGeneratedObject extends ObjectReference
scriptName _Bind_Object_Generated extends ObjectReference
{!BIND}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scriptName BindMeToGeneratedObjectEditorID extends ObjectReference
scriptName _Bind_Object_Generated_BaseEditorID extends ObjectReference
{!BIND $Object(FoodSweetRoll)}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scriptName AutoBindToGeneratedObject extends ObjectReference
scriptName _Bind_Object_Generated_BaseFormID extends ObjectReference
{!BIND $Object(0x64B3F) # Cabbage}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
scriptName BindMeToGeneratedQuestWithName extends Quest
scriptName _Bind_Quest_EditorID extends Quest
{!BIND MQ101}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
string script = StringUtil.Substring(self, 1, StringUtil.Find(self, " ") - 1)
Debug.Trace("[!BIND] Script " + script + " bound to " + GetID())
Debug.Trace("[bind generated object ] " + self) ; <--- not picked up by tests, but viewable in logs
endEvent
21 changes: 21 additions & 0 deletions Scripts/Source/_Bind_Quest_FormID.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
scriptName _Bind_Quest_FormID extends Quest
{
Truth Ore Consequences
!BIND 0x5B2DE
^--- attaching to a quest that starts on game start can result in multiple OnInit() calls
}

event OnInit()
GotoState("Initialized")
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
string script = StringUtil.Substring(self, 1, StringUtil.Find(self, " ") - 1)
Debug.Trace("[!BIND] Script " + script + " bound to " + GetID())
endEvent

state Initialized
event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
string script = StringUtil.Substring(self, 1, StringUtil.Find(self, " ") - 1)
Debug.Trace("[!BIND] Script " + script + " bound to " + GetID() + " ALREADY INITIALIZED!")
endEvent
endState
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scriptName AutoBindToGeneratedQuest extends Quest
scriptName _Bind_Quest_Generated extends Quest
{!BIND}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scriptName BindMeToGeneratedQuest extends Quest
scriptName _Bind_Quest_Generated_EditorID extends Quest
{!BIND $Quest(MyGeneratedQuest)}

event OnInit()
; If this will be an 0xFF dynamic form, do not print out `self` (it't not deterministic, which we want for tests)
Expand Down
26 changes: 0 additions & 26 deletions plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace SkyrimScripting::Bind {
constexpr auto BIND_COMMENT_PREFIX = "!BIND";
constexpr auto DEFAULT_JSON = R"({"mtimes":{},"scripts":{}})";
constexpr auto JSON_FILE_PATH = "Data\\SkyrimScripting\\Bind\\DocStrings.json";
constexpr auto BINDING_FILES_FOLDER_ROOT = "Data\\Scripts\\Bindings";

void LowerCase(std::string& text) {
std::transform(text.begin(), text.end(), text.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
Expand Down Expand Up @@ -184,35 +183,10 @@ namespace SkyrimScripting::Bind {
ProcessBindingTarget(bindTarget);
}

void ProcessBindingFile() {
logger::info("Reading Binding File: {}", FilePath);
LineNumber = 1;
std::string line;
std::ifstream file{FilePath, std::ios::in};
while (std::getline(file, line)) {
LineNumber++;
try {
ProcessBindingLine(line);
} catch (...) {
logger::info("BIND ERROR [{}:{}]", FilePath, LineNumber);
}
}
file.close();
}

void ProcessAllBindingFiles() {
if (!std::filesystem::is_directory(BINDING_FILES_FOLDER_ROOT)) return;
for (auto& file : std::filesystem::directory_iterator(BINDING_FILES_FOLDER_ROOT)) {
FilePath = file.path().string();
ProcessBindingFile();
}
}

void OnGameStart() {
vm = RE::BSScript::Internal::VirtualMachine::GetSingleton();
DefaultBaseFormForCreatingObjects = RE::TESForm::LookupByID(0xAEBF3); // DwarvenFork
LocationForPlacingObjects = RE::TESForm::LookupByID<RE::TESObjectREFR>(0xBBCD1); // The chest in WEMerchantChests
ProcessAllBindingFiles();
for (auto binding : BindingLinesFromComments) ProcessBindingLine(binding);
}

Expand Down
48 changes: 24 additions & 24 deletions spec/ExpectedOutput.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[!BIND] Script AutoBindToGeneratedObject bound to Fork
[!BIND] Script AutoBindToGeneratedQuest bound to
[!BIND] Script AutoBindToPlayer bound to [AutoBindToPlayer < (00000014)>] Prisoner
[!BIND] Script BindMeToGeneratedObject bound to Fork
[!BIND] Script BindMeToGeneratedObjectEditorID bound to Sweet Roll
[!BIND] Script BindMeToGeneratedObjectFormID bound to Sweet Roll
[!BIND] Script BindMeToGeneratedQuest bound to
[!BIND] Script BindMeToGeneratedQuestWithName bound to mycoolquest
[!BIND] Script BindMeToHodByEditorID bound to [BindMeToHodByEditorID < (0001348A)>] Hod
[!BIND] Script BindMeToHodByID bound to [BindMeToHodByID < (0001348A)>] Hod
[!BIND] Script BindMeToMultipleTargets bound to [BindMeToMultipleTargets < (00000014)>] Prisoner
[!BIND] Script BindMeToMultipleTargets bound to [BindMeToMultipleTargets < (0001348A)>] Hod
[!BIND] Script BindMeToMultipleTargets bound to [BindMeToMultipleTargets < (00013491)>] Sven
[!BIND] Script BindMeToMultipleTargets bound to [BindMeToMultipleTargets < (00035534)>] Hilde
[!BIND] Script BindMeToPlayer bound to [BindMeToPlayer < (00000014)>] Prisoner
[!BIND] Script DocStringBindTohod bound to [DocStringBindTohod < (0001348A)>] Hod
[!BIND] Script DocStringBindToMultipleTargets bound to [DocStringBindToMultipleTargets < (00000014)>] Prisoner
[!BIND] Script DocStringBindToMultipleTargets bound to [DocStringBindToMultipleTargets < (0001348A)>] Hod
[!BIND] Script DocStringBindToMultipleTargets bound to [DocStringBindToMultipleTargets < (00013491)>] Sven
[!BIND] Script DocStringBindToMultipleTargets bound to [DocStringBindToMultipleTargets < (00035534)>] Hilde
[!BIND] Script DocStringBindToNPCs bound to [DocStringBindToNPCs < (0001348A)>] Hod
[!BIND] Script DocStringBindToNPCs bound to [DocStringBindToNPCs < (00013491)>] Sven
[!BIND] Script DocStringBindToNPCs bound to [DocStringBindToNPCs < (00035534)>] Hilde
[!BIND] Script DocStringBindToplayer bound to [DocStringBindToplayer < (00000014)>] Prisoner
[!BIND] Script _bind_actor_player bound to [_bind_actor_player < (00000014)>] Prisoner

[!BIND] Script _bind_actor_editorid bound to [_bind_actor_editorid < (0001348A)>] Hod

[!BIND] Script _bind_actor_multiple bound to [_bind_actor_multiple < (0001348A)>] Hod
[!BIND] Script _bind_actor_multiple bound to [_bind_actor_multiple < (00013491)>] Sven
[!BIND] Script _bind_actor_multiple bound to [_bind_actor_multiple < (00035534)>] Hilde

[!BIND] Script _bind_actor_multiple_oneline bound to [_bind_actor_multiple_oneline < (00000014)>] Prisoner
[!BIND] Script _bind_actor_multiple_oneline bound to [_bind_actor_multiple_oneline < (0001348A)>] Hod
[!BIND] Script _bind_actor_multiple_oneline bound to [_bind_actor_multiple_oneline < (00013491)>] Sven
[!BIND] Script _bind_actor_multiple_oneline bound to [_bind_actor_multiple_oneline < (00035534)>] Hilde

[!BIND] Script _bind_object_editorid bound to [_bind_object_editorid < (00013491)>] Sven
[!BIND] Script _bind_object_formid bound to [_bind_object_formid < (000BBCD1)>] chest
[!BIND] Script _bind_object_generated bound to Fork
[!BIND] Script _bind_object_generated_baseeditorid bound to Sweet Roll
[!BIND] Script _bind_object_generated_baseformid bound to Cabbage

[!BIND] Script _bind_quest_editorid bound to MQ101
[!BIND] Script _bind_quest_formid bound to FreeformRiften17
[!BIND] Script _bind_quest_formid bound to FreeformRiften17 ALREADY INITIALIZED!
[!BIND] Script _bind_quest_generated bound to
[!BIND] Script _bind_quest_generated_editorid bound to mygeneratedquest