Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

bitsy

a little engine for little games, worlds, and stories · By adam le doux

Using a variable in place of a room ID?

A topic by earthan created Nov 25, 2023 Views: 201 Replies: 8
Viewing posts 1 to 6
(1 edit)

What I want to do is, inside an Exit, substitute out the target room's designation, for a variable. something like

{exit roomID 6 16}

And then the variable 'roomID' holds the target room's ID number, which can then be changed so I can redirect exits without writing a bunch of if/then branches.

So far, this *almost* works; it changes to the correct room, but fails to place the Avatar anywhere in the new room, so the game becomes inoperable. I noticed the same thing happens if you format it like {exit 0 6 16} (forgetting the "" around the room number) so I thought "roomID" might work, but no luck so far.

Hi, earthen! Yours is the question I read awhile back and got intrigued. I see that nobody still got back to u. Despite my many things I've learned the past year or so using Bitsy, I have no clue how to help u with this problem, but it sounds so interesting! I've read some things on variables from Andrew Yolland and a few others (ripple writes, Time 4 Sum BS Fish Names, etc), but I honestly have no idea on your query UNLESS Adam makes that a feature of sum kind in his next update?

Props to u for thinking of such a useful thing! Well, that's 3 posts in one day after just joining. Hope I was able to help a few ppl out at least, so they can enjoy even more of the wonderful world of Adam LeDoux's Bitsy! :D

Hey!

So as far as I know, vanilla Bitsy doesn't contain a function to store rooms' IDs as variables. However, you can do some roundabouts to achieve kind of similar results. My way of doing it was through a bunch of branching lists. For example, in this game, the player is sent to a random room each time they go through an exit, but some conditions determine what room they will appear in.

So, as I see it, you can use a branching list as a 'variable' of sorts, that will contain all your rooms, with different conditions attached to each of them. Then when the exit is triggered, the game will run through all of the conditions and determine which room to send a player into. This is super cumbersome, though, and may even make Bitsy lag and crash, so based on my personal experience, I would say do it at your own risk. 

Hi, Valeriy! Big fan here. Thank you so much for a response to this, as I've been wondering about it ever since earthan first posted it! Fair enuf. Other things I find that can lag Bitsy hard is if u make too many rooms, or way too many exits. Always appreci8 such knowledgable ppl wn it comes to Bitsy. U and others have amassed more experience with it than I have so far, so I can't thank u enuf for your valuable insights!

Hey, thanks for your kind words! I'm not used to thinking of myself as someone very knowledgeable in Bitsy, but from time to time I'm being reminded by other people that a lot of stuff I know is not that obvious and can be helpful if shared with others. I wish I had more time to talk more explicitly about the techniques I use to create my games; maybe in time, I'll make an advanced tutorial or something. Meanwhile, if you have any particular questions about how things work in my games, feel free to ask, and I'll gladly share any knowledge I have with you :)

You're more than welcome, Valeriy. And an advanced Bitsy tutorial sounds like a great idea! No specific questions atm, but I'll certainly keep it in mind for future. There are a fair number of ppl with really good knowledge, and I can't keep track of them all on itch.io, but because I've played all your Bitsy games so far, I became quite interested in what you've done with the engine in terms of variables usage and such, it reminds me a lot of things I've learned in OHRRPGCE over the past few years. Looking forward to more from u, as well as other knowledgeable creators who find such amazing ways to push Bitsy to its limits.

I ran out of time to test it but I did conceive of a workaround of sorts, wherein a branching list consults a variable before transporting the player. Once I figured out that using 'exits' as exits was shooting myself in the foot, and they're more functional as 'dialogue' triggers, the rest of my project went much more smoothly.

So the way I would solve this now is by creating a reusable 'dialogue' script which consults a variable with if/thens - various events alter the variable, which determine where in the branching list you "exit" and which room you end up in.

Oh yeah, I totally forgot to mention that the first thing you should do with this method is disable the exit with the lock/unlock function. This basically makes an exit functional as a trigger that would execute any code you want, as you've said. Thanks for bringing this up!

Hey, earthan. Sounds similar to what Valeriy suggested, tho I like your pov of looking at exits as best-used as dialog triggers. Nice input from u both. I was timid to reply, as earlier yesterday, it seemed like I got a temporary ban... I couldn't access anything on itch.io at all, this forum, itch.io games, nada. It went-away after an hour or maybe longer (I never noted when I tried again). I thot itch.io was down, but dif. sites sed it wasn't, so I'm gonna be careful how often I post here, just in case.