GMOD and Java

Do they work together at all…?

I am 10* better with Java then Lua and want to know if they work with eachother :stuck_out_tongue:

You’ll have to learn Lua if you want to script in GMod, no other scripting languages are either implemented or supported.

But knowing Java you’re obviously already familiar with the concepts shared by most languages (variables, loops, ifs, functions/procedures, arrays/tables etc), so Lua should take very little time for you to learn. It really is piss easy to get to grips with, very lenient.

Yeah, but I wasn’t sure if you could make like menu’s for example with Java instead of lua because they are alot better.

Well there are a few modules that let you use Ruby and Python.
Gm_Ruby
Gm_Python

Technically the menu systems aren’t from lua, they’re Source engine hud elements that have been bound to lua functions. If you install lua stand-alone then you won’t get Derma.
I prefer the Lua system as you can more easily say where everything has to go and you can give buttons Callbacks instead of hacky action listeners.

I don’t quite understand. Do you mean you prefer the VGUI capabilities of Java to those of Derma?

That’s what he means, although I personally like Derma alot.

You can’t use Java in the Garry’s Mod Lua environment, without a module. As far as I know, a quality one doesn’t exist. If you do know Java, it shouldn’t take you too long to learn Lua, and apply it to Garry’s Mod. In no sense are Java’s menus better than Luas/Garry’s Mods. It’s all about how you, the coder, makes them.

Some things Java and Lua have in common:
They are both interpreted languages
They both compile into an intermediate bytecode before the interpreter runs it.
They are both able to run on any system where there is a Lua interpreter.

Differences:
Java is Statically Typed, so you have to define what types of variable are allowed in whichever part of memory, whereas in Lua any variable can hold any type of data.
Lua uses natural language for boolean operators whereas Java uses C style && and ||. (Garrysmod Lua is a variation which allows these operators, but they aren’t Lua standard).
Java has a massive standard library, Lua has a tiny one.
Lua has advanced language features like function closiures.
In Lua every data structure is a table, whereas Java has many different ones. Lua tables are essentially HashMaps, they work like arrays if you only use sequential integer keys, they work like Maps for non-sequential keys, they work like Sets if you have the object as the key and the value as ‘true’.