I'm relatively new to the programming side but do have some basic idea on html, css and Javascript. I'm currently making a bit of a RPG on SugarCube. As I mentioned, I'd like to have multiple events that could happen as part of a passage you can revisit. I was able to make the basic idea work with if/else conditionals:
Exploring...
<<set $explore = random(99)>>Debug: $explore
<<if !$foundLocationA && !$foundLocationB>>
<<if $explore < 50>>
Random Event
<<elseif $explore < 80>>
Location A
<<else>>
Location B
<</if>>
<<elseif $foundLocationA && !$foundLocationB>>
<<if $explore < 80>>
Random Event
<<else>>
Location B
<</if>>
<<elseif !$foundLocationA && $foundLocationB>>
<<if $explore < 70>>
Random Event
<<else>>
Location A
<</if>>
<<elseif $foundLocationA && $foundLocationB>>
Random Event
<</if>>
Basically if I wanted such that there are multiple events more than Random Event, B, C here; if I found A or B I will no longer be able to find it again (I have another passage for old locations). Going to location A and B will set the foundlocationA/B to true which unlocks it for old locations. Is there some easier way to do this? (someone mentioned me used nodes not sure how) This would drive me insane if I have to repeat this for Location A-Z.
Comments
Second. Please use the code tag when posting code or markup—it's C on the editor bar.
If you're asking for a way to determine whether the player has been to a location, which doesn't require you to set a story variable, then you could use the visited family of functions to do so. Documentation:
If you're asking about something else, you're going to need to clarify.
Then delete it from the array when you enter the location. Anyways, I just can't quite wrap my head around writing some kind of efficient code for controlling those probabilities in the $eventList for this approach.
It would probably help by defining what kind of probabilities you're looking for here. In your original example each case had a unique set of probabilities, which does not lend itself to optimization.
[/quote]
Ya I guess I wasn't communicating what I want very well. Basically as a basic example for what I was writing at and didn't do it quite right was that. Location A, B ,C certain probabilities of happening, lets say 25% 15% 10 % while the remaining 50% would be Random Events. If you gone to any of Location A, B, C etc. it would be eliminated and the probabilities of the rest remains the same while the random events increase by the one that has already happened. The array method, just evenly distributes the chance of A, B, C over 50% while the rest is Random. It doesn't Increase random unless I put it into the array itself which is still distributed evenly. Hope you get at what I'm trying to do. I'm not good at conveying it haha
I've thrown together a skeleton of how you might do something like this. The core parts are JavaScript, since it's easier to do that way. I've attached the Twine 2 story archive, which you import into Twine 2, to this post.
WARNING: Do not mark the comment containing TheMadExile's skeleton as an Answer, even if it does solve your problem because that will cause the forum software to delete the attached file.
Could well be what TheMadExile suggested, but I can't get his html attachement open (problem/restriction my end).
You probably simply need to right-click the link and select the save as menu item—the actual name varies by browser: Save as…, Save link as…, Save target as…, etc.