Global script files which are always loaded (multiple)

  1. Describe your reason for requesting this feature. What problems are you running into?

I have a lot of code which isnt related to a specific file of room. The script files are getting bigger and bigger. Would be nice to have some way of keeping them a little smaller and organized by having the option to add some separate script files.

  1. How would this request improve your experience with using Pulp?

It would increase the readability of the script files,
It would keep the script files smaller and more organized.
It would make code less hacky and out of place.

I'm doing this by creating Sprite Tiles that are meant for storing specific scripts (so in my mind they are just different script files).

For example in a room that is a turn-based combat against an specific enemy I can have something like:

on enter do
	enemy_name = "Slime"
	enemy_attack = 3
	enemy_life = 5
	enemy_sentence = "{enemy_name} is very sticky"
	tell "combatHandler" to
		call "startCombat"

on combatWin do
	tell "transitionHandler" to
		call "fadeOut"
	tell "lootHandler" to
		call "randomLoot"

Like this I can duplicate this room for a new enemy and just change the specific variables to that enemy in the room script. The "combatWin" event would actually be in the "combatHandler" as well, but I put it just as an example.

Thanks for reaction! Though I dont think I understand your solution. First you talk about tiles and later about room. Is this script for a room or for a tile. Either way it doesn't sound like something that can be used as a solution for my problem.

If this where a script for a tile you would always have to have that tile in your room, where I don't have space for that.

If this where a script for a room I could only use this specific code in this room, and I need it everywhere.

I currently use the player for global scripts since the player ALWAYS available. BUT, this means a single script file for ALL global code. This is not a valid solution.

Sorry yes, I probably explained it in a confusing way. The thing is that you don't need to have the sprite in the room to call any of its custom events. When you use tell "tileName" instead of tell x,y you are calling the tile "prototype", not an specific instance as you can see in here: Playdate PulpScript

That's why you can't use tell "tileName" to make an enemy tile move for example, but you can use it for this (treat the sprite as a different script file).

In my example what I wanted to show is that I usually call custom events on enter but from tiles that are not placed in any room.

woooooow, this just blew my mind. Thanks for explaining this! Great workaround.