How to Use Tool Scripts and Resources in Godot (Godot Retro Text Adventure Tutorial #9)

  Рет қаралды 8,915

jmbiv

jmbiv

Күн бұрын

Пікірлер: 72
@hamzasibai1983
@hamzasibai1983 Жыл бұрын
In Godot 4.0 you can use set this way(note I used zone instead of room where applicable): Also note the change in setting up the export variable as an annotation (using @ ; also notice how to make it multiline): @export var zone_name : String = "Zone Name" : set = set_zone_name @export_multiline var zone_description : String = "This is the description of the room." : set = set_zone_description
@YammoYammamoto
@YammoYammamoto 10 ай бұрын
Thank you! Worked like a charm! Saved me a plenty of time.
@joelmcwilliams
@joelmcwilliams 9 ай бұрын
Thanks for this, looks like using room instead of zone was causing some errors like this one for me on the first line of the set_room_name function until I switched it to set_zone_name: "Invalid set index 'text' (on base: 'null instance') with value of type 'String'.
@xx___xx2787
@xx___xx2787 9 ай бұрын
@@joelmcwilliams im literally getting this error, i never had this one the first time round. is setting it to zone the only way to fix it or is there some other workaround?
@joelmcwilliams
@joelmcwilliams 9 ай бұрын
@@xx___xx2787 I think so, I was pretty confused by it but after switching room to zone it went away... unsure why.
@xx___xx2787
@xx___xx2787 9 ай бұрын
@@joelmcwilliams ok tysm :)
@jasonwebb71
@jasonwebb71 3 жыл бұрын
I'm really enjoying this series. This is my first time using Godot, so, having grown up with text adventures in the early 80s, this is an enjoyable learning process for me.
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
That's awesome, I'm glad you're enjoying it! If you have any questions as you're learning Godot, feel free to ask those in the Discord server.
@kosm460
@kosm460 Жыл бұрын
in godot 4 its @tool
@synder68
@synder68 5 ай бұрын
Just finished this video. Thanks godot 4 really has changed a lot of things, but its still fun following along.
@childlearningclub
@childlearningclub Жыл бұрын
I have struggled with understanding how setget works, even with several videos showing it, your explanation was the first that made sense to me :). Thank you.
@MrBfurse
@MrBfurse 3 жыл бұрын
This series is incredible as always! Really looking forward to the next video. I saw on a previous video you will be doing about 15 videos in the series, however I would really love like 30 haha. Looking forward to how to pick up objects and look at them in the upcoming videos. just a question, if I wanted to add some artwork to the rooms what would be the best way to do this? I assume (as a noob) it would be best in the background node to place the rows node you have made into a Hbox container so you could place artwork to the right/left half of the screen and then you can could use another node to handle the different artwork? If you are going to go down this road in another video, I will happily and patiently wait!
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
Thanks so much for the kind words Sam, and glad you're still enjoying these! Man, same for me, I would love to keep this going but realistically don't think more than around 15 (give or take a few) will end up happening. Great question though! I hope we do get to some more UI changes but, in case we don't - I think the way you said it is perfect. Make a new HBoxContainer, add Rows as a child, and then a new VBoxContainer to handle the new UI elements on the right side (and adjust as needed). You could then make artwork, a map, or just some info about the room/game all be new elements as children of the new VBoxContainer. If we do get to that in this series, that's how I imagine I'd do it, but I haven't planned that far ahead so TBD haha
@AutMouseLabs
@AutMouseLabs 3 жыл бұрын
I had no idea about tool scripts! This is so useful!
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
So glad it was helpful! They're really useful 🙂
@peetabix
@peetabix 3 жыл бұрын
This is a long one. I'm learning so much. :)
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
So glad to hear you're learning from it! It's longer than I usually want videos to be but I wanted to make sure we covered a lot of the important stuff.
@darkvioletcloud
@darkvioletcloud Жыл бұрын
My game crashed. Spent two hours trying to figure out what was wrong with my code. I misspelled one word. Oops. Great tutorial as always!
@Cosmozaure
@Cosmozaure 3 жыл бұрын
Thanks for all this work.
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
No problem, thanks for watching!
@peetabix
@peetabix 3 жыл бұрын
So, if i want to add a new room. I can make a duplicate of (for example) OutsideRoom, i'll name it Garden then add $Garden.connect_exit("south", $Outsideroom) to add it to the game?
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
That's correct, yes! Perhaps a better way to do it would be to start with the room the player spawns in, and move outward - so you connect house to outside, and then outside to garden - it accomplishes the same thing though, so as long as you're consistent use whatever way works. We'll hopefully start adding some more rooms in the next couple videos!
@peetabix
@peetabix 3 жыл бұрын
@@jmbiv_dev Cool, thanks. :) It's great to see how the work we've done can make it easy to add to the game in the future.
@isaiahgrylls8548
@isaiahgrylls8548 2 жыл бұрын
In Room.gd line 24, "var exit = Exit.new()" gives error "the identifier "Exit" isn't declared in the current scope" What can I do to fix this?
@jmbiv_dev
@jmbiv_dev 2 жыл бұрын
This means that the engine doesn't recognize "Exit" - make sure you added "class_name Exit" at the top of your Exit.gd script, that's the line that tells Godot to add "Exit" to the global namespace!
@Uhfgood
@Uhfgood Ай бұрын
So someone mentioned earlier that you need to put @ before tool (@tool) in order for it to work I think since 4.0 (and in 4.3 what I'm currently using). Setters and getters don't use setget anymore but individual set or get keywords as functions. set obviously has to have an identifier in parentheses like a regular function with a single parmeter. get doesn't need parentheses. Make sure you indent after : (colon) but before defining set or get. Someone else in the comments brought up to do that multiline editor hint instead of just @export you use @export_multiline -- as shown here: @export var room_name = "Name" : # note how room_name is only a single line @export set( name ) : room_name = name $MarginContainer/Rows/RoomName.text = name @export_multiline var room_desc = "Description" : set( desc ) : room_desc = desc $MarginContainer/Rows/RoomDescription.text = desc
@myvisualnovelquest822
@myvisualnovelquest822 Жыл бұрын
I'm just wondering. If you were creating a game with a lot dialogue, I'm assuming you would want to use a resource. Is that correct?
@xx___xx2787
@xx___xx2787 9 ай бұрын
id say so yeah, cuz you would make a class called dialogue (u can call it whatever u want its just a placeholder) then have character as an argument so u can have it affect the character; have a function to print it out, have variables for prompts if its passive dialogue. If its a convo dialogue then im not as sure, unless its choice based like bg3 then it might be easier cuz u would just have an if statement but id do that outside of the class i guess. but for th ebse mechanics of getting the dialogue to appear and interact then yeah id say have it as a resource. (i am not an expert in this, im a student lol; its just my suggestion on how id design it.)
@myvisualnovelquest822
@myvisualnovelquest822 9 ай бұрын
@@xx___xx2787 I'm still trying to figure out as I go too.
@xx___xx2787
@xx___xx2787 9 ай бұрын
@@myvisualnovelquest822 it's the best way to do things 👌
@myvisualnovelquest822
@myvisualnovelquest822 9 ай бұрын
@@xx___xx2787 it's also frustrating when there is little to no information on certain applications, fundamentals, principles, etc, so then you have to look at other information and hope you can use the same principle.
@WhoIsCraig
@WhoIsCraig Жыл бұрын
I have looked at the word ROOM so much it looks like its spelt wrong.
@DrMrProfSir
@DrMrProfSir 9 ай бұрын
Great tutorial, I'm loving it so far. I'm working in godot 4.1 and I'm getting this error in my set name function "Invalid set index 'text' (on base:'null instance') with value of type 'String'." does anybody have any clues as to how to solve this?
@jmbiv_dev
@jmbiv_dev 9 ай бұрын
That error is telling you that you're trying to change a property on a null object. So whatever it is that you're trying to change the "text" property on, that object is null - you may have forgotten to initialize it, or if it's a value that gets passed in as a parameter or something, it isn't being retrieved correctly. Hopefully that helps - if you're still having issues, hop in the Discord server and we can help out more there!
@leynieraragon9417
@leynieraragon9417 4 ай бұрын
did you solve this issue? im having it also
@magni319
@magni319 4 ай бұрын
@@jmbiv_dev I'm getting the same error, your code doesn't work.
@thomaseubank1503
@thomaseubank1503 2 жыл бұрын
14:56 That would be great for dialogue
@astwyr2856
@astwyr2856 3 жыл бұрын
thank you
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
No problem!
@valdivinoneto5132
@valdivinoneto5132 3 жыл бұрын
Valeu, ótimo vídeo
@kosm460
@kosm460 Жыл бұрын
ok so i get a error when we change the go function at the end. It says "Nonexistent function "get_other_room()" in base PanelContainer (Room)
@kosm460
@kosm460 Жыл бұрын
if I erase the get_other_room function and just put change_room(exit) then the game works fine. Any advice?
@kosm460
@kosm460 Жыл бұрын
solved it. I didnt delete some stuff from the match statements in the room script
@DJKNITEX
@DJKNITEX 11 ай бұрын
what did you delete cause im having this same issue as well
@kosm460
@kosm460 10 ай бұрын
@@DJKNITEX a week or so after following this tutorial my game actually corrupted. all the scenes run data deleted themselves so its not runnable and i never tried to fix it. i probably didnt delete some example stuff he had added to show something off or it was a older version of something he changed in the match statement
@oneilfusion
@oneilfusion 5 ай бұрын
I got the same error and fixed it. It is because I haven't changed the room.exits["east"] = self in match statement into room.exits["east"] = exit
@alphabeta3029
@alphabeta3029 7 ай бұрын
In Godot 4 room description would look like this, i.e. multiline in export and setter in place: @export_multiline var room_description : String = "Some long and very complicated room description" : set(new_value): $MarginContainer/Rows/RoomDescription.text = new_value room_description = new_value
@magni319
@magni319 4 ай бұрын
It doesn't work. Godot insists that RoomDescription node doesn't exist.
@nat2509
@nat2509 3 жыл бұрын
is it possible to show the text one character at a time and not all at once?
@hassassinator8858
@hassassinator8858 3 жыл бұрын
search up "typewriter text Godot"
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
Yes, absolutely! You could create an empty array, and then add each character of the text to that array (say, like, a new character every 0.3 seconds, using a timer), and then just update your label whenever that array changes. Hope that helps!
@joshuabroberg2380
@joshuabroberg2380 2 жыл бұрын
I cannot get export (String, MULTILINE) var to work. It still shows a tiny box.
@jmbiv_dev
@jmbiv_dev 2 жыл бұрын
Sorry to suggest the most basic thing, but have you tried closing Godot and then reopening it? I've found changes to exports sometimes don't update right away (though they usually do).
@Desdraftlit
@Desdraftlit 2 жыл бұрын
Ah the age old fix from A+ class.. turn it off and on again. Thank you kind sir!
@leynieraragon9417
@leynieraragon9417 4 ай бұрын
yo @ 32:12 that was not the error I was getting >.>
@Takiro_Ryo
@Takiro_Ryo 2 жыл бұрын
I don't know why but when I start my game it gives an error in the setters, where it tries to access the properties of the labels, saying that the node doesn't exist. It works in edit mode, however. I had to add `if Engine.editor_hint:` to check if it runs in the editor to make it work and only access the labels when in editor mode.
@jmbiv_dev
@jmbiv_dev 2 жыл бұрын
This might happen if those setters are getting called before the labels you are trying to access are ready (i.e., before the parent itself is ready). I'm not sure why that wasn't an issue in my code or what's different, but I would just make sure those setters aren't getting called before the labels are readied when your game starts.
@benjamingunther4988
@benjamingunther4988 2 жыл бұрын
@@jmbiv_dev HI, I've run into the same issue "get_path: cannot get path of node as it is not in a scene tree." I'm not really sure how to delay the setters being called or hasten the readying of the labels. I imagine something like placing the script as a child to the labels in the room tree or adding some kind of "wait x frames before calling" code, but that somehow seems convoluted and wrong to me. Usually i would just try to shuffle my initialize function around, so change room isn't asking for info that isn't there yet, but we're using that function to create the room and the needed info. Sorry for the messy explanation. In my understanding, I'm supposed to make sure that the label is ready before trying to access what the label actually says. But defining what the label is saying is part of the creation of said label. Which is kinda hurting my brain. Could you please elaborate a little on that? I really appreciate and enjoy your tutorial, but I'm kinda stuck and don't see a good way out.
@jmbiv_dev
@jmbiv_dev 2 жыл бұрын
@@benjamingunther4988 no worries, happy to help! I think I need a bit more context from you - can you either join our discord server and ask your question there with some pictures about what your error looks like + which node you're referring to that's causing the error, or can you give that same info here and I'll try and help?
@benjamingunther4988
@benjamingunther4988 2 жыл бұрын
@@jmbiv_dev Thank you for your help and fast reply, but somehow the problem has solved itself. Today I started up the project and ran the game and on the first try it crashed because of said error. But every try after that it just works. I've literally changed nothing. Computers are weird. But just so you know: the discord link in the description is invalid. 🙂
@xtreme-software
@xtreme-software 2 жыл бұрын
Apparently a known problem. Thanks to this forum post (godotengine.org/qa/110809/node-not-found-why) or RTFM (docs.godotengine.org/en/stable/tutorials/plugins/running_code_in_the_editor.html?highlight=tool#what-is-tool), I have solved it as follows: if Engine.editor_hint: $MarginContainer/Rows/ZoneName.text = value
@insidedevelopment5282
@insidedevelopment5282 3 жыл бұрын
How would I lock a room then???
@jmbiv_dev
@jmbiv_dev 3 жыл бұрын
We'll get to that in the next video! But, if you want a quick answer before then - probably easiest to add another parameter to "connect_exit" in "Room.gd" that is a boolean you can pass in to lock an exit or not.
@rik0904
@rik0904 Жыл бұрын
14:44 in c sharp you set multipleline in PropertyHint of Export attribute
@rik0904
@rik0904 Жыл бұрын
tool in c# work but there are some errors, hard to now why but in process of trying to find out it erase my game_room, fun
@rik0904
@rik0904 Жыл бұрын
i figured out when we do reading node in property that is used for tool we schould use GetNodeOrNull because there is a time window when Game_Room exist but children don't
@charlythompson9281
@charlythompson9281 Жыл бұрын
I'm working in v4.1, and I'm getting a couple of errors which seem to relate to the line room.exits["west"] = exit. First error: res://rooms/Room.gd:64 - at function: connect_exit and the second error: res://rooms/RoomManager:gd:8 - at function:_ready. I'm not certain if it's relevant, but I also have an error in the Debugger that says RoomManager.gd:8 @_ready(): Node not found: "RoomManager" (relative to "/root/Game/RoomManager"). What's confusing is that I do have a node at that address named RoomManager, and it has the RoomManager script attached to it. That script has a yellow arrow pointing at the $RoomFarmhouse.connect_exit("east", $RoomManager). The RoomFarmhouse is a PanelContainer node with a Room script attached to it, and that script has the class_name identifier at the top of the script. Can anyone offer any guidance / help?
@xx___xx2787
@xx___xx2787 10 ай бұрын
hi, not sure if this wil help clear things up but i hope it does, on your line: $RoomFarmhouse.connect_exit("east", $RoomManager) i think for the room you want to connect FarmHouse to, that parameter has to be the other room. For example, my line looks like this: $SpawnRoom.connect_exit("south", $PuzzleRoom) another thing, when you defined the function "@_ready():" did you do the "--> void" before the colon? (obvz, the speech marks arent needed), cuz ive got that on mine and it works fine, as for the other errors, did you export RoomManager into the script (if they were made in another script) because it thinks your referencing the node when (to the software's knowledge) it doesnt exist within the script. I mean you probably have, its just a thought. gotta love scope errors, i get them all the time with functions in python (its a nightmare of a language). just to be clear i have no idea if this is helpful, i spent 6 hours on the GDScript reference docs so i could get familiar with the syntax before doing the tutorial series cuz ive never used this engine before, i have a decent level of coding knowledge because i take a computer science course at college and can code in (the not so useless language for this engine tbh) python. So i hope this makes sense and helps, otherwise i appologise for making you read all this, have a good day/night :)
@charlythompson9281
@charlythompson9281 10 ай бұрын
@@xx___xx2787Thanks so much for taking the time to reply! I gave up on the project and took a different course. :( I may end up revisiting it in the future, though, and I'm sure it'll help somebody else!
@xx___xx2787
@xx___xx2787 10 ай бұрын
@@charlythompson9281 lol, bro it's ok, I did like 3 episodes of the series that day and like no one in comments had the Godot 4 translation, and then someone else was stuck, so I thought I may as well give a solution, well, what made sense to me as a solution, anyways good luck with the course Ur on now and have a great day/night
Twine -- Interactive Fiction Design Tool
9:34
Gamefromscratch
Рет қаралды 48 М.
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
How do Cats Eat Watermelon? 🍉
00:21
One More
Рет қаралды 14 МЛН
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 11 МЛН
How To Shader (Fast) - using Godot Engine
7:10
PlayWithFurcifer
Рет қаралды 335 М.
Using Composition to Make More Scalable Games in Godot
10:13
Firebelley Games
Рет қаралды 235 М.
How to program in Godot - GDScript Tutorial
58:10
Brackeys
Рет қаралды 710 М.
Enemy AI with Behavior Trees - with Demo in Godot Engine
15:26
Jason Lothamer
Рет қаралды 24 М.
How I Fan 3D Cards in Godot 4
9:53
Bramwell
Рет қаралды 36 М.
Making Programs With Godot - Text Editor - Part 1
15:35