Tutorial QSP Differences Between Normal And Dynamic Variables

Greyfrias

New Member
Mar 20, 2018
2
1
Hello, I've been working in a QSP game for the last month or so and now that I have at least the start of the story completed I started working on the coding part, which is the one that scare me the most, and I've noticed different approaches in handling the variables of your characters.

For example, I was originally going to use normal variables to determine the affinity of your character with the others, or their level of corruption, but then I was looking at the code of "Son of a Bitch" and I saw that it used dynamic coding. I tried to learn from the translated wiki but I couldn't understand the benefits of using this dynamic variables. And that's why I'm here, after a lot of lurking here, writing a post to ask if any of you know the advantages and disadvantages that dynamic code in QSP holds compared to normal one.

You don't have permission to view the spoiler content. Log in or register now.

Thank you a lot for your time and excuse me for any mistakes I've made writing the post because english is not my first language and I'm a bit rusty writing in it.
 

captainJugs

Newbie
Jun 7, 2017
63
88
I've never used QSP but seems like what your asking is why would you use arrays.

A variable can hold some data.
While an array can hold multiple variables.
And there a lots of different types of them - lists, maps etc

Anyway - while using variables is fine, it can get out of control if you had lots of them.
for example, you might be fine if you only had 5 characters with different data. what about 20 characters? or even 100s?
This is where an array should be used.
 

TCMS

Quote my posts if you want an answer
Donor
Former Staff
Aug 5, 2016
5,797
30,082
I think it's mostly the coders preferences in these cases. But yeah there's probably a performance side of things that needs to be looked at, but I have no clue about that when it comes to qsp (or coding in general)
 

geriatre

Member
Aug 22, 2016
497
667
Son of a bitch is not a good coding example.

I spend quite some time hacking the source when there's a major update to remove some of the grind, add cheats, simplify event triggers, etc., and it's nasty.

On topic :
You could make a function called "create_character" that returns a map with a predefined format, like
Code:
{
    { "Name", "Mike" }
    { "Location", "Bathroom" }
    { "Strength", 10 }
}
And then put that map in the dynamic map of characters, with the key "Player character", so if you want to have a fighting mini-game and compare each character's strength to determine the winner, you can do :

Code:
Character["Player character"]["Strength"] > Character["Asshole bully"]["Strength"]
Instead of having
Code:
Player_character_name = "mike"
Player_character_location = "Bathroom"
Player_character_strength = 10
Assholebully_name = "Eric"
Assholebully_location = "Bathroom"
Assholebully_strength = 8

Assholebully_strength > Player_character_strength
And then if you have 20 characters who can fight each other ... it's a nightmare.
Smart use of data structures can save you a LOT of time.
 
  • Like
Reactions: t727