Any frameworks that could help with this project? If not, what language should I use?

BulletPete

Member
May 5, 2017
108
101
To be blunt, I'm terrible at the artistic side of these sorts of games. But I do have enough programming knowledge to learn any new languages and create something workable (though, not optimized) from it, and enough narrative and writing experience to create a good scene, though.


So I had an idea. I could create a narrative game inspired by Alter Ego (it's not a game fitting this site, but if you want to try it, ) - where a character gains various traits throughout the years and those unlock trait exclusive events. Along with this, they could see their characters age and accompany them throughout their lifes.


Ideally, the user could upload their own photos or select one from hundreds of options I can create in artbreeder. Art would be limited, so the game doesn't become too heavy and more text based from the start.


Now, I know I could do all of this fairly easily with the languages I know now at a more advanced level. I'm fairly proficient at JS, PHP and MySQL, but I don't want to create an always online game since I don't have the time or money to spend on maintenance. Ideally, I'd use a framework which would let me store info on a local database and create an UI which would fit my needs.


Are there any alternatives that would let me create such game?
 

Satori6

Game Developer
Aug 29, 2023
492
937
Since you already know JS, Twine would be a good fit.

It's a novel/story framework focused on text-based games, but since it's JS, you can add as much complexity as you want to it.
This would also be the easiest one to implement picture importing (the game Free Cities is a good example of this feature).

One of the nicest things about Twine is that it includes save/load system that saves you a lot of time.

Twine uses TwineScript, which comes in different flavors. SugarCube is the most favored one by developers, but you should look into all options to see which one you like best.
And don't get discouraged by it - in the end, TwineScript is just simplified JS functions and macros. You can always opt not to use it and just code the entire thing in JS.
 

BulletPete

Member
May 5, 2017
108
101
Since you already know JS, Twine would be a good fit.

It's a novel/story framework focused on text-based games, but since it's JS, you can add as much complexity as you want to it.
This would also be the easiest one to implement picture importing (the game Free Cities is a good example of this feature).

One of the nicest things about Twine is that it includes save/load system that saves you a lot of time.

Twine uses TwineScript, which comes in different flavors. SugarCube is the most favored one by developers, but you should look into all options to see which one you like best.
And don't get discouraged by it - in the end, TwineScript is just simplified JS functions and macros. You can always opt not to use it and just code the entire thing in JS.

Thank you for the suggestion.


Does it allow some sort of database that could potentially ease up the description process? I've downloaded it, played with it a bit and looked up some tutorials, but I couldn't find anything similar to what I'd idealized. Twine, from the initial looks of it, seems like an excellent tool for branching narratives but not as much when it comes to generating unique, evolving characters.


For instance, I would love to give each character an ID, a randomly generated name (from a predefined list, obviously) and then have several traits saved up in the object. For example, I'd love to have an array of friends where I simply save up their ID's in there. Then use said ID to query up their personality/physical traits on the spot and determine events. Like If the mc has a friend with a popular/party animal trait, the mc gets invited to parties as part of an event. If he has a friend with the bookworm trait, he'd have some study sessions events and etc etc.

Also, at the start of the scene I could query their features, attribute them to a variable and have narrative flow naturally with whatever info I pulled out from the database. For instance, if the main character has blond hair, whenever I'm about to describe the scene I'd have it like ''His $mcHairColor hair was a mess.'' If I'm describing a blond friend called Charlie, I'd have it like '' $c2's $c2HairColor hair was a mess.'' where $c2 was set as Charlie and $c2HairColor set as blond in the beginning of the scene.

With this system, I could also have several images linked up to several ages, all aged up and down with artbreeder and have the characters get old as the game progresses.
 

Satori6

Game Developer
Aug 29, 2023
492
937
Thank you for the suggestion.


Does it allow some sort of database that could potentially ease up the description process? I've downloaded it, played with it a bit and looked up some tutorials, but I couldn't find anything similar to what I'd idealized. Twine, from the initial looks of it, seems like an excellent tool for branching narratives but not as much when it comes to generating unique, evolving characters.


For instance, I would love to give each character an ID, a randomly generated name (from a predefined list, obviously) and then have several traits saved up in the object. For example, I'd love to have an array of friends where I simply save up their ID's in there. Then use said ID to query up their personality/physical traits on the spot and determine events. Like If the mc has a friend with a popular/party animal trait, the mc gets invited to parties as part of an event. If he has a friend with the bookworm trait, he'd have some study sessions events and etc etc.

Also, at the start of the scene I could query their features, attribute them to a variable and have narrative flow naturally with whatever info I pulled out from the database. For instance, if the main character has blond hair, whenever I'm about to describe the scene I'd have it like ''His $mcHairColor hair was a mess.'' If I'm describing a blond friend called Charlie, I'd have it like '' $c2's $c2HairColor hair was a mess.'' where $c2 was set as Charlie and $c2HairColor set as blond in the beginning of the scene.

With this system, I could also have several images linked up to several ages, all aged up and down with artbreeder and have the characters get old as the game progresses.
Yeah, you can do all of that.

$ works and an operator for global/persistent variables, so during character creating you can do something like:

<<set $mc={hairColor='blonde', other_properties...}>>

And then just write "His $mc.hairColor hair was a mess."

As for the database, you could store the random NPC traits in an object within a JS file and import it for ease of use. Then you could do things like:

<<=friendEventDescription($eventID,$friends[$friendID])>>
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,296
3,952
Twine produces HTML+css+js games that then run in a browser environment. So you can theoretically use whatever JS APIs are available in the browser like the IndexedDB API ( )

But you still need to populate the data into there, so you'll need it all in a JSON definition anyway. So there's no point really, just use the JS object to import into the game's runtime variable space and lookup via indexes, exactly as Satori6 suggested.
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,289
4,159
As for the database, you could store the random NPC traits in an object within a JS file and import it for ease of use. Then you could do things like:

<<=friendEventDescription($eventID,$friends[$friendID])>>
I don't see how that will work. friendEventDescription() a javascript function, right? You can't call them like that.
 

Satori6

Game Developer
Aug 29, 2023
492
937
That doesn't work with Twine2+SugarCube2.36.1 when I try it. What are you running and how is the function declared in the javascript? Just function friendEventDescription(param1, param2)?
Twine 2.6.2
SugarCube 2.36.1

Story Javascript
Code:
window.friendEventDescription=function(a,b){
return 'This is event '+a.toString()+' for character '+b+'.';
}
StoryInit
Code:
<<set $friends to ['Alcahest']>>
Passage
Code:
<<=friendEventDescription(123,$friends[0])>>
That's the whole story.
Are you returning a value from your function? When you call them like that, a return value is expected.
 
  • Like
Reactions: Alcahest

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,289
4,159
Twine 2.6.2
SugarCube 2.36.1

Story Javascript
Code:
window.friendEventDescription=function(a,b){
return 'This is event '+a.toString()+' for character '+b+'.';
}
StoryInit
Code:
<<set $friends to ['Alcahest']>>
Passage
Code:
<<=friendEventDescription(123,$friends[0])>>
That's the whole story.
Are you returning a value from your function? When you call them like that, a return value is expected.
Oh, you can use print if you use the window object. I didn't know that. I see now that it works with setup functions as well since they are also on the window object. (y)
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,296
3,952
Wow, I wasn't expecting that, Alcahest is normally the one helping the other Twine beginners (No offense intended Alcahest, I love your work). And as a bonus I got to learn something too!
 
  • Yay, new update!
Reactions: Alcahest

BulletPete

Member
May 5, 2017
108
101
Yeah, you can do all of that.

$ works and an operator for global/persistent variables, so during character creating you can do something like:

<<set $mc={hairColor='blonde', other_properties...}>>

And then just write "His $mc.hairColor hair was a mess."

As for the database, you could store the random NPC traits in an object within a JS file and import it for ease of use. Then you could do things like:

<<=friendEventDescription($eventID,$friends[$friendID])>>

But could I set this randomly, that would be my biggest question?


For example, imagine these images belong to a NPC who grew up with the mac, could I store all these pictures in an array, could I give him randomly generated traits every time?
imagem_2024-01-11_203936696.png imagem_2024-01-11_204014823.png
1705005678183.png

imagem_2024-01-11_204545764.png
And give him gain randomly generated traits every time?


If so, you'd think it'd be best practice to randomly generate everything on the first page?


I'm failing to see how the heck I could keep Twine organized.


Because I guess I could, but generating everything in the beginning sounds like a pain to make run optimally.

I was honestly hoping there was some way I could apply an ER model to character creation as a way to make it all easier to evolve.
 
Last edited:

Satori6

Game Developer
Aug 29, 2023
492
937
But could I set this randomly, that would be my biggest question?
Of course. Twine uses JS - you can do anything you want.


For example, imagine these images belong to a NPC who grew up with the mac, could I store all these pictures in an array, could I give him randomly generated traits every time?

And give him gain randomly generated traits every time?
Yeah, you could store them in an array, or simply use folder and file names that allow you to retrieve the right picture based on a character's description.

eg; you could have the following folder structure: portraits/male/
And then name those 4 pictures 1a, 1b, 1c, and 1d.

Then just store the picture ID ("1" in this example) in the character object and have some getPortrait() function that returns the correct one based on the character's age and gender.

If so, you'd think it'd be best practice to randomly generate everything on the first page?
No, just generate things as needed.

I'm failing to see how the heck I could keep Twine organized.
I prefer writing my JS in external files and loading those instead of writing JS in Twine.
Twine would then be left as a simplified HTML editor where you're mostly just telling it what to display.
 

BulletPete

Member
May 5, 2017
108
101
Of course. Twine uses JS - you can do anything you want.




Yeah, you could store them in an array, or simply use folder and file names that allow you to retrieve the right picture based on a character's description.

eg; you could have the following folder structure: portraits/male/
And then name those 4 pictures 1a, 1b, 1c, and 1d.

Then just store the picture ID ("1" in this example) in the character object and have some getPortrait() function that returns the correct one based on the character's age and gender.


No, just generate things as needed.


I prefer writing my JS in external files and loading those instead of writing JS in Twine.
Twine would then be left as a simplified HTML editor where you're mostly just telling it what to display.


The thing is, I keep thinking of ways to make this optimally and creating the variables as I need them does seem like the obvious choice. Yet, this is supposed to be a branching narrative with randomness, so there is no guarantee the player will pass by the scene that declares the variable. At least the way I'm understanding Twine, declaring them at the start seems like the safe way the player will overcome the randomness, no?


Additionally, I have no idea where to add in an isolated js script to make the events come in randomly.


Otherwise, without a script, at first glance, it just seems like I'll have to add all the functions in here
imagem_2024-01-12_040155759.png

Which sounds like a huge mess and way too small to navigate thought the functions efficiently.

The only other way I'm thinking of generating scenes randomly, would be attaching a random number generating function to the button, which would lead the player to a scene. But this sounds like it will create a complete mess of a web of disorganized scenes on the dashboard, no?
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,289
4,159
The thing is, I keep thinking of ways to make this optimally and creating the variables as I need them does seem like the obvious choice. Yet, this is supposed to be a branching narrative with randomness, so there is no guarantee the player will pass by the scene that declares the variable. At least the way I'm understanding Twine, declaring them at the start seems like the safe way the player will overcome the randomness, no?
If you want to make sure a variable exists with a default value, you can just add it when loading a save (if the variable doesn't already exist). It's essentially no different than declaring them at the start. But I find it's rarely needed, depending on how you use the variables (though my game is relatively linear with no randomness).

Additionally, I have no idea where to add in an isolated js script to make the events come in randomly.
Scrap Twine and use Tweego. Then you can code in any editor you want and have as many js-files as you want.


Automatically update your html-file like this:
https://f95zone.to/threads/dream-life-development-thread.176300/post-11877519
 
Last edited:

Satori6

Game Developer
Aug 29, 2023
492
937
The thing is, I keep thinking of ways to make this optimally and creating the variables as I need them does seem like the obvious choice. Yet, this is supposed to be a branching narrative with randomness, so there is no guarantee the player will pass by the scene that declares the variable. At least the way I'm understanding Twine, declaring them at the start seems like the safe way the player will overcome the randomness, no?
If it's a variable that matters, you'd create it at the start. If it's some random variable (as mentioned in the previous post), there's no need to add it until it's needed.


Otherwise, without a script, at first glance, it just seems like I'll have to add all the functions in here


Which sounds like a huge mess and way too small to navigate thought the functions efficiently.
You can import JS files. There's no need to use Twine's JS box.