Jump to content

Elements To Lua Converter (Vehicles, Objects, Markers..)


AleksCore

Recommended Posts

Posted (edited)

[ETL] Elements To Lua Converter by AleksCore

Simple script (tool for map editor) to output position, rotation (and other properties) of vehicles (objects/markers/peds) to lua format.

How it works?

First of all start Map Editor and start this script (/start etl) :D, then:

1) Select vehicle (object/marker/ped) and press "H".

2) Open "Output Box" by pressing CTRL + G

3) You will get something like that:

createVehicle(411, 1234, -634, 20, 0, 0, 90) --if you was selected vehicle 

or

createMarker(1234, -634, 20, "corona", 10, 255, 255, 255, 255) --if you was selected marker 

4) You can also convert all vehicles (objects/markers/peds) from map by pressing "All Vehicles to lua" button in menu

Screenshots:

10458.png

10457.png

P.S. This is my first script with GUI.

Link to download

Edited by Guest
  • 2 weeks later...
  • MTA Team
Posted

I dug through the code to find something to complain about this resource:

function VehiclesToLua() 
vehicles = getElementsByType("vehicle") 
for key, vehicle in ipairs(vehicles) do 
x, y, z = getElementPosition(vehicle) 
rx, ry, rz = getElementRotation(vehicle) 
model = getElementModel(vehicle) 
    oldText = guiGetText(outputBoxMemo) 
    guiSetText(outputBoxMemo, oldText.."createVehicle("..model..", "..x..", "..y..", "..z..", "..rx..", "..ry..", "..rz..")") 
end 

You shouldn't really do this. Other resources can create vehicles, you know? Consider using the API (exports) that the map editor provides you.

Indent your code.

Posted

Besides what A Concerned Citizen mentioned, you should use local variables except when strictly needed and perhaps, to make code look cleaner and easier to read, use format method from the Lua string library instead of formatting and sending the string directly to the function.

Note that we are just trying to help you, so that you don't make the same mistakes twice.

Posted

A Concerned Citizen, ixjf,

thx, but the only thing that I understand from this - I have to use local variables less :(

ehh, programming it's not my..

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...