New here and saying hello

As the topic states, I recently signed up and thought I’d post a friendly hello. I discovered this site via StumbleUpon and played Choice of the Dragon. I liked the game o much, I decided to see what else there was on the site, where I then discovered ChoiceScript. I was delighted as I’ve often thought about writing an interactive fiction story, but never thought about how I would achieve it. As for my background, I am both an amateur writer and semi-professional programmer, though I’ve never worked with JavaScript before. I don’t as of yet have an idea for a story, as all my current writing ideas are best suited for a standard novel format, but I’ve been tinkering with the ChoiceScript files and have slapped together a few decent mods, including the ability to have global functions to every scene so copy and pasting the same thing into every scene is unneeded. I’d be willing to share this mod if anyone is interested, but since I’m not extensively familiar with JavaScript, I can’t guarantee that I implemented the “global scene”, as I call it, properly. Other then that, I’m glad to be a part of this community, as I hope I can offer a lot to it!

Hey there, welcome to the forums! :slight_smile:

What do you mean about this calling functions mod? I think you can all any j/s function from any file in the directory by default. O.o

Sorry for my unclear wording. I’m running off less then 5 hours of sleep. What I meant was I programmed (or hacked, cause of how sloppy it likely is) functionality for a global Scene file, eg: “choicescript_global.txt”, so you can reuse common ChoiceScript functions across different chapters/scenes without having to copy and paste them into every file.

So I could call a *label subroutine in scene 1 whilst the game has scene 2 displayed?

That WOULD be VERY useful :0

well, the *label subroutine would actually be in the “choicescript_global.txt” file, but yes, you could *gosub to it from ANY scene! How it works basically is after the current scene is loaded, it loads up the global scene file and appends the global text to the end of the main scene. Due to my unfamiliarity with Javascript though, I’m not entirely certain I executed it correctly, or even efficiently for that matter. As it is, I have it reloading the global scene every time there is a scene change. It seems to be bug-free from my test runs of it, but until I slap a real game/story together, I suppose I won’t know for sure.

Sweet, if you wouldn’t mind sharing I’d love to plug it into my game tonight, I have a perfect example of a routine I need to copy/paste so would be happy to help you test it! :slight_smile:

The only problem I foresee is if people have a label in the global scene that matches the current scene, otherwise that does seem like a pretty solid method (without looking at the code).

Hello and welcome. I to would like to see if that would work in mine.

Sorry about the lateness of my reply. I have been rather ill lately and haven’t been able to drag myself to an internet source.

That would be a problem, yes. I didn’t really take the time to proof the system against such things, as I felt it beyond my current scope, and for my particular needs, unnecessary.

As I’m really tired and drugged up on painkillers, I tossed the entire mod into a zip file. It’s a copy of the ChoiceScript zip with the examples, and of course the modified code. When I’m feeling a bit better, I’ll take a second look at the code and try to make it more modular.

Off the top of my head, if you want to peek at the code, I made the following changes/additions:
-Added a line to the end of the “mygame.js” file
-In the file “scene.js”, I modified the function loadScene()
-Also in the “scene.js” file, I added the function loadGlobalScene(), which is located directly below the normal loadScene() function
-Added the file “choicescript_global.txt” to the “scenes” folder
-Modified the file “startup.txt” in the “scenes” folder to test/showcase the global scene usage
-Also modified the file “animal.txt” in the “scenes” folder to prove that it does actually work in all scenes

Also, I feel I should note that using global ChoiceScript calls within the stats screen is probably a bad idea, though I’ve not tried to do so. I’ll probably add a check later to see if the current scene being loaded is the stats screen and make it not load the global scene info.

Let me know how it works for you, and sorry about the lazy upload. As I said, when I’m feeling better, I’ll spiff it up and make it look pretty. Have fun!

Hey no problem man, thanks for thanks for the share! I’ll have a tinker later.

Rest easy and get better soon man :slight_smile:

Sorry you are sick hope you feel better soon, great work so far.

Works a treat, and it’s fairly easy to implement too, bravo man. This is great. The only thing you could probably do is combine the loadscene and loadglobalscene functions but in all honesty it makes it easier to bugtest and later remove the mod if they’re seperated. I can’t fault it, nor can I express just how useful this will be.

Welcome, @stainedofmind, hope you’re feeling better soon, and thanks for the contribution. I’ve downloaded it, and will try it out after work this evening. I’ve a few CS subs that I’d love to have global access to, and if this works, I’ll have a lot more. B-)

@stainedofmind Impressive potential, this. Welcome to the forum, and thanks for sharing. I’ve had to abandon some pretty decent ideas for lack of the functionality to implement them properly (i.e. without excessively bloating each & every scene.txt file, anyway) so I have very high hopes for this.

Get well soon! Also, if I may suggest, perhaps when you’ve recovered enough to tweak this some more as planned, it would probably be a good idea to start a new “Game Development” thread exclusively for this, just so it’s easier for others to find in future. It’s too useful to see it drift away and be lost among the dross as a “General” topic.

This is a wonderful idea! I detest the current necessity of having to recopy and paste the same commonly used subroutines into multiple text files. It’s easily one of my biggest pet peeves with Choicescript. Among other things, this makes for a great place to put inventory functions.

I’ve been using it for the best part of the day, absolutely no problems. I’d consider pitching this to CoG to be included in the official package.

Only thing is the variable inside mygame.js - You don’t seem to require it, unless it’s defined somewhere else. Either way, it works fine without my adding of it.

First off all, thanks for all the greets and “get betters”. Also, I’m glad my mod is working so well thus far. I think I’ll open up a new thread for the mod in a few hours when I’m on my lunch break. Til then…

I initially tried to add the global functionality directly into the loadScene() function, but due to my lack of expertise in JavaScript, I wasn’t able to make it work. Interesting also that it doesn’t appear to need the variable declared to work. Again, I’ll chalk it up to my inexperience with JS. I like the idea better that it’s not needed to be honest. I didn’t want to add it to the “mygame.js” file to begin with, and after testing it just now, you’re right in that it doesn’t need it. Excellent, says I!

I hope it works well for you. From the sounds of it, it’s working well for everyone else.

To reiterate what I said above, I’m definitely going to open a new thread when I get a moment. I had the same doubts about ChoiceScript when I first glanced through it, which is why I created the mod to begin with, so hopefully it’ll help you out!

I had the same thoughts for using it as a dumping ground for an inventory system as well!