Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

RT @justcause: Make somebody happy today and send them a Steamy gift! 80% off on the whole #JustCause series! http://t.co/DCwjtFgVnp http:/…

1 month ago

October 26, 2014, 02:50:46 am

Poll

What scripting language would you most like implemented?

Lua
223 (59%)
Squirrel
25 (6.6%)
Python
69 (18.3%)
JavaScript
54 (14.3%)
Other (Mention in post)
7 (1.9%)

Total Members Voted: 378

Author Topic: Scripting Language  (Read 11286 times)

Trix

  • JC2-MP Developer
  • Full Member
  • *****
  • Posts: 151
    • View Profile
Scripting Language
« on: July 25, 2012, 03:31:00 pm »
As the scripting system has not been implemented and a lot of people are requesting we not use Lua, I'm interested in knowing what you, the community, are interested in.

If your language of choice isn't listed, please give in-depth reasons as to why we should consider your choice.

Qasaur

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Scripting Language
« Reply #1 on: July 25, 2012, 10:01:06 pm »
Lua definitely, it's been proven in use in multiple games such as Garry's Mod and many other games. It's also an easy language to learn and will make the scripting community larger than if you use say, JavaScript.

Python is also an excellent language and is also very easy to learn.

However, between the two I would say LUA because of the massive success it has had with the Garry's Mod scripting community.

Oceanity

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Scripting Language
« Reply #2 on: July 25, 2012, 10:38:56 pm »
I'm kind of curious as to the reasons people are against the use of Lua, it's generally perfect for things such as this.

To be fair, I'm not entirely knowledgeable of scripting languages outside of Lua, JS and a bit of Python, so it could just be that I'm not aware of a better alternative.  :P

Philpax

  • JC2-MP Developer
  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Scripting Language
« Reply #3 on: July 26, 2012, 12:15:04 am »
I think we should go with Befunge! It's very practical!

On a serious note, I'd agree with Lua, due to its simplicity and community. It's a shame you have to fake object-oriented classes, but the benefits are worth it. It's also easy to implement, depending on whether you use the C API, LuaBind, toLua++, and others.

Squirrel looks pretty interesting, but it also seems relatively unproven in the field of game (and derivative) development. If you have time, later on in the project, I'd suggest you implement a small portion of each language and show some code snippets; how each language will be used at release will make all the difference (obj.method(something), and not method(obj, something)).

Killjoy0593

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Scripting Language
« Reply #4 on: July 26, 2012, 02:32:17 am »
Lua to my understanding is the most streamlined scripting language, fun to work with too :)

Rick

  • JC2-MP Betatester
  • Newbie
  • *****
  • Posts: 7
    • View Profile
Re: Scripting Language
« Reply #5 on: July 26, 2012, 03:02:48 am »
All votes for Lua should double as votes for Squirrel.  8)

baconcow

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Scripting Language
« Reply #6 on: July 26, 2012, 06:57:17 am »
I don't know any of these languages, but the Lua manual from their website looks very well organized.

xEnt

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Scripting Language
« Reply #7 on: July 26, 2012, 08:56:42 am »
this is hugely biased from the amount of people from SA-MP that are used to lua.

go with javascript imo, everyone knows java/javascript/c#

Glata

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Scripting Language
« Reply #8 on: July 26, 2012, 09:43:27 am »
LUA is by far the best, JavaScript seems to be coming second in the vote for whatever reason. I find JavaScript a pain to use.

EDIT: In my stupidity forgot to add Script at the end of Java.
« Last Edit: July 26, 2012, 12:56:51 pm by Glata »

Oz

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Scripting Language
« Reply #9 on: July 26, 2012, 10:40:13 am »
this is hugely biased from the amount of people from SA-MP that are used to lua.

SA-MP doesn't use Lua, it uses PAWN or something. You're thinking of MTA, which does use Lua, and to me that's a key reason why it's a good reason for JC2-MP to use the same language. Easier uptake to scripting if you're using a language folks are already familiar with. Since JC2 is a similar style of game to GTASA, makes sense to cater towards people coming from multiplayer mods of GTASA (eg MTA) since they'll probably form a big chunk of the player community.

I'm all for Lua, it'll help bring the MTA community across at least, and folks from Garry's Mod.

Philpax

  • JC2-MP Developer
  • Hero Member
  • *****
  • Posts: 563
    • View Profile
Re: Scripting Language
« Reply #10 on: July 26, 2012, 10:44:33 am »
LUA is by far the best, Java seems to be coming second in the vote for whatever reason. I find Java a pain to use.

Java? Java and Javascript are two very different things.

heh

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Scripting Language
« Reply #11 on: July 26, 2012, 10:55:08 am »
Python would be a better choice if Lua is out. Very easy to learn, great cross compatibility and it's extremely fast.

Also will it be possible to write "plugins" in cpp for the servers? Because if it came down to using Lua or that I'd prefer offloading my commands and such into cpp and calling them via the scripting lang.
« Last Edit: July 26, 2012, 11:01:57 am by heh »

Wizzy

  • Donator
  • Newbie
  • *****
  • Posts: 19
    • View Profile
Re: Scripting Language
« Reply #12 on: July 26, 2012, 11:43:15 am »
I'd suggest Lua or furthermore, LuaJIT2, which has proven to be a lot faster than the normal Lua while providing the same level of debugging capabilities as the standard Lua.

The only real downside of Lua is the lack of object orientation which often leads to hardly maintainable cluster code.


After all I'd suggest Lua, with some utility libs and and a class wrapper maybe.

Some time ago I wrote a rather primitive but useful class wrapper for lua, which supports inheritance and stuff like that:

Code: [Select]
local tinsert = table.insert
local tremove = table.remove
local tostring = tostring
local setmetatable = setmetatable
local getmetatable = getmetatable
local next = next

function super(obj)
local new = {}
for k, v in next, obj do
new[k] = v
end
return setmetatable(new, getmetatable(obj).super)
end

function class(name, statics, methodes, parentClass)
local classTbl = {__parentClass = parentClass}--The actual class table

if(parentClass) then--we require a reference to the parent class
classTbl.super = parentClass.__methodes
end

if(not methodes.__tostring) then--implementing tostring if not existant
methodes.__tostring = function(self)
return name ..": " .. self.__address--"CLASSNAME: ADDRESS"
end
end

if(methodes[name]) then
methodes.__construct = methodes[name]
end

if(parentClass) then
for k, v in next, parentClass.__methodes do--copying methodes from superclass
if(not methodes[k]) then
methodes[k] = v
end
end
end

classTbl.__methodes = methodes--needed for later access

classTbl.__methodes.__index = methodes--Required

local ClassMeta = {--Class metatable needed to "call" the class itself
__call = function(self, ...)--constructor
local instance = {}
local hexAddress = tostring(instance):sub(-8)--saving the hex address for tostring use
setmetatable(instance, methodes)--required
instance.__address = hexAddress--setting the address

local currParent = parentClass
local constructorStack = {instance.__construct}--the constructors need to be called in the opposite inheritance order
while currParent do
if(not currParent.__methodes.__construct) then--If we have a superclass
break
end
tinsert(constructorStack, currParent.__methodes.__construct)--pushing the function onto the stack

currParent = currParent.__parentClass
end

while(constructorStack[1]) do--calling all constructors
tremove(constructorStack)(instance, ...)--hacky :3
end

return instance
end
}

for k, v in next, statics do--copy statics into our table
ClassMeta[k] = v
end

if(parentClass) then--copying statics
for k, v in next, getmetatable(parentClass) do
if(not ClassMeta[k]) then
ClassMeta[k] = v
end
end
end

ClassMeta.__index = ClassMeta--required
setmetatable(classTbl, ClassMeta)--required
return classTbl
end


--EXAMPLE CODE--

Vector2 = class("Vector2", {}, {
Vector2 = function(self, x, y)
self.x = x or 0
self.y = y or 0
end,
__add = function(a, b)
return Vector2(a.x + b.x, a.y + b.y)
end,
__tostring = function(self)
return "Vector2: " .. tostring(self.__address) .. ", " .. tostring(self.x) .. ", " .. tostring(self.y)
end
})

vecA = Vector2(25, 24)
vecB = Vector2(50, 26)

print(vecA + vecB)

Vector3 = class("Vector3", {}, {
__construct = function(self, x, y, z)
self.z = z or 0
end,
__add = function(a, b)
return Vector3(a.x + b.x, a.y + b.y, a.z + b.z)
end,
__tostring = function(self)
return "Vector3: " .. tostring(self.__address) .. ", " .. tostring(self.x) .. ", " .. tostring(self.y) .. ", " .. tostring(self.z)
end

}, Vector2)

vec3A = Vector3(10, 20, 30)
vec3B = Vector3(50, 60, 70)

print(vec3A + vec3B)

Vector4 = class("Vector4", {}, {
__construct = function(self, x, y, z, w)
self.w = w or 0
end,
__add = function(a, b)
return Vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w)
end,
__tostring = function(self)
return "Vector4: " .. tostring(self.__address) .. ", " .. tostring(self.x) .. ", " .. tostring(self.y) .. ", " .. tostring(self.z) .. ", " .. tostring(self.w)
end
}, Vector3)

vec4A = Vector4(10, 20, 30, 18)
vec4B = Vector4(50, 60, 70, 12)

print(vec4A + vec4B)
« Last Edit: July 26, 2012, 11:57:11 am by Wizzy »

JJJan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Scripting Language
« Reply #13 on: July 26, 2012, 12:02:56 pm »
I'm a Java developer, but my first choice is Lua too. But I'd also love to see Java implemented ..

Plantjen

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Scripting Language
« Reply #14 on: July 26, 2012, 12:29:05 pm »
I definitely prefer LUA, as said before, this will attract many MTA mod developers.