-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global shared RuntimeVar storage? #49
Comments
A macro could work but unfortunately not as natively as your The easiest way to implement this would be via runtime macros: [RuntimeMacro]
public void setGlobal(string globalVarName, StoryVar value)
{
// Some static class or singleton
GlobalVariables[globalVarName] = value;
}
[RuntimeMacro]
public StoryVar getGlobal(string globalVarName)
{
return GlobalVariables[globalVarName];
} Because you're using SugarCube, which doesn't have the concept of nesting macros, you'd probably need to use GlobalVariables directly if you need it in an expression, e.g.:
A better option would be to make a sync script that listens for standard variables' value changes and propagates them to other stories. You could do this in an update loop and compare each variable in Actually, I might add an event to the Story object, sort of like this: |
Ah, yeah. I think I was moving away from that because I didn't think runtime macros received StoryVars, but rather what they cast down to? I'll give it a shot. Thanks! |
Something I'm trying to figure out how to implement is a way to have multiple Cradle stories get/set StoryVars from a shared location. This way, Cradle stories can share information with one another, or I can have scripts in my Unity scene listening to variables that a number of stories are affecting.
My initial thought is to have a singleton
GlobalRuntimeVars
class and to add<<setGlobal $variable = "something">>
type setter/getter commands to access those shared variables.So my question is: is adding those getter/setter macros easy to pry in with the current code base and where would I do that? Or is there a simpler way to go about this?
Thanks!
The text was updated successfully, but these errors were encountered: