Jump to content

Custom script for mod not working


Recommended Posts

So im making my own character for don't starve because it was just something to do, now ive got everything set up and i now know what im doing, i decided to start on the custom speech script. the script was originally wilsons but i changed the quotes to what i wanted. however, when i take my character in game, he continues to say wilsons quotes, i went back and checked the file and everything should be working correctly. E.g when he examines a carrot he said "Its all vegetabley" when the script should make him say "Too soft to be a stake". Help please!

 

(stake as in the vampire slaying tool, but thats irrelevant)

Link to comment
Share on other sites

Do you have a bit that goes something like...

 

STRINGS.DESCRIBE.YOURCHAR = require "speech_yourchar"

I do have that:

GLOBAL.STRINGS.CHARACTERS.enix = require "speech_enix"

 

My characters name is enix, in everything. but even though the wilson quotes dont exist within the script, he will still use them.

 

the file im putting / changing quotes in is called "speech_enix"

Link to comment
Share on other sites

I do have that:

GLOBAL.STRINGS.CHARACTERS.enix = require "speech_enix"

 

My characters name is enix, in everything. but even though the wilson quotes dont exist within the script, he will still use them.

 

the file im putting / changing quotes in is called "speech_enix"

 

hm... do you return the files content at some point? You probably do, just to be safe.

 

EDIT: Upload the mod (or at least the involved files) if you need further help.

Link to comment
Share on other sites

hm... do you return the files content at some point? You probably do, just to be safe.

 

EDIT: Upload the mod (or at least the involved files) if you need further help.

 

I am a bit confused about what you mean about returning the files. I edit the files from inside the mod and save them if that makes sense?

 

so i literally find the script in the mod and edit it.

 

also im really new to coding and stuff so sorry if im being stupid

 

 

Try GLOBAL.STRINGS.CHARACTERS.ENIX= require "speech_enix" ?

also corrosive, that's exactly what my file said, and my speech file is called "speech_enix"  i just dont understand!
 
sorry for being annoying
Link to comment
Share on other sites

@skyhawkcoomb,

 

This probably doesn't have to do with your problem, but "returning" in the programming sense has a specific meaning.  You can think of functions as being little helpers.  They go out and do something for you.  Once they complete everything you've tasked them to do, they return to you(or rather, whatever state/context the code was in prior to calling the function).  When a function returns, it can "bring back" a value, or multiple values in some languages like Lua.  The value that gets brought back(i.e. returned) is specified by using the keyword return at some point in the function. 

 

return by itself tells the function to stop execution and to return the value nil.  return followed by one or more variables(separated by commas) tells the function to stop execution and bring back those variables.  If a function reaches the end before any return statements are encountered, then Lua, like most languages, just act as if there was a return statement just before the end (this is just to prevent code from being cluttered-- functions must always return something, even if that something is nil, and even if you don't do anything with any of the values returned).

 

So when you have the code:
 

function Gimmie_A_Banana()    return "a banana"end

The function Gimmie_A_Banana() always returns a string that says "a banana".

 

That means when you call the function like so...

local my_banana = Gimmie_A_Banana() -- note: the ()s are what tell Lua to execute(call) the function                                    -- without ()s, it would just put a reference to the function inside                                    -- the my_banana variable

...results in everything to the right of the "=" sign being evaluated, which causes the interpreter to call the function being stored in the Gimmie_A_Banana variable (  because of the () operator next to it  ).

 

 Once the Gimmie_A_Banana() function returns "a banana", the interpreter finishes executing that line by assigning the value "a banana" to the my_banana variable ( because of the = operator next to it ).

 

 

 

side note about the word evaluate:

Evaluation, in a programming sense, like many other things in programming, is pretty much the same as in mathematics.  It just means to simplify as much as possible, or more generally, "find out what the value of something is."

 

If you've ever done homework where it said something along the lines of "for y = 1,  evaluate x = y + 2" ...

 

Essentially, the function is x = y + 2:

function x(y)    return y + 2end

That homework problem is telling you (you being the "homework interpreter" :razz:) to evaluate:

x(1)

 

 

Edit: oops, I forgot to mention the whole point of this! --

 

In addition to functions being able to return a value, when Lua loads additional files-- for example through the functions dofile() or require()--  those files are able to return values as if they were functions.  In fact, a lot of time the game expects you to be returning something from your files.  For example, every prefab file should end up returning a prefab!  Otherwise you've just created a prefab that the game can't interact with.

Link to comment
Share on other sites

skyhawkcoomb,

 

This probably doesn't have to do with your problem, but "returning" in the programming sense has a specific meaning.  You can think of functions as being little helpers.  They go out and do something for you.  Once they complete everything you've tasked them to do, they return to you(or rather, whatever state/context the code was in prior to calling the function).  When a function returns, it can "bring back" a value, or multiple values in some languages like Lua.  The value that gets brought back(i.e. returned) is specified by using the keyword return at some point in the function. 

 

return by itself tells the function to stop execution and to return the value nil.  return followed by one or more variables(separated by commas) tells the function to stop execution and bring back those variables.  If a function reaches the end before any return statements are encountered, then Lua, like most languages, just act as if there was a return statement just before the end (this is just to prevent code from being cluttered-- functions must always return something, even if that something is nil, and even if you don't do anything with any of the values returned).

 

So when you have the code:

 

function Gimmie_A_Banana()    return "a banana"end

The function Gimmie_A_Banana() always returns a string that says "a banana".

 

That means when you call the function like so...

local my_banana = Gimmie_A_Banana() -- note: the ()s are what tell Lua to execute(call) the function                                    -- without ()s, it would just put a reference to the function inside                                    -- the my_banana variable

...results in everything to the right of the "=" sign being evaluated, which causes the interpreter to call the function being stored in the Gimmie_A_Banana variable (  because of the () operator next to it  ).

 

 Once the Gimmie_A_Banana() function returns "a banana", the interpreter finishes executing that line by assigning the value "a banana" to the my_banana variable ( because of the = operator next to it ).

 

 

 

side note about the word evaluate:

Evaluation, in a programming sense, like many other things in programming, is pretty much the same as in mathematics.  It just means to simplify as much as possible, or more generally, "find out what the value of something is."

 

If you've ever done homework where it said something along the lines of "for y = 1,  evaluate x = y + 2" ...

 

Essentially, the function is x = y + 2:

function x(y)    return y + 2end

That homework problem is telling you (you being the "homework interpreter" :razz:) to evaluate:

x(1)

 

 

Edit: oops, I forgot to mention the whole point of this! --

 

In addition to functions being able to return a value, when Lua loads additional files-- for example through the functions dofile() or require()--  those files are able to return values as if they were functions.  In fact, a lot of time the game expects you to be returning something from your files.  For example, every prefab file should end up returning a prefab!  Otherwise you've just created a prefab that the game can't interact with.

 

This is a good explanation, I used it as a base for [this article] ;-)

Link to comment
Share on other sites

I'm so sorry for such a late reply guys, but I got it working thanks! It was simply because it wasn't capitalised in the right place! Although thankyou corrosive for your explanation on returning files, it was very interesting and will hopefully help me out at some point! Thanks all again and sorry for extreamly late reply

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...