Textadventures UK Forums
34 FOLLOWERS
Create and play text adventure games in this Textadventures UK Forum. Come across libraries and code samples, get game announcements and feedback, share your interactive fiction and game design, find adult recommendations for PG games, and help your mates in naming their new games here.
Textadventures UK Forums
2h ago
Good evening.
I'm creating a game in "Text Adventure" mode, not "Gamebook" and every time I advance and play it, I have to start from the beginning. Is there any way for my character to start in the place I want or just in the place where he/she has stayed?
Thanks in advance for the answer ..read more
Textadventures UK Forums
2h ago
Okay thanks. One last question hopefully please.
I'm trying to get the verb to display A) itself and B) its percentage chance based on condition parameters of the verb list itself, or by functions that can work off dynamically altered values but some or if not all the verbs no longer display at all. I use displayAction() for working out whether to display the action verb (in this case Snuggle) based on the new "action" parameter on the on the newVerbs[] itself and there's also a hardcoded boolean flag called displayPerc for deciding whether to push the % onto the verb, so for ones like Follow ..read more
Textadventures UK Forums
2h ago
If you're ever curious about what a variable is, you can always examine it by adding a line like this. This is useful for debugging what the values of variables are if your code isn't working the way you think it should, all you have to do is check the console in your dev tools to see what is printed.
console.log(p)
In this case, the p parameter contains two objects, char and item. Here's an abridged version of what gets printed. If you wanted to have a more generic function, you could use p.char and p.item to refer to the character that initiated the action, and the item they acted upon, resp ..read more
Textadventures UK Forums
6h ago
This is working 100% how I wanted it to, I don't want real time/date stuff as I'm not going full on life sim, just a very basic time scheduler system
createItem("EventClock",
{
eventPeriod:1,
eventActive:true,
gameTime: 720, // Defaulted to 12:00 (AM) - (M x 12) x H = Time - (5 x 12) x 12 = 720
gameTimeFormatted: "12:00 PM",
examine: "",
eventScript:function() {
// Update the game clock by 5 minutes
this.gameTime = this.gameTime + 5
if (this.gameTime >= 1440) {
t ..read more
Textadventures UK Forums
6h ago
So the below code looks like it works, but it still conflicts with 2 issues
Residential area1 (0), Residential area2 (0), Residential area3 (0), Residential area4 (0)
(Because the game code takes objectx.name and that objects can't have two of the same names, automatically applying a number beside it, which makes it looks ugly.)
It conflicts with scenery generator, I am not sure what is happening, but random stuffs are spawning instead
Script when entering a new room
foreach (objectx, ScopeVisible()) {
objectx.verbcountstat = 0
if (ListContains(objectx.displayverbs, "Take")) {
objec ..read more
Textadventures UK Forums
12h ago
I had a small success
Verbs are just script attributes
based on https://docs.textadventures.co.uk/quest/using_verbs.html
object.displayverbs = ListCombine(object.displayverbs, Split("Attack"))
https://docs.textadventures.co.uk/quest/display_verbs.html
Script when entering a room:
foreach (objectx, ScopeVisible()) {
if (HasAttribute(objectx, "fight")) {
}
else {
if (HasAttribute(objectx, "hp stat")) {
objectx.displayverbs = ListCombine(objectx.displayverbs, Split("fight"))
objectx.fight => {
msg ("You deal 1 damage to donkey<br/>Donkey retaliates with ..read more
Textadventures UK Forums
17h ago
What is the "p" in the args list of the function meant to represent? Is it the player object? Your shorthand is not that clear sorry. Also what about "nm" on the msg ..read more
Textadventures UK Forums
20h ago
Another walkaround solution is to create an object named scenery in the required rooms
Copy and paste the following code on entering specific rooms
scenery.alias = scenery.name+ ": "
if (RandomChance(100)) {
scenery.alias = scenery.alias+ "floor"
}
if (RandomChance(40)) {
scenery.alias = scenery.alias+ ",table"
}
if (RandomChance(40)) {
scenery.alias = scenery.alias+ ",windows"
}
if (RandomChance(40)) {
scenery.alias = scenery.alias+ ",coffee"
}
if (RandomChance(40)) {
scenery.alias = scenery.alias+ ",madam"
}
if (RandomChance(40)) {
scenery.alias = scenery.alias+ ",table"
}
.
Al ..read more
Textadventures UK Forums
1d ago
I see what you were doing with calling setNPCVerbs() each time the player enters a room. It makes sense and you could probably get it working with a few minor adjustments, however, I'd recommend using the verbFunctions array instead, for a couple reasons. First, maybe later on, this or another NPC will move between rooms independently. If the verbs are only ever set when the player enters a room, they could get out of sync. Second, you'd need to find another way to update the chance in the description, if it can change while the player stays within one room. Since each function in the verbFunc ..read more
Textadventures UK Forums
1d ago
As a quick way to get the time to display with two digits like you want, you could convert them to a string with a minimum number of digits.
this.gameTimeFormatted = `${w.EventClock.nHour.toLocaleString('en-US', {minimumIntegerDigits: 2})}:${w.EventClock.nMinutes.toLocaleString('en-US', {minimumIntegerDigits: 2})}`
If it were me though, I'd use a builtin Date, that way it keeps track of the real time in the background, including days, and you can format it however you want.
createItem("EventClock",
{
eventPeriod:1,
eventActive:true,
examine: "",
gameTime: new Date("2024-0 ..read more