Ren'Py #11 Using Classes

  Рет қаралды 24,580

Game Developer Training

Game Developer Training

Күн бұрын

Пікірлер: 49
@phoenixofthegraveyard
@phoenixofthegraveyard 3 жыл бұрын
You are awesome. This is the clearest example I've seen of someone explaining classes step by step and how versatile they are. Thank you!
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
Glad it was helpful!
@paulschaaf8880
@paulschaaf8880 3 жыл бұрын
Thank you for a great explanation on a confusing subject. It took me awhile to get the hang of it but after a little tweaking I managed to get a calendar/clock modeled after yours working as well as a class system for stats, nicknames, traits, skills, inventory, upgrades, etc. Much nicer way to organize things than having hundreds of loose variables to keep track of.
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
Glad it was helpful!
@maverick_nyaa
@maverick_nyaa 4 жыл бұрын
Can you declare the list of months first and then create the calendar object without pasting the entire list as the parameters? @11:24
@adamcelej5371
@adamcelej5371 3 жыл бұрын
Yes, it is possible
@spectre_tea
@spectre_tea 3 жыл бұрын
why do we have to inherit created class from class object? usually it isn't done in native Python also what's the point of writing "@property" before functions of a calendar?
@gapedandamazed6988
@gapedandamazed6988 3 жыл бұрын
Well I tried without it. It just gave me the object place in memory instead of the calendar
@aykonsilvers
@aykonsilvers 3 жыл бұрын
I appear to be stuck here. I did everything exactly as the tutorial said, but when I load up the game and open Developer console. I type "print Calendar.Output" and get a response that name 'Calendar' is not defined. and it calls out an error in py_exec. Any idea how this went wrong? TIA.
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
Calendar is the name of the class, you need to reference the instance of the class which is calendar with no capital
@nicolauscahyadi140
@nicolauscahyadi140 3 жыл бұрын
Thank you for explanation. I have a question, I'm currently making class which it can store objects, but I want call it in different files. for example, I create class in file A, and I want call it in file B for storing object. it's that possible? or it should same file? Thank you.
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
You can define a class in a separate file. Ren'Py treats all your .rpy files as if they were one file.
@Aniknk
@Aniknk 5 жыл бұрын
Yes! After an hour I did it right! Now I have useless calendar.
@likopinina6803
@likopinina6803 4 жыл бұрын
well the point wasn't really the calendar, but figuring out how classes work, so you can use them for other stuff
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
Precisely. You would think the name of the video would give that away.
@madsixvines4839
@madsixvines4839 Жыл бұрын
But what if I want to increase time only when player does something?
@jamesimrobertson5422
@jamesimrobertson5422 4 жыл бұрын
What's the function of the 'self.Hour = Hour' et al code lines? Are they not implicit given the 'def' property list. and if necessary can they not be automatically generated from the 'def' statement with one click?
@shinminmetroskyline
@shinminmetroskyline 2 жыл бұрын
doubt it
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
no
@briannao1224
@briannao1224 4 жыл бұрын
I've been slowly learning thanks to your videos! I have run across an issue though and I can't figure out how to fix it! When I first tried using self. it worked and I had no problems. I don't know if I hit a button or something, but now every time I type self. it doesn't highlight it and doesn't seem to recognize it as anything. I've tried changing my spacing and a whole bunch of other things to fix it, but I can't seem to figure out what's gone wrong! Any advice on what to do would be very helpful!! Thank you for these great videos!!
@artwitha.g.8955
@artwitha.g.8955 4 жыл бұрын
I've once ran across a similar problem and it was because my file was a set to python and not ren'"py ( like the file name didnt end in .rpy) so maybe check that ? ( idk im rly clueless too and pretty new to this lmao but hope this helps !)
@christopherpittaway8902
@christopherpittaway8902 2 жыл бұрын
i'm very sorry to bother but i'm trying to add a similar function into a project i am working on, only i am adding minutes instead of hours, whenever i call the function to add time it returns none, do you know a way i could try to fix this?
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
without seeing code I wouldn't be able to help. Please don't post code here though, thanks.
@antoinest-germain9260
@antoinest-germain9260 3 жыл бұрын
Hi, it is necessary to inherit the class with the object one? If yes, why is it? I'm using python to program several things for many years but don't figure out why should we do this to create a class inside of renpy.
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
Ren'Py is just a Python module. Everything you do in Ren'Py has to be interpreted into Python so it makes more sense to use native Python as much as possible to optimize your code
@readyloserone9364
@readyloserone9364 2 жыл бұрын
Hey! I know this video is pretty old, but I have a pretty major issue that I’ve come across. Similar to other comments, I can’t seem to figure out how to type “print calendar.Output” into the console. It just gives me a NameError about “calendar not defined”. Do you have any advice on this?
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
There are a number of reasons it might not be working, check for typos, tabbing errors and make sure you are running the console from within the game and not from the main menu.
@CrunchyFreak
@CrunchyFreak 4 жыл бұрын
When I delete the parts from my script file like you have at the end, ingame it displays as [Output] and not the actual information in the events file. I have been trying for 3 hours to work out what I've done wrong and I can't work it out!
@CrunchyFreak
@CrunchyFreak 4 жыл бұрын
hadn't added calendar.Output to the Output! Just worked it out!
@samygafsi6429
@samygafsi6429 2 жыл бұрын
When declaring the variable calendar as Calendar Class, I face a limit of items I can use. When I'm at the Weekdays, in the middle it goes gray. It's as if there is a limit of items I can use. When I remove one of the months, I get an extra item, so one of the days is no longer grayed out. Here's an example : When I declare the following line : $ calendar = Calendar(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 0, 3, 4, ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat","Sun"]) Anything beyond "Fri" is grayed out (even the rest of the code not just this line). But If I delete any month or the colored week days, "Sat" is green. And If I delete both "Sat" and "Sun", the rest of my code is colored and working again. Any idea how I can solve this ? Or what is the issue exactly ?
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
There is no issue, atom just does that for some reason
@samygafsi6429
@samygafsi6429 2 жыл бұрын
@@GameDeveloperTraining How can I overcome this ? Any settings to change ?
@samygafsi6429
@samygafsi6429 2 жыл бұрын
@@GameDeveloperTraining I'm sorry for overwhelming you with questions. But if ATOM keeps doing this, it might present a big limitation on future code. I'm considering making a sandbox game and you can imagine how this is important.
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
@@samygafsi6429 it doesn’t affect your code, just the visual representation of it. You can add code even after it changes colour
@samygafsi6429
@samygafsi6429 2 жыл бұрын
@@GameDeveloperTraining Thanks for the quick reply. and Kudos on these tutorials, you made Renpy look so approachable and doable. You are doing an amazing job and service to everyone watching the playlist.
@Az-od3ip
@Az-od3ip 3 жыл бұрын
This is a great video, helped a lot and I thank you that. But I had some problems with some small concepts that you didn't talk about. First, I don't know why, but you can't define your class holder variable outside of labels. If you do, ren'py will not recognize your class as existent. Also, even if you define It inside a label, ren'py will not complain about your class being non-existent anymore but the class properties are inaccessible. The best way to define the class I found was below the class itself, yet I'm still unable to comprehend what kind of weird scope ren'py has. Edit: I did watch almost all of your videos. And I really think you should make a video about scopes.
@GameDeveloperTraining
@GameDeveloperTraining 3 жыл бұрын
All classes should be defined in the Init Python block. Classes are standard Python code and nothing to do with Ren'Py
@WingerWind
@WingerWind 2 жыл бұрын
Hello! This video may be from four years ago, but I was wondering if anyone could help me with an issue I’ve found. Do keep in mind that I’ve gone through this video three times inspecting every line of code, yet somehow haven’t found anything that doesn’t match GDT’s code. print Calendar.Output NameError: name ‘Calendar’ is not defined Traceback (most recent call last): File “renpy/common/00console.rpy”, line 689, in run renpy.python.py_exec(code) File “/Users/(my full name)/Applications/renpy-7.5.1-sdk/renpy/python.py”, line 1062, in py_exec exec(py_compile(source, ‘exec’), store, locals) File “”, line 1, in NameError: name ‘Calendar’ is not defined I’ve been stuck looking up solutions and finding nothing for several days by now 😅
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
Check your class name uses the same case as where you are referencing it, i.e. check that you are using capital letters correctly.
@dovedozen
@dovedozen 4 жыл бұрын
I owe u my life
@TheVallin
@TheVallin Жыл бұрын
Had some issues getting things to work after I decided to customize a bit of the code, python not being my normal scripting language. But I managed to figure it out. Kept getting a ''int' object is not iterable' error. So had, self.TOD[self.TODs] but had to code going self.TOD += TOD insted of the TODs. And forgot to replace Hours in the 'def AddTime(self, Hours):' with TODs. Had to rewatch this vid to find out what I did wrong! Thanks again for making this tutorial!
@thechaoscabinett
@thechaoscabinett 2 жыл бұрын
I swear, I was so frustrated when I got errors you didn't and just decided to not finish the video. I should've just finished it, I was just ahead of you. 😅
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
Mate, this is the problem so many people encounter and they get all angry with me lol. Glad you finished the vid ;)
@snailandspider9178
@snailandspider9178 2 жыл бұрын
I have a message error for "if self.Days > self.MonthDays[self.Month]:" saying that : " '>' not supported between instances of 'int' and 'str' " but I'm pretty sure I did everything correctly (sorry for misspelling english isn't my first language) Edit : I found out what was the problem but now I have the error "Possible infinite loop" Edit 2 : Now that I have solved the "infinite loop" problem the calendar only start to work at the end of my game
@GameDeveloperTraining
@GameDeveloperTraining 2 жыл бұрын
Keep working at it, you'll get there.
@czzrd1370
@czzrd1370 Жыл бұрын
Hi, Could you please explain how you solved it... (if you still remember :) )
@snailandspider9178
@snailandspider9178 Жыл бұрын
@@czzrd1370 Sorry it's been some time so I don't really remember but I think the problem was that I made a mistake while writting the months or the days
Ren'Py #12 Using classes - Part 2
9:31
Game Developer Training
Рет қаралды 11 М.
Ren'Py #14 Using classes and lists to create a Player Inventory
24:38
Game Developer Training
Рет қаралды 16 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
All Rust features explained
21:30
Let's Get Rusty
Рет қаралды 335 М.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
thoughtbot
Рет қаралды 915 М.
Ren'Py #26 Sub-locations Pt.1
19:50
Game Developer Training
Рет қаралды 6 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 513 М.
How I use object (classes) as a non programmer for Renpy games
21:18
Ren'Py #16 Customising the Choices menu
9:04
Game Developer Training
Рет қаралды 20 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
Malware Development: Processes, Threads, and Handles
31:29
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 576 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН