Comments (2)
A macro could work but unfortunately not as natively as yoursetGlobal
example. Something like this:
<<setGlobal "someVar" "something">>
<<getGlobal "someVar">>
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.:
<<print "You have " + GlobalVariables["someVar"]>>
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 Story.Vars
to a list you saved in the previous frame (a bit tedious).
Actually, I might add an event to the Story object, sort of like this: Story.OnVariableChanged(Story story, string varName, StoryVar newValue, StoryVar previousValue)
. You could then register a single handler for all your stories and propagate the value to all of them.
from cradle.
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!
from cradle.
Related Issues (20)
- Adding stories at runtime (like a mod)? HOT 1
- How to determine if a passage has been seen? HOT 1
- Stories not generating C# scripts HOT 7
- Jump on a specific passage HOT 1
- NotSupportedException on Windows C#6 version HOT 6
- Using Twine Text Player for dialogues HOT 1
- Can't generate .cs file HOT 1
- Animating text using TMPro player (Text Mesh Pro)
- [Harlowe] "...must be followed by a Harlowe-hook" error caused by tabs in code HOT 5
- Getting an exception error HOT 3
- Custom macros (prompts) for Harlowe / Harlowe documentation
- Can't import stories HOT 2
- Single-line comment or end-of-line expected
- Unable to import stories HOT 1
- Sugarcube Code: <<timed "2s">> <<goto "passage">> throwing error logs HOT 4
- Story Compilation Error
- Can't find Mono directory HOT 3
- Need Explanation for Macros (Harlowe)
- History not updated when pausing on exit from passage
- Cradle timeouts when trying to extract Clockwork.html story data with Unity 2020.3.22f1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cradle.