Skip to content

Instantly share code, notes, and snippets.

@confraria
Last active March 25, 2020 15:56
Show Gist options
  • Save confraria/7933f227927e2eba250f672e76e4258a to your computer and use it in GitHub Desktop.
Save confraria/7933f227927e2eba250f672e76e4258a to your computer and use it in GitHub Desktop.
game scripting
/*
The ids: system and player are builtin and don't need to be defined
*/
export const actors: Catalogue<Actor> = {
system: {
name: "Talent digital",
email: "no-reply@talent-digital.eu",
type: ActorType.System,
avatarUrl:
"https://talentdigital.eu/wp-content/themes/TalentDigital/images/FM_TDLOGO_small.png",
phoneNumber: "TALENTDIGITAL"
},
player: {
name: "Luis Confraria",
email: "luis.confraria",
type: ActorType.Player,
avatarUrl:
"https://pbs.twimg.com/profile_images/1084882918173016065/TE2WwQ3w_400x400.jpg"
},
tina: {
name: "Tina Digel",
email: "tina.digel",
type: ActorType.Internal,
avatarUrl: "https://randomuser.me/api/portraits/women/65.jpg"
},
tesla: {
name: "Nicola Tesla",
email: "nicola.tesla",
type: ActorType.Internal,
avatarUrl: "https://randomuser.me/api/portraits/women/65.jpg"
},
konsta: {
name: "Konsta Peura",
email: "konsta.peura@gmx.de",
type: ActorType.External,
avatarUrl: "https://randomuser.me/api/portraits/men/46.jpg"
},
mike: {
name: "Konsta Peura",
email: "konsta.peura@gmx.de",
type: ActorType.External,
avatarUrl: "https://randomuser.me/api/portraits/men/46.jpg"
}
};
export const applications: App[] = [
App.Chat,
App.Email,
App.MonsterJobs,
App.Foogle,
App.RealEmail
];
actor("tina")
.in("chat")
.say(
`We have received so many requests for new inventions that we can hardly keep up with them.`
)
.say("Which project do you think we should tackle next?")
.choose([
"Micro-Cooler // Consumer electronics, Reverse microwave, which freezes food and drinks in a very short time",
"Shop chef // shopping cart with integrated digital recipe book",
"Star-Liner New kind of transport for space cruises"
])
.saveAs("project") // choices are stored with id and value
.says(`What a cool project! We will need a specialist for support!
The best way is to place a job ad on [Mega-Jobs.de](/megajobs)`);
player()
.in("monsterjobs")
.on("hire")
.saveAs("newHire")
.addScore({ information: 10 });
actor("newHire").via("chat").say(`Hey, cool, glad to be part of the team!
It's actually unbelievable that nobody has ever invented this before.
Have you guys researched this before?
Maybe you can look on [Foogle](/foogle)`);
player()
.in("foogle")
.on("search", options => {
if (options.searchTerms.contains("reverse") && get("project").id == 1) {
addScore({ information: 10 });
}
});
actor("newHire")
.in("chat:group")
.say(
"Very cool! I will have my first thoughts about the project. Tell me, do you already work in the cloud?"
);
actor("tina")
.in("chat:group")
.say(
`That's actually a very good idea! We must find a good tool. {player.name} have you ever worked in the cloud before?`
)
.listen()
.say(playerSaid =>
playerSaid.yes
? "Great! You should be familiar with it."
: `Maybe you can take a look at this video [youtube](https://www.youtube.com/watch?v=dQw4w9WgXcQ)`
);
@JustMicha
Copy link

Thats quite cool! Even without introduction I think i can understand the main structure. The main commands are quite easy.
External means that I can build a connection to the "real world" via the game, right?
It is nice that you can add the score within this structure as well.
I even like the new look of Nicolai Tesla :D
Good work!

@eickler
Copy link

eickler commented Mar 25, 2020

Yes, that looks good and readable.

We probably need to spend some brain cells on the blocking/eventing behaviour of such scripts. It reads well linearily, but I am not sure if it actually works well that way. This is because you have a concurrency between what the player is doing and what the script/story is doing. If you stay fully linear, you may get into odd situations that the player has to understand an exact time point when to execute an action (= when the script progressed there), or alternatively the script gets very complex.

If you look at e.g., https://www.adventuregamestudio.co.uk/site/ags/tutorial/scripting/1/, they are event-oriented as top-level concept. Maybe you could have each invocation chain logically linear and each statement logically concurrent, and if you need to sync them, you need to wait for some event that another statement trigers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment