Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Having Java as a scripting language?  (Read 4746 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #30 - Posted 2011-11-14 04:13:46 »

I don't think making modders download a full JDK is all that much of a stretch.  Players certainly shouldn't have to.
Just my thought. I realized that I don't really need the ability to compile scripts in the actual game... >_> Stupid stupid stupid!!!

I mean.. just make it easy for yourself Cheesy I don't think performance is going to be a problem this way.
Oh, I will have lots of scripts. I'll be having lots of script hooks/functions that can be implemented by scripts and they are then called when the specified event happens. For example, to implement a life stealing attack, you would have a positive buff that gives a unit a script that has a onAttack() function implemented that checks how much damage is done and gives the unit life depending on how much damage you do.
All in all, I will probably have several hundred script functions called each game update.

Myomyomyo.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #31 - Posted 2011-11-14 04:26:13 »

I don't think making modders download a full JDK is all that much of a stretch.  Players certainly shouldn't have to.
Just my thought. I realized that I don't really need the ability to compile scripts in the actual game... >_> Stupid stupid stupid!!!

I mean.. just make it easy for yourself Cheesy I don't think performance is going to be a problem this way.
Oh, I will have lots of scripts. I'll be having lots of script hooks/functions that can be implemented by scripts and they are then called when the specified event happens. For example, to implement a life stealing attack, you would have a positive buff that gives a unit a script that has a onAttack() function implemented that checks how much damage is done and gives the unit life depending on how much damage you do.
All in all, I will probably have several hundred script functions called each game update.

I don't know. Let me be an idiot here, for a minute.
Don't make a game in java, where all the logic is in scripts, and then expect better performance than in java. Either, you keep it java and provide a compiler or you take jython, or jruby and deal with what performance you will get. It's the price of wanting everything scripted.

/endjerk.

I'm curious; why might you possibly need this? Players who want to mess with scripting, should not have a problem compiling.

Offline avm1979
« Reply #32 - Posted 2011-11-14 04:46:28 »

I'm curious; why might you possibly need this? Players who want to mess with scripting, should not have a problem compiling.

I know that wasn't directed at me but... compiling is a huge pain for a lay modder. If you don't have to compile, the barrier of entry is really low - a text editor and the willingness to experiment. Once you make them run javac with a classpath set properly and all that, I'd think you're weeding out the vast majority of people who might otherwise be interested.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #33 - Posted 2011-11-14 09:55:36 »

I don't think making modders download a full JDK is all that much of a stretch.  Players certainly shouldn't have to.
Just my thought. I realized that I don't really need the ability to compile scripts in the actual game... >_> Stupid stupid stupid!!!

I mean.. just make it easy for yourself Cheesy I don't think performance is going to be a problem this way.
Oh, I will have lots of scripts. I'll be having lots of script hooks/functions that can be implemented by scripts and they are then called when the specified event happens. For example, to implement a life stealing attack, you would have a positive buff that gives a unit a script that has a onAttack() function implemented that checks how much damage is done and gives the unit life depending on how much damage you do.
All in all, I will probably have several hundred script functions called each game update.

I don't know. Let me be an idiot here, for a minute.
Don't make a game in java, where all the logic is in scripts, and then expect better performance than in java. Either, you keep it java and provide a compiler or you take jython, or jruby and deal with what performance you will get. It's the price of wanting everything scripted.

/endjerk.

I'm curious; why might you possibly need this? Players who want to mess with scripting, should not have a problem compiling.
Uhmm, my "scripts" are obviously in Java if I use Janino/JavaCompiler. I don't expect better or even equal performance to Java, just acceptable performance for a game with lots of scripts. I've heard that one of the biggest overheads with script interpreters is calling a script / script method. My case of calling many hundreds 1-5 line script methods would therefore be a worst case scenario for interpreted script languages. I'm just trying to do this "right" the first time so I hopefully don't have to redo it.

Both Mads and Sproingie do have a point that people who want to mess with scripting and such stuff shouldn't have a problem with installing the JDK, so believe I have "solved" my actual problem here. I'll compile scripts in the map editor and save them in the files, so only the map editor will need a JDK to compile scripts. The actual game will only load the compiled scripts' class files. I will continue to keep an eye on Janino though, as implementing it in the map editor would be very nice. I'd also like to implement my stat expressions (like Damage = Strength * 3) using compiled code instead of the external expression lib I'm using right now. This would obviously not be affected by the bug(s) mentioned earlier in the Janino compiler, so I'll probably implement it when I have the time.

I'm curious; why might you possibly need this? Players who want to mess with scripting, should not have a problem compiling.

I know that wasn't directed at me but... compiling is a huge pain for a lay modder. If you don't have to compile, the barrier of entry is really low - a text editor and the willingness to experiment. Once you make them run javac with a classpath set properly and all that, I'd think you're weeding out the vast majority of people who might otherwise be interested.
Huh I'd obviously do all the compiling in the map editor using JavaCompiler. No need to manually compile scripts. I'll then have a play button that compiles all the scripts and fires up the game with the map, and also an export function that saves a playable map from a map project with all the scripts compiled so that it can be opened by the game without the need for a JDK. The only thing that the actual modder/maker is exposed to when it comes to compiling is having to download the JDK.

Myomyomyo.
Offline Chromanoid

Junior Devvie


Medals: 3



« Reply #34 - Posted 2011-11-14 16:30:30 »

If you want a JDKless alternative for Janino you might want to look at the Eclipse JDT Compiler. It is used in the popular Reporting Engine JasperReports for "scripting" purposes. Maybe you can try Groovy and similar languages that don't need the jdk for compiling to javavm bytecode as well. In a first prototype it should be easy to implement Groovy, Clojure, JDT Compiler, JavaCompiler... Then you can check performance and ease of use.
Offline avm1979
« Reply #35 - Posted 2011-11-14 16:41:18 »

Huh I'd obviously do all the compiling in the map editor using JavaCompiler. No need to manually compile scripts. I'll then have a play button that compiles all the scripts and fires up the game with the map, and also an export function that saves a playable map from a map project with all the scripts compiled so that it can be opened by the game without the need for a JDK. The only thing that the actual modder/maker is exposed to when it comes to compiling is having to download the JDK.

Ah, my apologies, that wasn't obvious to me Smiley From what Mads said, it seemed like modders would have to know about "compiling", which in this case they don't. They just have to install the JDK, as you said, and the rest just magically works. My mind just didn't conflate "modding" with "map editor".

Offline nsigma
« Reply #36 - Posted 2011-11-14 17:09:20 »

Sorry, my code is currently more similar to scrambled eggs than to actual code. I basically hackingly merged two different test programs. Go figure... T_T

It's easy to reproduce though. Just create two java files, with the first one containing a method with a while(true)-loop with a break; to exit it. Then load both of them with a JavaSourceClassLoader (the while-break one first) and bam! JaninoRuntimeException!  Cry

Only just had a chance to follow up.  This is exactly what I'd tried out in Praxis without problem - just checking there wasn't anything more complicated involved.  As mentioned, I'm using 2.5.16 and the ClassBodyEvaluator.  Which of those helps I don't know.

I think the SimpleCompiler superclass of ClassBodyEvaluator can compile full Java classes too (personally I prefer using class bodies for user scripts) which might also work OK.

I realise from subsequent replies you may have talked yourself out of Janino by now, though  ...  Smiley

Best wishes, Neil

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline impaler

Senior Newbie





« Reply #37 - Posted 2011-11-17 12:41:51 »

A bit late, but what about Beanshell?

http://www.beanshell.org/

It uses Java syntax too which makes it even easier.
Offline avm1979
« Reply #38 - Posted 2011-11-17 16:19:29 »

Only just had a chance to follow up.  This is exactly what I'd tried out in Praxis without problem - just checking there wasn't anything more complicated involved.  As mentioned, I'm using 2.5.16 and the ClassBodyEvaluator.  Which of those helps I don't know.

I think the SimpleCompiler superclass of ClassBodyEvaluator can compile full Java classes too (personally I prefer using class bodies for user scripts) which might also work OK.

Just to make sure - are you using the same instance of ClassBodyEvaluator to compile both snippets? You have to be using the same instance of JavaSourceClassLoader for the problem to show up.

Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (64 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!