Lyraedan Posted January 27, 2023 Share Posted January 27, 2023 (edited) Hello, I am trying to access another Lua file inside a prefabs script. I have my own custom character, has their own voice lines, I want to add custom voice lines. I can not find how to pull from the speech_<characterName> file that was loaded so I decided to try and make my own So I set it up -- scripts/Custom_Speech.lua return { TEST_SPEECH = "This is a test" } in my prefab I just need to access TEST_SPEECH so I try -- scripts/prefabs/MyCharacter.lua local custom_speech = dofile("../Custom_Speech.lua") -- tried without ./ and ../ didn't work -- Initial setup code local onAssosiatedAction -- For scenario sake whenever this assosiated action whether that be equip, unequip etc triggers do this inst.components.talker:Say(custom_speech.TEST_SPEECH) end -- The rest of the code I've also tried using `require` instead of `dofile` but they both just seem to choke and I can't get it to do what I want and I've been at this for over 5 hours and feel like I'm going around in circles. I just want to pull my quotes from a seperate file instead of hard coding them in the script. Edited January 27, 2023 by Lyraedan Link to comment https://forums.kleientertainment.com/forums/topic/145778-how-do-i-include-another-lua-file-inside-a-prefab-script/ Share on other sites More sharing options...
Merkyrrie Posted January 27, 2023 Share Posted January 27, 2023 Quotes from your mod should all be accessible with the STRINGS file just from anywhere just like TUNING is, because of this line in your modmain : STRINGS.CHARACTERS.MY_CHARACTER = require "speech_mycharacter" so if you wanted to take the generic battlecry quote, it would be STRINGS.CHARACTERS.MY_CHARACTER.BATTLECRY.GENERIC where MY_CHARACTER is whatever you put in for that in the code above Link to comment https://forums.kleientertainment.com/forums/topic/145778-how-do-i-include-another-lua-file-inside-a-prefab-script/#findComment-1619091 Share on other sites More sharing options...
Lyraedan Posted January 27, 2023 Author Share Posted January 27, 2023 8 hours ago, Merkyrrie said: Quotes from your mod should all be accessible with the STRINGS file just from anywhere just like TUNING is, because of this line in your modmain : STRINGS.CHARACTERS.MY_CHARACTER = require "speech_mycharacter" so if you wanted to take the generic battlecry quote, it would be STRINGS.CHARACTERS.MY_CHARACTER.BATTLECRY.GENERIC where MY_CHARACTER is whatever you put in for that in the code above This seems to have at least allowed me to place my custom voice lines in the speech file, for that I am thankful. Odd because last time I tried to access STRINGS it told me "STRINGS" was undeclared but now it works. Thank you Link to comment https://forums.kleientertainment.com/forums/topic/145778-how-do-i-include-another-lua-file-inside-a-prefab-script/#findComment-1619157 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now