Help with different types of random events

Twine Version: 2
Story Format: sugarcube

I’m trying to learn more about random events. Can someone teach me in a easy way how to set up a random event in these situations:

  1. Character is exploring rooms. Each day (or time period), a random npc will be in these rooms.

  2. Character is leaving house to go to a shop . in-between these locations, random events may appears. Like get attaced by bandits in the street or finding a npc. There will be different districts, some of them more dangerous than others so I want this to affect the random atack events percentage.

  3. Sometimes the character will have dreams. This will be the first thing to happen after they go to sleep

  4. Npc shop keepers will have random dialogue everytime the character go there to buy stuff.

Probably all of these are the same type of situation that can be done with the same solution, but for me who is still learning, everything is new and different hahaha

That’s an awful lot of questions. I mean you managed to ask six or seven times in the last four days.

While some people here are really really helpful, and they have our eternal gratitude for their help, you need to find a way to answer most of your own questions.
Most often than not you can find similar questions with an internet search. Also, you can download games with features you like and open them with Twine. Then you’ll be able to check a way to do it.
I’m pretty sure you’ll have less and less difficulties in the future if you’re used to resolve yourself most of your problems.

Hey, no, that’s not a good place to go. If you don’t want to volunteer answers, that’s fine, but please don’t tell people not to ask questions…


Let’s see: I don’t really have time for a full answer just now, but I think you could add tags to your random event passages, and then use Story.lookup to find the appropriate ones, and then .random() on the array of passages to get one, and finally <<include>> to show the event?

<<include Story.lookup("tags", "dream").random().title>>

Something like that? Maybe?

4 Likes

@MarcyRangel You’re welcome to ask questions here. However, it sounds as though you’re a new Twine author and trying to make a pretty complicated RPG/VN/schedule management game as your first effort and those are notoriously difficult to understand even though they are built up out of lots of simple processes and loops.

I’d suggest starting smaller and working on each element you want to include one at a time. Try building a small experimental game that’s just about visiting a shop keeper with random dialogue and see how far you get. If you have problems, post the code you’re having problems with so people can point to something and give more specific detailed help.

It’s not that people don’t want to assist; you’ve basically just asked such general fundamental questions about RPG game structure in Twine that it’s hard to answer without writing a long essay tutorial about game design. Those do exist - you can find some here by searching, and elsewhere on the internet. That’s what @souppilouliouma meant by searching - people have asked your questions and answered them in the past and you can benefit from that existing knowledge.

3 Likes

I’m sorry :frowning: I didn’t realize how much of a bother I as being. This year I dint have the time to work on this project but this month In finally having the time for it that’s why I got excited and wanted to learn as much as possible so quick. I will stop now, I’m really sorry.

You’re welcome here @MarcyRangel and it’s no bother; you’ll just get quicker and more detailed help on this forum asking a question like

“I’m having trouble solving for x in the equation (x-1) = (23*y), what am I doing wrong?”

as opposed to

“Can someone please explain how math works?”

I see you deleted a post called “Questions about Mad Exile’s Gregorian Date & Time Widgets” - that was a much better specific question, but if you’ve already solved it yourself, that’s good!

I understand. I’m sorry again

@MarcyRangel you’re abolutely not a bother, and I certainly don’t want to allow nor disallow people asking questions.
I may have sounded harsh and @HanonO seems to say things more smoothly than me.

1 Like

I didnt solved, I deleted because I didn’t want to be a bother again haha That’s ok, I will try to learn alone

@souppilouliouma you wasn’t harsh, you were right, I was really being inconvenient. I will work harder from now on tofind a solution when I have difficulty in something instead of going to ask help right away :relaxed:

Again, we’re here to support you and you’re not alone. So long as you’re aware you’ll get better and quicker feedback if you post a specific problem and someone can say “You forgot to close your parentheses here…” as opposed to composing a lengthy explanation on design theory. :slight_smile:

1 Like

Thank you so much!! And is ok, they’re right, I was being really inconvenient these days with lots of questions. I deleted my previous questions and from now on I will work higher to find a solution by myself instead of going ask help right away :relaxed:

It’s not that people don’t want to learn by themselves, but obviously beginners don’t even know what keywords to search for. If you don’t want to drop links to resources, at the very least give out keywords to search for, lest your answer basically sounds “dismissive and patronizing”, acting all high and mighty telling people they do wrong without even pointing them the way to go.

Edit:
For example:

Have you considered different ways to make rpg games in Twine available on Google?

You can see the emphasis on searchable keywords, which is better than “rpg game structure”, BTW. See how easy it is to be helpful? Why not help them?

Telling people not to ask questions without telling them what to research beforehand is to shut them out, simply because they can’t find any “good” resource. Is that what you want?

So true. This is usually why I ask “stupid” questions… because I can’t find the correct search term to lead me to the right place to learn.

1 Like

@HanonO I manage to find a solution to all my MadExile Time widget questions , except for one: how do I calculate remaining time using that widget? Like, if current date is x and event is y, what is the code to calculate the remaining days? I cant find this information anywhere and I am horrible at math :sob: I swear to god I looked everywhere . I found how to create widgets, how to set events, how to change days and months. But not this. Do you have any tips? I swear I will not post anything again for at least months, it’s just this one problem that I need to solve as soon as possible to move my story foward

No need to cry. You can ask as many questions as needed. When you say “day”, do you mean turn based events ?

http://twinery.org/questions/8355/turn-based-events

No, not turn based events. I use MadExile time widget (found in this thread (MadExile's Gregorian date & time widgets) How might I advance this game clock to a certain day and time? - Twine Q&A) to set the date of my story. Some events happens in specific dates (for example, npc birthdays is on 12/4). I want to make a widget to the game calculate how many days between current date and event day. Let’s suppose current date is 11/05, I want to print how many days remain until the npc birthday on 12/04. I hope I made sense, english is not my native language :sweat:

You will need a table with number of days each month, but maybe this will help

https://www.vbforums.com/showthread.php?638840-Manually-calculating-date-difference

Edit: have you tried Twine mad exile on the search engine on this board? I think one of those post will work for you.

1 Like

Hopefully @TheMadExile will chime in here. I honestly don’t work extensively in Twine and Sugarcube, so I’m not the person to ask.

You don’t have to swear off asking questions! I wasn’t in any way trying to silence you, I was hoping to give you tips on how to get better advice here.

Check this thread also:

1 Like

Here is how I would approach the problem:

  1. Click the magnifying glass icon in the upper right to get a search bar drop-down.

  2. Enter gregorian date into the search bar. It’s often best to start with a specific term in order not to get irrelevant results. (If there are no results, you can always broaden the search.)

  3. In the search results, the second topic looks very promising, titled [Sugarcube 2.31.1] Events triggered based on calendar date.

  4. That thread seems to provide very useful hints for the usage of the widget. (Although, probably not the exact solution to the days problem.)

  5. So then, I’d look closely at the code of the widget itself, to see whether it contains built-in definitions that would solve the task directly. That doesn’t seem so.

  6. However, from the widget’s setup code (and from a Twinery forum post where TheMadExile provides the widget), we see that the JavaScript Date object is used.

  7. So, I would read up on the JS Date object. TME provided a link in that post, otherwise it’s the first Google hit for JavaScript Date object:
    Date - JavaScript | MDN

  8. That can look fairly intimidating if you aren’t used to it, but we can at first just skim-read it, since we are only looking for a method to calculate days between dates.

  9. We don’t immediately find a promising method name, but at the bottom of the page, there’s a section called “Calculating elapsed time”.

  10. There we see that we can subtract one date from another (or equivalently subtract the values returned by their getTime() methods), and we will get back the time difference in milliseconds. So, to get what that means in days, we will need to divide it by the number of milliseconds in a day (1 day = 24 hours = 1440 minutes = 86400 seconds = 86400000 milliseconds).

  11. As a quicker alternative to steps 7-10, we could have googled javascript calculate days between dates, the first hit is:
    How to calculate the number of days between two dates in javascript? - GeeksforGeeks
    Where we find:

// To calculate the time difference of two dates
var Difference_In_Time = date2.getTime() - date1.getTime();
  
// To calculate the no. of days between two dates
var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
  1. I’m not well-versed in Twine, but I think for Sugarcube it should be something like:
<<set $gameDate to new Date(2015, 2, 17, 3, 24);>>
<<set $futureDate to new Date(2015, 2, 24, 3, 24);>>

<<set $diffdays to ($futureDate.getTime() - $gameDate.getTime()) / 86400000>>

I hope this helps or provides some necessary building blocks.

1 Like