Typing in Java on Renpy?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Typing in Java on Renpy?

#1 Post by Nucl3arSnake »

I'm not too familiar with writing in Python and I have some effects that I would like to use in the game, but I only know how to write them in Java. Would it be possible to change the writing language in the script/gui/etc to Java or would I just have to learn Python?

For ex: changing password manually if the user had forgotten it.

Password b= new Password();
String b = ID 10 T;

I really just want to use setters/getters and instances to do this.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Typing in Java on Renpy?

#2 Post by SuperbowserX »

Can you be more specific on what you want to do? Unless you're doing a *really* complex operation I can't see why you would need to implement Java.

Changing passwoord? For what? Like an in-game password that the user has to figure out as part of the puzzle? Or for a save game? Or a password to start the game? You can easily do that by just making a label that takes in arguments in Ren'py (which is the equivalent of a Renpy function).

I think you should tell us what you are trying to implement, and we'll see if we can think of python/renpy code that can implement it.

Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Re: Typing in Java on Renpy?

#3 Post by Nucl3arSnake »

I would just type it in Python/RenPy but I can't type in that coding language fluently.
I added two screenshots of part of the script where the code would be needed.

In the beginning of the game the player is able to type in their own password.
Later in the game, if they had forgotten it and can't type it in, then there would be a code that would change the password manually to ID-10-T.

I would use one class of setters and getters to declare an instance for the password.
Then in the other class I could declare the new password.

But this isn't the only thing i would use Java for, there's a lot more, but that's just one example. It would make my coding SO much easier if i could type it in Java.
Attachments
Screenshot_2017-04-01-14-50-45.png
Screenshot_2017-04-01-14-50-37.png

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Typing in Java on Renpy?

#4 Post by SuperbowserX »

Well you'll need to learn Ren'py language. It's very very simple; read the documentation, i..e the quickstart.

What are the common functions you would need to use in Java? I can provide their Ren'py equivalents.

I'd rather use the easy say statement than use the System.out.println() thing.

At the first password entry, just use something to the effect of:

Code: Select all

"Enter the password you desire."
$ pass = renpy.input()
And later, something to the effect of:

Code: Select all

"What was the password you previously entered?"
$ attempt = renpy.input()
if attempt != pass:
    "This is the wrong password. It is being changed to ID-10-T."
    $ pass = "ID-10-T"
else:
    "That is the right password!"
EDIT: Forgot to double check the image when I saw your code example. So this example probably isn't what you are looking for. But the basic rules of say statements, variable definitions, and user inputs are still demonstrated.

Please, don't be afraid to learn the Ren'py language :) If you have any questions, please post them in this thread and we'd be glad to help. Also, I know quite a bit of Java, and I'm 99% sure that it'd be far easier to use the Ren'py language.

Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Re: Typing in Java on Renpy?

#5 Post by Nucl3arSnake »

I have read the documentation but nothing sticks :/ and im just more well versed in Java, it would make the process go by faster.
It will be really nice if you can provide the equivalents! But the game script is still being developed so I don't have the full list. So my questions about this will probably be well sparsed all the way into this summer.
I have found some code for other things that I needed for the game, but i really had to dig through some archives.

//I really dont mind typing System.out.println(); all the time.
I guess what I'm trying to say is that I'm more comfortable with Java than the RenPy language and i know what I'm doing with Java.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Typing in Java on Renpy?

#6 Post by SuperbowserX »

The equivalent of System.out.println() is the say statement. Just do this:

Code: Select all

"Hello."
And if you want a character to say something, just say:

Code: Select all

emi "Hello."
Where emi is a defined character.

To define a variable, just do:

Code: Select all

$ money = 100
or

Code: Select all

$ name = "John"
You don't need to specify variable name in Python or Ren'py. No initialization needed (but still an error if undefined variable is used).

No semicolons needed. Ren'py/Python runs on indentation, which is handled automatically with mostly all text editors.

if statements are largely the same. Except that for conditionals, instead of using "&&", "||" and "!", you instead use "and", "or" and "not" respectively.

I know it can be daunting/frustrating to learn a programming language, but you gotta try. It's part of the experience.

Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Re: Typing in Java on Renpy?

#7 Post by Nucl3arSnake »

So it just knows what kind of variable needed?
So an
int something =42

Would just be
$ something=42 and it knows that's an int. Etc for other variables...

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Typing in Java on Renpy?

#8 Post by SuperbowserX »

It's not quite that it knows what kind of variable it is -- more that if you use the variable later for an appropriate purpose, it will work.

$ something = 42 may be an integer; or it may be a double or some other numeric data type. But when you run code that uses the variable it won't actually matter.

It depends on what you want to do with it. If you want it to be a string (so that you can append it or check if a substring exists within it) then you just define it with quotes.

If you are printing the variable, then it's even easier than Java or python.

Code: Select all

$ something = 400
"The value of the something variable is [something]."

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Typing in Java on Renpy?

#9 Post by trooper6 »

I started as a Java programmer. Ren'Py is based in Python and you can't just write in Java. The Ren'Py language gives you a lot, more complex things you'd need to write in Python. Python is. It difficult to transition over to from Java. I recommend taking the Basic Python course over at codeacademy.com -- it is free.

Python is different from Java...you don't use getters and setters for the most part...you just directly access the variables you want. Also, Python let's you have methods not tied to a class. There is a lot of good stuff in there. I really recommend the following:

1) Read through Ren'Py documentation--especially the QuickStart
2) Look at the code in the Ren'Py Tutorial game to see how things look in practice
3) Download a few games that haven't archived their code...and check out their code to see code in practice.
4) Do the Python course from codeacademy.com
5) Do small exercise projects to test little hinge before you make your magnum opus. Like do something that involves screen language, do something with menus, try a basic inventory thing.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Re: Typing in Java on Renpy?

#10 Post by Nucl3arSnake »

Like I said before I've already read /all/ of the documentation, I just have a hard time remebering things. That and I've already made a vertical slice for my current game. I don't need tutorials for Renpy, I just wanted to know if it was possible to switch to Java. That's already been answered as a no.

User avatar
SuperbowserX
Veteran
Posts: 270
Joined: Sat Jan 07, 2017 3:09 pm
Contact:

Re: Typing in Java on Renpy?

#11 Post by SuperbowserX »

Yeah unfortunately the answer is no. Good luck trying to get the hang of the language.

Nucl3arSnake
Newbie
Posts: 11
Joined: Sat Feb 25, 2017 2:57 pm
Projects: Deus Ex: Love Augmented
Tumblr: askfrankpritchard
Contact:

Re: Typing in Java on Renpy?

#12 Post by Nucl3arSnake »

Thanks for your help :)

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Typing in Java on Renpy?

#13 Post by zmook »

Nucl3arSnake wrote: Sat Apr 01, 2017 3:34 pm I really just want to use setters/getters and instances to do this.
Python has classes, getters and setters, so you can use the Java idioms if you really want to. But ultimately it's a very different language and you're going to have to learn at least some of it, and also Ren'py which is three more languages (Statement, Screen, and ATL).

If reading the docs doesn't stick, just throw yourself into it and look up every line until you start remembering. I'd also recommend getting to know the Console -- with an interpreted language you can learn a lot by trying syntax and seeing immediately what happens.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

Post Reply

Who is online

Users browsing this forum: No registered users