tuntis
03-28-2009, 01:40 PM
VCO's server scripting engine is great and allows for a lot of great stuff, especially when compared to MTA/VC-MP's horrid scriptability options. But I have 2 suggestions to consider for future releases, and would like some comment from others:
A more object-oriented approach
For example, the player functions. Currently, for example, you would set a player drunk like this (assuming the player ID is #5):
togglePlayerDrunk(5, true)
Simple? Yes. But what if it would be like this instead:
p = Player(5) // Creates a new Player object that fetches player #5
p.toggleDrunk(true) // Sets the player into drunk mode
I know what you're thinking - seems more complicated, right? But an object-oriented approach is cleaner. Modern programming & scripting languages use OOP patterns. Furthermore, if we'd assume there would be a /drunk command to make a player drunk, like this:
function MakePlayerDrunk(PlayerID)
togglePlayerDrunk(PlayerID, true)
end
What if PlayerID would be replaced by a Player object instead? The above code would become this:
function MakePlayerDrunk(PlayerID)
PlayerID.toggleDrunk(true)
end
I think that an object-oriented design pattern (buzzwords, hooray!) would make scripting easier and cleaner. Juggling around Player ID's in code can get far more messier than a Player object, IMO.
Replacing the current MySQL commands with LuaSQL
LuaSQL (http://www.keplerproject.org/luasql/) is a Lua library designed for database access. I think integrating this with VCO would be easier for both sides - no need to write own MySQL commands, but instead just provide basic documentation for a grown, mature DBMS interface library.
Note that I'm not criticizing VCO in any way - the current scripting possibilities are great, but I personally feel that this could be done to make it even better. Your thoughts?
A more object-oriented approach
For example, the player functions. Currently, for example, you would set a player drunk like this (assuming the player ID is #5):
togglePlayerDrunk(5, true)
Simple? Yes. But what if it would be like this instead:
p = Player(5) // Creates a new Player object that fetches player #5
p.toggleDrunk(true) // Sets the player into drunk mode
I know what you're thinking - seems more complicated, right? But an object-oriented approach is cleaner. Modern programming & scripting languages use OOP patterns. Furthermore, if we'd assume there would be a /drunk command to make a player drunk, like this:
function MakePlayerDrunk(PlayerID)
togglePlayerDrunk(PlayerID, true)
end
What if PlayerID would be replaced by a Player object instead? The above code would become this:
function MakePlayerDrunk(PlayerID)
PlayerID.toggleDrunk(true)
end
I think that an object-oriented design pattern (buzzwords, hooray!) would make scripting easier and cleaner. Juggling around Player ID's in code can get far more messier than a Player object, IMO.
Replacing the current MySQL commands with LuaSQL
LuaSQL (http://www.keplerproject.org/luasql/) is a Lua library designed for database access. I think integrating this with VCO would be easier for both sides - no need to write own MySQL commands, but instead just provide basic documentation for a grown, mature DBMS interface library.
Note that I'm not criticizing VCO in any way - the current scripting possibilities are great, but I personally feel that this could be done to make it even better. Your thoughts?