Making rooms do stuff #23
ErroneousCreationist
started this conversation in
Resources
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Lets say you want to do something in your room. Like... a tutorial for your slugcat, that shows those text border things? Or a cutscene thing? Traditionally, this would be done with devtool objects, but you don't need to use them. Heres how I added tutorial text to my scugs campaign.
To do this, I hooked RoomSpecificScript.AddRoomSpecificScript, and used this code:
Okay, so this is run basically on every room, and you can just hook and add objects. For finer control of when an object is spawned, you can just add stuff to the if statement, e.g. if you wanted it only on cycle 0, you can go
(room.game.session as StoryGameSession).saveState.cycleNumber ==0
However, we actually need an object to put in the room. Heres how to make one.
First, create a class that inherits from rain world's base object class, UpdatableAndDeletable, like this
class MyTutorialObject : UpdatableAndDeletable
Then, make the constructor. Might be helpful to put your room in the constructor, so you can get it easily.
As the name implies, you can, in fact, use the Update function of this class. Heres some example code from my mod, but you can do anything you want here
Basically, it plays 3 messages one after the other, and then destroys itself. It also checks if the player is in the room, and that the hud is playing (so it can wait to play the next message). This is not the best way to do it, you could totally just make a class that does all your text tutorials. Also, you don't have to use it to do tutorials, you can do anything with this, spawn effects, explode stuff, play sounds, whatever. Happy coding!
Beta Was this translation helpful? Give feedback.
All reactions