Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Freakyy

GTALua - Script Engine in Lua

Recommended Posts

Freakyy

Image.png

GTALua - A Powerful Scripting Engine for GTA V in Lua

Current Features

  • NEW Timers
  • NEW Events (OnPedCreated, OnVehicleCreated)
  • NEW Object-Oriented Wrappers for natives (+ Documentation & lots of examples)
  • NEW Flexible/Simple GUI-module
  • All 5300 Natives accessible in Lua
  • Console that contains error messages and has support for own commands
  • Good Documentation to get you started with GTALua (Wiki & Tutorials & Examples)
  • Load/Reload/Unload your scripts with a simple command in the console while ingame
  • Intro movie skipper

Planned Features

  • Automatic Refresh (instead of current manual method)
  • Script Database (maybe)

Scripting Documentation
Make sure to check out the examples, you can find them in GTALua/addons/
We also have a wiki, you can find a tutorial and other things there! Check it out

Not convinced?


Less code, same result
Both scripts do exactly the same, but the left one is way easier and cleaner.
not_convinced_1.png

Menus
simple_menu_example.png
Check out: gui.SimpleMenu



Changelog
NEW Current Version: 1.1.0 (Alpha)

  • Added Timers
  • Added Events (OnPedCreated, OnVehicleCreated)
  • Added ScriptThread:Tick
  • Added lots of more wrappers for Blips & ui.CreateBlip
  • Added gtalua.ini (contains configuration for console)
  • Improved gui.SimpleMenu
  • Improved error handling for ScriptThread:Run
  • Fixed print
  • Fixed Vector:Distance
  • Fixed Entity:GetOffsetVector, Entity:SetVelocity (with Vector as parameter)

 


Version: 1.1.0 (Alpha)

  • Added (more than 80) Object-Oriented Wrappers for the natives (+ Documentation with lots examples)
  • Added GUI module to easily create menus
  • Added support for OUT-parameters
  • Addons can now be loaded/unloaded at any time
  • Script-Threads now run on one main thread (without blocking each other, using coroutines)
  • Huge documentation with new tutorials & examples

Check out the updated Tutorials! Getting Started

Version: 1.0.1 (Alpha)

  • Updated to work with 1.0.350.1/2
  • Removed leftover debug messages
  • Updated native call layouts for animations (thanks gcWorld!)
  • Note: With this update you'll have to overwrite dinput8!

Version 1.0.0 (Alpha)

  • Initial Version
  • Supported Game Versions: Steam/Retail 1.0.335.2

 



Installation
Download
Click here if you need further help! Or take a look at the Spoiler below.

Support + Getting Started as Developer

Wiki
The wiki contains Tutorials and a useful Getting Started page!

Examples
You can find several examples in GTALua/addons/

IRC
If you have any questions, you can ask here or join the GTANet IRC!
Host: irc.gtanet.com
Port: 6667
Just send me a message (Freaky) or join #gtalua or #gtamodding

Here / PM
If you have any questions, feel free to ask them here or via PM.

 

Edited by TJGM

Share this post


Link to post
Share on other sites
burnsyboo

Nice release bro im going to test this out now

Share this post


Link to post
Share on other sites
headscript

Image.png

 

GTALua - A Powerful Scripting Engine for GTA V in Lua

 

Current Features

  • All 5300 Natives accessible in Lua
  • Console that contains error messages and has support for own commands
  • Good Documentation to get you started with GTALua (Wiki & Tutorials & Examples)
  • Reload your scripts with a simple command in the console while ingame

Planned Features

  • Automatic Refresh (instead of current manual method)
  • Helper functions & classes for the natives
  • Adding even more examples
  • Drawing functions & library
  • Script Database (maybe)

Scripting Documentation

Make sure to check out the examples, you can find them in GTALua/addons/

We also have a wiki, you can find a tutorial and other things there! Check it out

 

Changelog

Current Version: 1.0.0 (Alpha)

  • Initial Version
  • Supported Game Versions: Steam/Retail 1.0.335.2

Installation

Download

Click here if you need further help! Or take a look at the Spoiler below.

 

Support + Getting Started as Developer

 

Wiki

The wiki contains Tutorials and a useful Getting Started page!

 

Examples

You can find several examples in GTALua/addons/

 

IRC

If you have any questions, you can ask here or join the GTANet IRC!

Host: irc.gtanet.com

Port: 6667

Just send me a message (Freaky) or join #gtamodding

 

Here / PM

If you have any questions, feel free to ask them here or via PM.

 

 

where is the benefit from yours compared to mine?

Share this post


Link to post
Share on other sites
Freakyy

where is the benefit from yours compared to mine?

 

I have proper documentation (wiki, tutorial, examples), a much easier addons-system, each script has its own script thread so people are free to do what they want, my code is well-structured, documented and optimized (that's why my files aren't nearly 3mb).

 

Also please do me a favour and remove the quote, it takes away loads of space.

Edited by Freakyy

Share this post


Link to post
Share on other sites
Drkz

Excellent. Though dumb question where can i find the model hash of peds and vehicles, things like that ?

 

Reading through the example scripts, you call the models by hash, just wondering where i can find the said hash to spawn whatever i want. Thanks.

Edited by Drkz

Share this post


Link to post
Share on other sites
Freakyy

Excellent. Though dumb question where can i find the model hash of peds and vehicles, things like that ?

 

Not a dumb question at all :)

 

They are everywhere around the internet.

I will add a list of them on the Wiki later.

Edited by Freakyy

Share this post


Link to post
Share on other sites
SgtDirtyMike

I commend your work on this release, but you must agree it is redundant. The other solution is much simpler to use, and whilst it's true that it may not provide as much functionality, yours is more cluttered and less organized. No one cares about a few megabytes...

Why not contact headscript first and suggest ideas instead of using his idea to make a more complicated release?

Share this post


Link to post
Share on other sites
Freakyy

I commend your work on this release, but you must agree it is redundant. The other solution is much simpler to use, and whilst it's true that it may not provide as much functionality, yours is more cluttered and less organized. No one cares about a few megabytes...

 

Why not contact headscript first and suggest ideas instead of using his idea to make a more complicated release?

 

More cluttered and less organized? I appreciate the feedback, i really do, but that's not true. What are you referring to?

I have a proper file structure with comments, an addon-system, in C++ I'm using classes and I also tried to port object-oriented-programming as good as possible over to Lua. The fact that you need to create your own script thread might be a complication, but it's 5-7 lines. It has the advantage that you are free to do what you want - you never conflict with other scripts, you don't block other scripts if you have an error, etc.

And the fact that it's smaller is not even an important fact, it's the optimization and performance.

By the way, if you want to be exact, the work on GTALua began before he released his - he was just the first to release :)

Edited by Freakyy

Share this post


Link to post
Share on other sites
headscript

 

And the fact that it's smaller is not even an important fact, it's the optimization and performance.

show me your performance against mine :)

im totally raw on the natives nothing blocking or changing everything is 100% direct

http://pastebin.com/6zkg8Had

Share this post


Link to post
Share on other sites
Freakyy

 

 

And the fact that it's smaller is not even an important fact, it's the optimization and performance.

show me your performance against mine :)

im totally raw on the natives nothing blocking or changing everything is 100% direct

http://pastebin.com/6zkg8Had

 

 

We have a totally different approach of calling natives.

In my code, the arguments are pushed and the native called completely in Lua, whereas you registered a function for every native.

Share this post


Link to post
Share on other sites
headscript

 

 

 

And the fact that it's smaller is not even an important fact, it's the optimization and performance.

show me your performance against mine :)

im totally raw on the natives nothing blocking or changing everything is 100% direct

http://pastebin.com/6zkg8Had

 

 

We have a totally different approach of calling natives.

In my code, the arguments are pushed and the native called completely in Lua, whereas you registered a function for every native.

 

which is faster? you cant tell me that calling 1 + n(each variable which u push to natives) functions from lua to c++ is faster than one lua to c+ +

Share this post


Link to post
Share on other sites
n00854180t

OP, I have a question for ya.

 

I'd like to call GET_PED_NEARBY_PEDS, which takes an array pointer as a parameter. I tried passing a table, but it complained about wanting a "number" (pointer, of course).

 

Do you know how I can call that function from Lua properly?

Share this post


Link to post
Share on other sites
Aleph-Zero

Nice. Looks like you put some effort, but i hope you plan on abstracting the natives 'cause if not i don't see the point. (might as well be using the C++ hook directly)

Share this post


Link to post
Share on other sites
Freakyy

which is faster? you cant tell me that calling 1 + n(each variable which u push to natives) functions from lua to c++ is faster than one lua to c+ +

It might not be faster than your approach, but it is definetly more clean. The reason I have that method in the first place is because of the natives/native_call_layout.ini file - people are able to change the parameters there, add undocumented natives. However, I'll do some benchmarking to find some actual numbers.

 

Edit: I just read through the last replies, people reported that they couldn't set the name plate correctly. In my case they would just have to edit the native_call_layou.ini, change the parameter type to string and then it would work. This is one of the main reasons why I chose this method. Maybe at a later point, when all natives have been analyzed, I will switch over.

 

 

OP, I have a question for ya.

 

I'd like to call GET_PED_NEARBY_PEDS, which takes an array pointer as a parameter. I tried passing a table, but it complained about wanting a "number" (pointer, of course).

 

Do you know how I can call that function from Lua properly?

It's not possible, I'll add this ASAP.

 

 

Nice. Looks like you put some effort, but i hope you plan on abstracting the natives 'cause if not i don't see the point. (might as well be using the C++ hook directly)

Thank you. You're absolutely right. It's exactly what I'm planning.

Although one advantage over the C version is that you don't have to restart your game :):D

Edited by Freakyy

Share this post


Link to post
Share on other sites
V7X3

More isn't always better, buuuuuuuut, people who wanna go "balls-deep" in messing about w/ Lua should definitely check this out. Otherwise, the version headscript released suffices just fine. Nonetheless, nice release OP, looks like a fair amount of effort was put forth into this, so... kudos there. :lol:

Edited by V7X3

Share this post


Link to post
Share on other sites
Freakyy

More isn't always better, buuuuuuuut, people who wanna go "balls-deep" in messing about w/ Lua should definitely check this out. Otherwise, the version headscript released suffices just fine. Nonetheless, nice release OP, looks like a fair amount of effort was put forth into this, so... kudos there. :lol:

Thanks for the feedback!

But more means more possibilities ;)

Share this post


Link to post
Share on other sites
n00854180t

@Freakyy, dang, thought as much. I'm excited to see the next version with these types of functions working.

Share this post


Link to post
Share on other sites
Freakyy

The next version will include the following changes:

  • KEY_ constants (like KEY_F9 for example)
  • Support for OUT-values (like arrays)
  • Minor bug fixes and code cleanup

The most exciting new feature will be the wrappers, here is a quick example: (do not try to use this on the current version)

streaming.RequestAndWaitForModel("cs_priest")
local bodyguard = game.CreatePed("cs_priest", LocalPlayer():GetPosition())
bodyguard:AllowWeaponSwitching()
bodyguard:DelayedGiveWeapon("WEAPON_PISTOL")


Any suggestions or wishes for the next update?

Share this post


Link to post
Share on other sites
n00854180t

Awesome updates there!

 

One other request I have is support for controller key constants and/or a wrapper for doing controller key presses. I know there's functionality for detecting gamepad presses in the natives, but the button codes aren't obvious.

Edited by n00854180t

Share this post


Link to post
Share on other sites
Freakyy

Awesome updates there!

 

One other request I have is support for controller key constants and/or a wrapper for doing controller key presses. I know there's functionality for detecting gamepad presses in the natives, but the button codes aren't obvious.

Added to my To-Do List!

Thanks for the suggestion.

Share this post


Link to post
Share on other sites
alexslx

 

Awesome updates there!

 

One other request I have is support for controller key constants and/or a wrapper for doing controller key presses. I know there's functionality for detecting gamepad presses in the natives, but the button codes aren't obvious.

Added to my To-Do List!

Thanks for the suggestion.

 

 

My suggestion is to keep the names of warped methods similar to .NET or C++ framework as much as possible and with a readable form.

 

Regards,

Edited by alexslx

Share this post


Link to post
Share on other sites
Loset

can you guys give me a good example?

example_addon = ScriptThread("example_addon_script_thread")example_addon:Register()function example_addon:Run()while self:IsRunning() do-- Set time-- 08:00:00natives.TIME.SET_CLOCK_TIME(8, 0, 0)-- Waitself:Wait(50)endend

this is what I understand from the example in the tutorial but I am not sure its 100% accurate?

Share this post


Link to post
Share on other sites
Ivey
ivy_bodyguard = ScriptThread("ivy_bodyguard") function ivy_bodyguard:Run()    print("test")	while self:IsRunning() do		if IsKeyDown(0x78) then            print("test2")        end		self:Wait(50)	endendfunction ivy_bodyguard:OnError()	print("Oh no! Example Thread caused an error!")	self:Reset()end ivy_bodyguard:Register()

Literally cannot get this to register the second "test2" in the console. I don't know if key presses are broken... it just does not work for me. Maybe you have some information on the subject.

Share this post


Link to post
Share on other sites
Pixelazed
ivy_bodyguard = ScriptThread("ivy_bodyguard") function ivy_bodyguard:Run()    print("test")	while self:IsRunning() do		if IsKeyDown(0x78) then            print("test2")        end		self:Wait(50)	endendfunction ivy_bodyguard:OnError()	print("Oh no! Example Thread caused an error!")	self:Reset()end ivy_bodyguard:Register()

Literally cannot get this to register the second "test2" in the console. I don't know if key presses are broken... it just does not work for me. Maybe you have some information on the subject.

 

I cannot get it register any keypresses either.

Share this post


Link to post
Share on other sites
alexslx

I've sent you a commit with my vehicle const list, just to save you a bit of work.

 

Also, as a suggestion, I think you should follow a standard documentation format such as javadoc (even it is made to use with java, I worked with a huge amount of project using it for other languages). In addition, don't let to document after (You'll never do it), and commenting the code will make easier to run a doc gen tool and generate a pretty api or docs page.

 

Regards,

Share this post


Link to post
Share on other sites
Cylonsurfer

So I'm trying to create a script to move various parts of the HUD so they are usable in VR. I assume I need to use SET_HUD_COMPONENT_POSITION but all I get returned in the console window is:

 

SET_HUD_COMPONENT_POSITION(a nil value)

 

Could someone give me an example of where I'm going wrong? I want to start by moving the radar for example. This is what I tried - and it's clearly wrong.

 

example_addon = ScriptThread("example_addon_script_thread")

function example_addon:Run()

while self:IsRunning() do

SET_HUD_COMPONENT_POSITION(RADAR, 1.0, 1.0)

end

end

example_addon:Register()

Share this post


Link to post
Share on other sites
Freakyy

can you guys give me a good example?

example_addon = ScriptThread("example_addon_script_thread")example_addon:Register()function example_addon:Run()while self:IsRunning() do-- Set time-- 08:00:00natives.TIME.SET_CLOCK_TIME(8, 0, 0)-- Waitself:Wait(50)endend

this is what I understand from the example in the tutorial but I am not sure its 100% accurate?

 

You forgot to register the thread.

Put example_addon:Register() at the end of the file.

 

 

ivy_bodyguard = ScriptThread("ivy_bodyguard") function ivy_bodyguard:Run()    print("test")	while self:IsRunning() do		if IsKeyDown(0x78) then            print("test2")        end		self:Wait(50)	endendfunction ivy_bodyguard:OnError()	print("Oh no! Example Thread caused an error!")	self:Reset()end ivy_bodyguard:Register()

Literally cannot get this to register the second "test2" in the console. I don't know if key presses are broken... it just does not work for me. Maybe you have some information on the subject.

 

I cannot get it register any keypresses either.

 

 

Okay, I will look into this.

Could you post your code too? Or join IRC / send me a PM?

 

I've sent you a commit with my vehicle const list, just to save you a bit of work.

 

Also, as a suggestion, I think you should follow a standard documentation format such as javadoc (even it is made to use with java, I worked with a huge amount of project using it for other languages). In addition, don't let to document after (You'll never do it), and commenting the code will make easier to run a doc gen tool and generate a pretty api or docs page.

 

Regards,

 

I already wrote it in the comment on Github, but thanks a lot men!

I really appreciate the help, I will merge the commit later today.

(I'm also glad you followed my "style" like with the KEY_ consts)

 

That's a good idea, you know any specific ones for Lua?

 

So I'm trying to create a script to move various parts of the HUD so they are usable in VR. I assume I need to use SET_HUD_COMPONENT_POSITION but all I get returned in the console window is:

 

SET_HUD_COMPONENT_POSITION(a nil value)

 

Could someone give me an example of where I'm going wrong? I want to start by moving the radar for example. This is what I tried - and it's clearly wrong.

 

example_addon = ScriptThread("example_addon_script_thread")

 

function example_addon:Run()

 

while self:IsRunning() do

 

SET_HUD_COMPONENT_POSITION(RADAR, 1.0, 1.0)

 

end

 

end

 

example_addon:Register()

 

I responded to your PM with the solution :)

Share this post


Link to post
Share on other sites
Freakyy

@alexslx

Thanks, but do I need a C++ documentation ?
I'm not planning to add binary plugins any time soon.

Share this post


Link to post
Share on other sites
SirGoodSmoke

Great work with this. Have an issue tho not sure if its me, I can't seem to execute scripts that are loaded after the first script. Example: Using bothing your example scripts, If both of them load I can only execute the one that loaded first. Hope this makes sense

 

In the console it will show that both scripts have registered but only the first registered script will allow me to execute it

Edited by SirGoodSmoke

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.