Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Experience in squirrel, I want to learn Lua

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
TurboGrafx
Newbie cheater
Reputation: 0

Joined: 27 May 2015
Posts: 15

PostPosted: Mon Feb 29, 2016 9:53 pm    Post subject: Experience in squirrel, I want to learn Lua Reply with quote

Okay well i want to expand my mind in scripting. I am a server owner for the GTA III MP mod liberty-unleashed.co.uk,

The Main question is/ what do i need to know maybe Squirrel compared to Lua ? If needed i will play single player GTA III to get an understanding. I dont hack in MP games. This is not what it is intended for [To hack].

With learning lua i know it should help me expand to bigger projects.
Any info would be helpful or pointing out any Lua releases anyone had for Gta III
Only reason why Gta III is that is where all my main work has been and i want to keep it that way. i find scripting to be A-LOT!!! of freaking fun
Back to top
View user's profile Send private message Send e-mail
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4718

PostPosted: Mon Feb 29, 2016 10:48 pm    Post subject: Reply with quote

Any time I need to learn a new language I just google it and find something like this. You don't need something that holds your hand through every little concept since you should already know most of the basic concepts shared between programming languages (e.g. variables, if statements, loops, classes & objects), nor do you need something that goes incredibly in-depth into how a language works. If you're not sure you'll be using it that much, then going too far in-depth will just be a waste of time since you'll probably forget most of the information. If you know you will, then also look at an official source to get a more accurate and in-depth perspective of how the language works. Of course, there's usually a few really technical things left out that you may want to know, but googling anything you don't know will usually lead you to the answer. If that doesn't, then try asking, or figure it out yourself through testing.

Regardless, after you get a basic overview of a language, start by making a few small things in it and work your way up from there. The more you code, the more you'll remember; the more complex your goals become, the more you'll learn when writing code. It's a very repetitious process, but if you can spread it out with other things going on in your life, then it's not that bad and seems to go by pretty quickly.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
TurboGrafx
Newbie cheater
Reputation: 0

Joined: 27 May 2015
Posts: 15

PostPosted: Mon Feb 29, 2016 11:20 pm    Post subject: Reply with quote

Thank you for your reply. I will attempt to look further into what you insisted, I just wish i could find a good starter pack or something..

_____________________
Lol next project will be Modules/ Sqlite
Back to top
View user's profile Send private message Send e-mail
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Mar 01, 2016 1:57 pm    Post subject: Reply with quote

The sticky thread I posted here is a decent starting point to begin learning Lua:
http://forum.cheatengine.org/viewtopic.php?t=538130

That said, there are syntax differences between the two languages.

Squirrel follows a more C/C++ style syntax while Lua does not. This can land up causing you some problems if you forget things between the two languages from time to time. Squirrel has classes and instances built-in. Lua does not. Instead, you have to use metatables and some trickery to create a similar experience in Lua.

Some key notes with Lua if you plan to get into using it for more in-depth scripting:
- Lua table index starts at 1, not 0.
- Lua tables use index 0 for the item counter. (ie. accessing the count of items via #tablename)
- Lua tables item count will be invalid if you skip indexes.
- Lua metatables are extremely important if you plan to use class-based coding / instancing.

Some syntax notes on Lua if you are not familiar with it:
- Lua does not use braces to define scopes. (ie. { })
- Lua does not require line-endings such as ;
- Lua uses -- to denote a single line comment, and --[[ ]] to denote a multi-line / block comment.
- Lua does not use operators such as !, instead it uses the word 'not'.
- Lua allows for function definitions similar to JavaScript, you can write things like:
Code:

function derp()
    print('derp!');
end

derp = function()
    print('derp!');
end


Lua also does not have a mix of tables/arrays like Squirrel. Instead, it only has tables that can be used like both.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
TurboGrafx
Newbie cheater
Reputation: 0

Joined: 27 May 2015
Posts: 15

PostPosted: Tue Mar 01, 2016 2:59 pm    Post subject: Reply with quote

Thank you for your reply i do have a few questions that may help me get started, LOL is there an official lua board for cheat engine(does cheat engine have its own built in functions?

If so is there a wiki? If not. lel..
**Kicks dirt** I will post an example of what i am use to in squirel, this function is created by a built in function by the MP owner (CMD) just type
/v 119 in a gui window and you will spawn the car ID hear is how i script in squirrel

Code:
    else if ( ( cmd == "spawncar" ) || ( cmd == "spawn" ) || ( cmd == "c" ) || ( cmd == "vehicle" ) || ( cmd == "veh" ) || ( cmd == "v" ) )
    {      
      local car = Car.Get( player.Name + "Car" );
      if ( car ) MessagePlayer( "*You Must Wait", player );
      else if ( !car )
      {
          if ( player.Vehicle )return false;
          {
           if ( text )
           {
              local pTemp = split( text, " " ), ID = 90;
              if ( IsNum( pTemp[ 0 ] ) ) ID = pTemp[ 0 ].tointeger();
              if ( ( ID >= 90 ) && ( ID <= 150 ) )
              {
                local vehicle = CreateVehicle( ID, Vector(player.Pos.x, player.Pos.y + 1, player.Pos.z), player.Angle);
                if ( vehicle ) player.Vehicle = vehicle;
                vehicle.OneTime = true;
                MessagePlayer( "[#ff0000]* Vehicle spawned: " + vehicle.Model, player );
               Car.Add( player.Name + "Car", 1 );
              }
              else MessagePlayer( "Forbiden Vehicle ID", player, Colour ( 255, 255, 255 ) );
           }
           else MessagePlayer( "Forbiden Vehicle ID, Please Try Again", player, Colour ( 255, 255, 255 ) );
        }
         NewTimer( "NewVeh", 10000, 1);
       function NewVeh()
       {
            Car.Del( player.Name + "Car" );
            MessagePlayer( "*You may now create a new Vehicle", player, Colour ( 131, 114, 5 ) );
         PlayFrontEndSound(player, 160);
         }
       }
    }


Some of these functions where built in like PlayFrontEndSound(player, 160); the rest i had to figure out and build.

I will continue to do more research on lua and i really want to know is there any built in functions. i am sure you could understand from what you see with functions and what i am asking...

[BTW awesome Freaking code pasting, the website i am on would jump the code all around as it is way to long]
Back to top
View user's profile Send private message Send e-mail
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4718

PostPosted: Tue Mar 01, 2016 3:21 pm    Post subject: Reply with quote

The file "main.lua" located in the main CE directory has documentation on most non-deprecated CE-related Lua functions and classes. There is also a wiki which has less documentation available (use google to find it).
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
TurboGrafx
Newbie cheater
Reputation: 0

Joined: 27 May 2015
Posts: 15

PostPosted: Tue Mar 01, 2016 3:25 pm    Post subject: Reply with quote

Thanks awesome So appreciated **Smacks face... I was just looking at that last night xD!!!

_______________
EDITED DUE TO DOUBLE POSTING.. i dont want to be that guy..

Last question can i go way and beyond other than just hacking. i want to know where to start first. what is the simplest things you would consider. i do not want to go heavy and give up. I have been playing with simple functions now i am attempting just a little bigger
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites