Popular Post BH Team Posted July 2, 2017 Popular Post Share Posted July 2, 2017 (edited) v.026.5-beta WHAT IS MOONLOADER MoonLoader is a modification for GTA: San Andreas that brings new ability to use Lua scripts made by mods creators. With Lua scripts you can change some game aspects, expand gameplay and add new features. MoonLoader provides to developers extensive functionality for modding, it includes all familiar capabilities that CLEO has, and also combines many new features that were not previously available together in any GTA: SA modding framework. It is still a young modification and hasn't yet spread widely, but there are some scripts already made, and it aims to become the complete modern CLEO replacement! FEATURES Lua Programming Language — the heart of MoonLoader. Lua is one of the most popular scripting languages, it has huge community, Lua is very widely used in game development, it's very simple but also very flexible programming language. Very easy to learn — despite it is a simple language there are a lot of tutorials, guides, books, courses and answered questions Great community — lots and lots ready-made solutions, almost every programming universal objective is solved Simple and powerful No programming limits (compared to SCM) No compilation needed Safety and error handling Built-in debugging tools Good and straightforward API And much more... MoonLoader uses LuaJIT — a just-in-time compiler for Lua and the fastest scripting engine FFI — FFI is an embedded library in LuaJIT, it provides direct interface between Lua and process memory and gives ability to directly call functions in memory, access data structures, pass Lua-functions to memory and even write on Assembly with DynASM from pure Lua. And, as everyone knows, all this is an integral part of gamemodding Script Management — script management system allows to obtain information about scripts and manipulate scripts execution Compilation is not Necessary — scripts can be compiled but it's not required, and if the script is open source every user can edit it without any preparation Error Handling — MoonLoader handles as many errors as it can. If CLEO-script dies because of an error then the whole game dies, but if Lua-script dies due to an error, it just prints the error to the log and stops script execution No Dependencies — the only two things are required is installed ASI Loader and version 1.0US of GTA: San Andreas Compatible With SA-MP — MoonLoader is meant to be compatible with both sigleplayer game and SA-MP Events — track such events like starting new game, window messages, quitting game, stopping script, etc. Atom as an Official IDE — Atom is great code editor, it's modern and completely customizable. MoonLoader has its own package for Atom to provide smart autocompletion, function search and error highlighting. Notepad++ also has an official MoonLoader support. If you don't like Atom for some reason, you can choose any text editor, even the standard Notepad. There are really no requirements for any special tools Early Stage Loading — Lua scripts loads just after game starts but there are two stages of loading: the "initialization stage" right after game launch and the "active stage" when game loaded Separate Save Game System — event-based game saving system allows to control when player starts a new game, loads a game or saves it Inter-Script Communication — scripts can exchange data and interact with each other through the export-import feature (it's not the standard function 'require') Synchronous Scripting Threads — scripting threads makes synchronous multitasking a lot easier Standard Libraries — distro includes some standard libraries with the common development tools And of course a bunch of new functions NOTES AND PLANSAfter almost a year of open alpha-testing MoonLoader finally got a beta-testing status. The stability of its work has been verified by time and by many users, but there are some things that you need to be informed about.Originally was planned that MoonLoader will support all versions of GTA: SA but with increasing functionality it's began to become a more difficult task and in the end it was decided that only v1.0US will be supported, maybe in the future it will change, but not now and there is no promises. Anyway it's not a big problem — most of mods supports only v1.0US as well and this version is most common for modding.MoonLoader has lack of documentation in English, official wiki is ok but currently it's all in Russian (but has the embedded Google Translate). Another thing is that many of conventional scripting opcodes are not described on our wiki (but you can find descriptions over the Internet, eg on GTAGModding).DXUT and SA-MP functions requires SAMPFUNCS installed, because they are opcodes from SAMPFUNCS. If you don't use these functions, SAMPFUNCS is not required.Since MoonLoader emulates SCM opcodes to provide all familiar game scripting functions, it makes small speed overhead for these functions compared to SCM — it is the cost for the all standard scripting functionality, but in most cases Lua is faster than SCM. The most common opcodes are gradually replaced with built-in functions in newer versions.Lua has no native support of thread saving into the file and MoonLoader doesn't support this as well. But it's not that bad, there is event-based game saving system that provides full control over saving and loading game.At this moment MoonLoader already has all necessary concepts and new functionality (like more game functions) can be easily implemented via dll and lua modules. The current plans is to add good rendering API and fix some of issues listed above. If you are interested in Lua script development check the getting started guide.DEVELOPERS FYP, hnnssy, EvgeN 1137SPECIAL THANKS DK22Pac, MISTER_GONWIK, 4el0ve4ik, EXPORT, Garrus, CLEO 4DOWNLOADDownload Installer Installation: run setup-moonloader.exe and follow steps of the installation masterDownload Archive (for manual installation. Doesn't include extension for Notepad++) Installation: extract all files from downloaded archive to the GTA: San Andreas root folder (make sure you have ASI Loader installed)Download Script Examples (may be obsolete)SCRIPT INSTALLATIONFollow the script installation instructions or just copy all content related to the script into the 'moonloader' folder located in the game's root directory.LINKSDevelopment ThreadWiki (Translated via Google Translate from Russian): main page; all pages related to MoonLoaderLua Mods on BlastHack (some of them are available in archive with examples, but the threads in the forum have descriptions)Official Russian ThreadOfficial Russian Development Thread Edited May 7, 2018 by BH Team Agem, Jago, AliceTG and 61 others 63 1 Link to comment Share on other sites More sharing options...
exp0rt Posted July 2, 2017 Share Posted July 2, 2017 great job, guy Link to comment Share on other sites More sharing options...
BH Team Posted July 2, 2017 Author Share Posted July 2, 2017 Here is the development thread: http://gtaforums.com/topic/890990-moonloader-development/ Ruvix 1 Link to comment Share on other sites More sharing options...
Guest Posted July 2, 2017 Share Posted July 2, 2017 Finally, this is explained in English. Good work. Link to comment Share on other sites More sharing options...
Blue Posted July 2, 2017 Share Posted July 2, 2017 Fantastic! Link to comment Share on other sites More sharing options...
inadequate Posted July 2, 2017 Share Posted July 2, 2017 (edited) If this is a CLEO replacement (as the description states it)... How can someone to port his CLEO script to MOON without to re-write all from scratch again? And even worse if the original script is very, very long. Or are they compatible between platforms? Edited July 2, 2017 by Inadequate Link to comment Share on other sites More sharing options...
BH Team Posted July 2, 2017 Author Share Posted July 2, 2017 (edited) If this is a CLEO replacement (as the description states it)... How can someone to port his CLEO script to MOON without to re-write all from scratch again? And even worse if the original script is very, very long. Or are they compatible between platforms? Nope, they aren't. MoonLoader is intended to be CLEO replacement for new mods. Theoretically, scripts can be converted almost complete automatically, but making converter isn't worth it, it's better to rewrite script manually because then the script may be performed much better with all of those MoonLoader features. It's more a replacement for developers, than for users. Edited July 2, 2017 by BH Team Link to comment Share on other sites More sharing options...
goodidea82 Posted July 2, 2017 Share Posted July 2, 2017 Amazing project! Problem: documentation is not in english http://blast.hk/wiki/moonloader:functions#googtrans(en) Some questions: - Is the number of local variables unlimited? - Are the commands executed by the SCM interpreter, or is the execution completely separated from the SCM interpreter? - Are the datastructures from plugin-sdk included? (or do you plan to do it?) - Is compatibility with FLA confirmed? BH Team 1 Link to comment Share on other sites More sharing options...
BH Team Posted July 2, 2017 Author Share Posted July 2, 2017 (edited) Amazing project! Problem: documentation is not in english http://blast.hk/wiki/moonloader:functions#googtrans(en) Some questions: - Is the number of local variables unlimited? - Are the commands executed by the SCM interpreter, or is the execution completely separated from the SCM interpreter? - Are the datastructures from plugin-sdk included? (or do you plan to do it?) - Is compatibility with FLA confirmed? 1. Yes. Limited only by the RAM, as far as i know. 2. Functions that are opcodes (those who has 'opcode' value in the function list) - yes, but it's not completely executed by the SCM interpreter, it's more like direct opcode handler function calling with some emulation. 3. They aren't. Currently there is no plans in implementing it. It can be easily done via FFI, see the RapidFire.lua from examples. 4. What is "FLA"? Edited July 2, 2017 by BH Team Link to comment Share on other sites More sharing options...
Colbertson Posted July 2, 2017 Share Posted July 2, 2017 (edited) - Is compatibility with FLA confirmed? Ive been running a bunch of Moonloader scripts and many other mods including FLA and havent had any issues. Compatability seems good with everything Edited July 2, 2017 by Mubber BH Team 1 Link to comment Share on other sites More sharing options...
goodidea82 Posted July 2, 2017 Share Posted July 2, 2017 (edited) Amazing project! Problem: documentation is not in english http://blast.hk/wiki/moonloader:functions#googtrans(en) Some questions: - Is the number of local variables unlimited? - Are the commands executed by the SCM interpreter, or is the execution completely separated from the SCM interpreter? - Are the datastructures from plugin-sdk included? (or do you plan to do it?) - Is compatibility with FLA confirmed? 1. Yes. Limited only by the RAM, as far as i know. 2. Functions that are opcodes (those who has 'opcode' value in the function list) - yes, but it's not completely executed by the SCM interpreter, it's more like direct opcode handler function calling with some emulation. 3. They aren't. Currently there is no plans in implementing it. It can be easily done via FFI, see the RapidFire.lua from examples. 4. What is "FLA"? FLA = fastman92limitAdjuster I have looked up the FFI example in RapidFire.lua. Here for the others: script_name('RapidFire')script_author('FYP')script_description('Get the latest MoonLoader updates from http://blast.hk/moonloader/')local ffi = require 'ffi'--- ConfigcheatToggle = 'RAPID'amplification = {-- weapon speed multiplier (greater value = faster) [22] = 3, -- pistol -- [23] = 4, -- silenced pistol [24] = 2.5, -- desert eagle [25] = 1.5, -- shotgun [26] = 10, -- sawn-off shotgun [27] = 10, -- combat shotgun [28] = 2, -- micro uzi [29] = 5, -- mp5 [30] = 3.5, -- ak47 [31] = 3, -- m4 [32] = 2, -- tec9 [33] = 10, -- rifle [34] = 10, -- sniper rifle}--- Mainfunction main() gameGetWeaponInfo = ffi.cast('struct CWeaponInfo* (__cdecl*)(int, int)', 0x743C60) while true do wait(0) if isPlayerPlaying(playerHandle) and isCharOnFoot(playerPed) then if testCheat(cheatToggle) then activated = not activated printStringNow('RapidFire ' .. (activated and '~g~activated' or '~r~deactivated') .. '.~n~~y~Made by FYP~n~~w~blast.hk', 2000) if activated then weaponOrigData = {} for skill = 1, 3 do weaponOrigData[skill] = {} for id, value in pairs(amplification) do local weap = gameGetWeaponInfo(id, skill - 1) weaponOrigData[skill][id] = {accuracy = weap.m_fAccuracy, animLoopStart = weap.m_fAnimLoopStart, animLoopFire = weap.m_fAnimLoopFire, animLoopEnd = weap.m_fAnimLoopEnd, animLoopStart2 = weap.m_fAnimLoop2Start, animLoopFire2 = weap.m_fAnimLoop2Fire, animLoopEnd2 = weap.m_fAnimLoop2End} -- magic local mul = 1 / value if id ~= 25 and id ~= 26 and id ~= 27 then weap.m_fAccuracy = weap.m_fAccuracy / (mul * 1.4) end weap.m_fAnimLoopStart = weap.m_fAnimLoopFire - (weap.m_fAnimLoopFire - weap.m_fAnimLoopStart) * mul weap.m_fAnimLoop2Start = weap.m_fAnimLoop2Fire - (weap.m_fAnimLoop2Fire - weap.m_fAnimLoop2Start) * mul weap.m_fAnimLoopEnd = weap.m_fAnimLoopFire + (weap.m_fAnimLoopEnd - weap.m_fAnimLoopFire) * mul weap.m_fAnimLoop2End = weap.m_fAnimLoop2Fire + (weap.m_fAnimLoop2End - weap.m_fAnimLoop2Fire) * mul end end else restoreOriginalWeaponData() weaponOrigData = nil end end end endend--- Eventsfunction onExitScript() restoreOriginalWeaponData()end--- Functionsfunction restoreOriginalWeaponData() if weaponOrigData ~= nil then for skill, weaponsOrig in pairs(weaponOrigData) do for id, orig in pairs(weaponsOrig) do local weap = gameGetWeaponInfo(id, skill - 1) weap.m_fAccuracy = orig.accuracy weap.m_fAnimLoopStart = orig.animLoopStart weap.m_fAnimLoopFire = orig.animLoopFire weap.m_fAnimLoopEnd = orig.animLoopEnd weap.m_fAnimLoop2Start = orig.animLoopStart2 weap.m_fAnimLoop2Fire = orig.animLoopFire2 weap.m_fAnimLoop2End = orig.animLoopEnd2 end end endend--- FFIffi.cdef([[struct CVector { float x, y, z; };// from plugin-sdk: https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CWeaponInfo.hstruct CWeaponInfo{ int m_iWeaponFire; // 0 float m_fTargetRange; // 4 float m_fWeaponRange; // 8 __int32 m_dwModelId1; // 12 __int32 m_dwModelId2; // 16 unsigned __int32 m_dwSlot; // 20 union { int m_iWeaponFlags; // 24 struct { unsigned __int32 m_bCanAim : 1; unsigned __int32 m_bAimWithArm : 1; unsigned __int32 m_b1stPerson : 1; unsigned __int32 m_bOnlyFreeAim : 1; unsigned __int32 m_bMoveAim : 1; unsigned __int32 m_bMoveFire : 1; unsigned __int32 _weaponFlag6 : 1; unsigned __int32 _weaponFlag7 : 1; unsigned __int32 m_bThrow : 1; unsigned __int32 m_bHeavy : 1; unsigned __int32 m_bContinuosFire : 1; unsigned __int32 m_bTwinPistol : 1; unsigned __int32 m_bReload : 1; unsigned __int32 m_bCrouchFire : 1; unsigned __int32 m_bReload2Start : 1; unsigned __int32 m_bLongReload : 1; unsigned __int32 m_bSlowdown : 1; unsigned __int32 m_bRandSpeed : 1; unsigned __int32 m_bExpands : 1; }; }; unsigned __int32 m_dwAnimGroup; // 28 unsigned __int16 m_wAmmoClip; // 32 unsigned __int16 m_wDamage; // 34 struct CVector m_vFireOffset; // 36 unsigned __int32 m_dwSkillLevel; // 48 unsigned __int32 m_dwReqStatLevel; // 52 float m_fAccuracy; // 56 float m_fMoveSpeed; float m_fAnimLoopStart; float m_fAnimLoopEnd; float m_fAnimLoopFire; float m_fAnimLoop2Start; float m_fAnimLoop2End; float m_fAnimLoop2Fire; float m_fBreakoutTime; float m_fSpeed; float m_fRadius; float m_fLifespan; float m_fSpread; unsigned __int16 m_wAimOffsetIndex; unsigned __int8 m_nBaseCombo; unsigned __int8 m_nNumCombos;} __attribute__ ((aligned (4)));]]) This looks really good I must admit and should be included in the standard in my opinion. >..but it's not completely executed by the SCM interpreter, it's more like direct opcode handler function calling with some emulation So how is the speed compared to native SCM execution? Edited July 2, 2017 by goodidea82 Crspy 1 Link to comment Share on other sites More sharing options...
Davve95 Posted July 2, 2017 Share Posted July 2, 2017 (edited) Sounds awesome! Great job! And your English was not bad either. Edited July 2, 2017 by Davve95 Link to comment Share on other sites More sharing options...
fastman92 Posted July 2, 2017 Share Posted July 2, 2017 (edited) Nice project. I had the same idea, but stopped development of such a project. You must check if your project is compatible with new ID limits. They are the main problem in other ASI plugins. Edited July 2, 2017 by fastman92 Link to comment Share on other sites More sharing options...
Crspy Posted July 2, 2017 Share Posted July 2, 2017 Finally you decided to post it here. Great job , your English is good. I've been following your work since v.021 beta. I am definitely gonna learn this as it seems to have a great future. Link to comment Share on other sites More sharing options...
deltaCJ Posted July 3, 2017 Share Posted July 3, 2017 This looks like a good CLEO replacement and has a bright future, but is it good for Mission Scripting? Link to comment Share on other sites More sharing options...
BH Team Posted July 3, 2017 Author Share Posted July 3, 2017 (edited) FLA = fastman92limitAdjusterOh... Can't say, I didn't test it. It should be good, MoonLoader has little amount of hooks and patches to provide better compatibility with other mods. So how is the speed compared to native SCM execution?Opcode-functions has overhead, it's inevitable, but it's like ~25-45% to the original, so it's ok, doesn't give a huge overload. I should do the benchmarks with comparisons. I had the same idea, but stopped development of such a project.Yea, heard about that somewhere, but after I started working on MoonLoader. You must check if your project is compatible with new ID limits. They are the main problem in other ASI plugins.Can you give me a tip how should I do this? This looks like a good CLEO replacement and has a bright future, but is it good for Mission Scripting?Pretty much. There is all the original game scripting features and game saving/loading system, so yes, why not... And your English was not bad either.So I can remove this ugly disclaimer? Edited July 3, 2017 by BH Team RyanDri3957V, Crspy and deltaCJ 3 Link to comment Share on other sites More sharing options...
Davve95 Posted July 3, 2017 Share Posted July 3, 2017 (edited) Yeah, in my opinion it does not seem to be needed. But I'm not a expert either xD. Edited July 3, 2017 by Davve95 damiann69 1 Link to comment Share on other sites More sharing options...
Zolika1351 Posted July 3, 2017 Share Posted July 3, 2017 Thank you for this, I always found CLEO scripting harder than lua so this will help me a lot. Crspy 1 Link to comment Share on other sites More sharing options...
Davve95 Posted July 3, 2017 Share Posted July 3, 2017 Yeah, me too. I hope this is way easier then CLEO scripting. If so I'd would get started someday. Link to comment Share on other sites More sharing options...
SilverRST Posted July 3, 2017 Share Posted July 3, 2017 So this can give the possibility to developers creating graphics scripts which are mostly only available for MTA or SAMP? Link to comment Share on other sites More sharing options...
Crspy Posted July 3, 2017 Share Posted July 3, 2017 (edited) For people who don't know , here's some cool stuff made with lua scripting for MoonLoader : [Lua] 2DFX - creating light sources [Lua] Creating 2DFX light coronas[Lua]Convert world coordinates to screen [Lua]After Wasted and Busted like GTA V ( so cool ) [Lua]Fly Camera[Lua]Open all interiors ( author claims it's better than EHI )[Lua]Slowing down time Edited July 3, 2017 by Crspy RyanDri3957V, Blackbird88, Davve95 and 1 other 4 Link to comment Share on other sites More sharing options...
deltaCJ Posted July 3, 2017 Share Posted July 3, 2017 These russians man. they're like super humans lol CyberRock, cardboardbox1230, Apu889 and 3 others 6 Link to comment Share on other sites More sharing options...
deltaCJ Posted July 3, 2017 Share Posted July 3, 2017 (edited) Hm, sad but none of the scripts are working for me? I put it in the moonloader folder but it doesn't work ingame... EDIT: f*ck double post sorry.... EDIT2: Also when I started new game it game me runtime error... I had to uninstall Edited July 3, 2017 by deltaCJ Link to comment Share on other sites More sharing options...
Crspy Posted July 3, 2017 Share Posted July 3, 2017 Hm, sad but none of the scripts are working for me? I put it in the moonloader folder but it doesn't work ingame... EDIT: f*ck double post sorry.... You sure ? they work fine for me. Link to comment Share on other sites More sharing options...
deltaCJ Posted July 3, 2017 Share Posted July 3, 2017 (edited) You sure ? they work fine for me. Yeah, its weird. I tried the rapid fire and the sprint aim one but none work Edited July 3, 2017 by deltaCJ Link to comment Share on other sites More sharing options...
BH Team Posted July 4, 2017 Author Share Posted July 4, 2017 Hm, sad but none of the scripts are working for me? I put it in the moonloader folder but it doesn't work ingame... EDIT: f*ck double post sorry.... EDIT2: Also when I started new game it game me runtime error... I had to uninstall Make sure your GTA: SA version is 1.0US and that you have installed MoonLoader properly. I doubt that the problem can be in the ASI loader, but anyway try Silent's ASI Loader.If all this is true then the problem is in conflicting mods. Link to comment Share on other sites More sharing options...
deltaCJ Posted July 4, 2017 Share Posted July 4, 2017 Hm, sad but none of the scripts are working for me? I put it in the moonloader folder but it doesn't work ingame... EDIT: f*ck double post sorry.... EDIT2: Also when I started new game it game me runtime error... I had to uninstall Make sure your GTA: SA version is 1.0US and that you have installed MoonLoader properly. I doubt that the problem can be in the ASI loader, but anyway try Silent's ASI Loader.If all this is true then the problem is in conflicting mods. Of course I have GTA SA US 1.0 and I used the installer, I even checked ASI loader and Notepad ++ extension. Link to comment Share on other sites More sharing options...
Arian643 Posted July 4, 2017 Share Posted July 4, 2017 It's great to see it here on GTAForums.It will be awesome if you can add some features like enabling and disabling lua scripts from the game menu (just like the modloader).Good luck with your upcoming projects Davve95 1 Link to comment Share on other sites More sharing options...
imlove13 Posted July 4, 2017 Share Posted July 4, 2017 Is it possible to Create Shader with LUA script ? @[email protected] Just Like MTA ... I heard MTA using LUA script Too.. xD Goodluck with your Project Btw <3 and Love to see Development .. ) Davve95 1 Link to comment Share on other sites More sharing options...
BH Team Posted July 5, 2017 Author Share Posted July 5, 2017 (edited) Of course I have GTA SA US 1.0 and I used the installer, I even checked ASI loader and Notepad ++ extension.Then most likely the problem in the mods conflict. Can you attach your moonloader.log? It's great to see it here on GTAForums.It will be awesome if you can add some features like enabling and disabling lua scripts from the game menu (just like the modloader).Good luck with your upcoming projects It would be nice, it's even can be done via lua script. Is it possible to Create Shader with LUA script ? @[email protected] Just Like MTA ... I heard MTA using LUA script Too.. xD Goodluck with your Project Btw <3 and Love to see Development .. ) Yes, MTA is using Lua, but it has its own API for rendering. Currently MoonLoader has no its own API for rendering, there is just original game possibilities to display some primitives on the screen. Adding rendering API is one of the priority tasks, but unfortunately, I can not even say approximately when it will be done. Edited July 5, 2017 by BH Team Thompson98, RyanDri3957V and Crspy 3 Link to comment Share on other sites More sharing options...