First off I SUCK at Lua! I am just learning so please don't blast me on how bad the code might be. I spent hours researching to come up with this. If there's a better way though please feel free to post in the comments. I would love to learn new ways to do things. But for my limited knowledge this is working pretty well for me and I thought others might get some use out of it
So I've been trying to learn some Lua and need to make this script for my Borderlands 3 table. I need to make hundreds of teleport scripts for all the locations to 100% complete each map. IE: Teleport Location of each ECHO log, all drop pods.. and so on.
I started off copying my script and pasting in each X Y and Z Cord for each script. As you can imagine this takes forever when doing thousands of teleport locations. So I spent some time reading up on Lua and created a script that will will write the teleport script for you and populate your X Y and Z Coords for you into the script. At this point all you need to do is go to the location you to save. Run the script. Copy all and paste all into a new auto assembly script and your done. Name it whatever you want and you have your teleport to that location done.
Of course you need you X Y Z pointers for this to work.. and change the pointers in the script so it works with your pointers.
Right now the script is setup to Never X the box in CE.. This saves the user from having to X the script twice.. once to use once to uncheck.. but this can be removed if you dont like it .. Just remove this line ---> print "return 'nop'"
I also included a timer option you could use instead.. Just comment out the return nop and remove the comment for the timer. This is set to Uncheck the box after 500ms.. but you can change that to any time you want
There is also a return 'nop' at the end of the script to make sure this creator script never gets Xed.. Reason for this is because I have it setup on a Hotkey so all I have to do it hit a button to populate the script. If you dont like this you can remove that line as well.
Anyways heres the script:
Code: Select all
{$lua}
if syntaxcheck then return end
[ENABLE]
GetLuaEngine().MenuItem5.doClick() -- Clears Lua Engine
print"{$lua}"
print"[ENABLE]"
print""
-- <-Change All pointers to your X Y and Z Cords -> --
XCoord = "[[[[player1]+168]+118]+4D0]+220" -- Do Not Remove The "
YCoord = "[[[[player1]+168]+118]+4D0]+224" -- Do Not Remove The "
ZCoord = "[[[[player1]+168]+118]+4D0]+228" -- Do Not Remove The "
X = "writeFloat('"..XCoord.."',"..(readFloat(""..XCoord.."")..") -- X Coord") -- Store Pointer To X
print (X) -- Print X String
Y = "writeFloat('"..YCoord.."',"..(readFloat(""..YCoord.."")..") -- Y Coord") -- Store Pointer To Y
print (Y) -- Print Y String
Z = "writeFloat('"..ZCoord.."',"..(readFloat(""..ZCoord.."")..") -- Z Coord") -- Store Pointer To Z
print (Z) -- Print Z String
print ""
--(Optional) Makes Script Activate But Remain Unchecked So you Can Use Again With Hotkey And Not Have To Uncheck First In New Script
--print "return 'nop'"
--Another option to Auto Un X Box.. This would allow you to Un X after a set amount of time. This is set to 500ms - Change to whatever timer you want
print [[if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 500,function(tm)
tm.Destroy()
memrec.Active = false
end
end)
end]]
print""
print"[DISABLE]"
-- (Optional) Makes Script Activate But Remain Unchecked So you Can Use Again With Hotkey And Not Have To Uncheck First
return 'nop'
-- (Optional) Could use timer instead
--if not syntaxcheck then
-- synchronize(function()
-- local t = createTimer()
-- t.Interval,t.OnTimer = 500,function(tm)
-- tm.Destroy()
-- memrec.Active = false
-- end
-- end)
--end
[DISABLE]
Code: Select all
{$lua}
[ENABLE]
writeFloat('[[[[player1]+168]+118]+4D0]+220',-81061.3828125) -- X Cord
writeFloat('[[[[player1]+168]+118]+4D0]+224',-72719.5078125) -- Y Cord
writeFloat('[[[[player1]+168]+118]+4D0]+228',2889.3981933594) -- Z Cord
return 'nop'
[DISABLE]
Code: Select all
{$lua}
[ENABLE]
writeFloat('[[[[player1]+168]+118]+4D0]+220',-81061.3828125) -- X Cord
writeFloat('[[[[player1]+168]+118]+4D0]+224',-72719.5078125) -- Y Cord
writeFloat('[[[[player1]+168]+118]+4D0]+228',2889.3981933594) -- Z Cord
if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 500,function(tm)
tm.Destroy()
memrec.Active = false
end
end)
end
[DISABLE]
This works great if you have a ton of teleport scripts to make
UPDATE: Teleport Script V2
Special thanks to ShyTwig16 for all his help creating this new version and all the help he's given me in learning more about Lua
This new script will create a new Teleport to: script to you cheat table every time you click on it.
All you need to do is change you X,Y,Z Pointers in the script and (Optional) Change the location is sends the new save locations to
I tried to document most every line in the script for those that are trying to learn Lua and want to know how the script works.
If I got something wrong in the documentation I apologies as I am still learning all this myself.
I am also leaving the old script here incase someone would rather have the Lua Engine print version instead.
Here is the code to the new script and can also be downloaded below:
Code: Select all
{$lua}
if syntaxcheck then return end
[ENABLE]
local script = {} -- Creates container (script) so we have a container to store script in using table.insert(script,)
table.insert(script, "{$lua}") -- Sending {$lua} To New script
table.insert(script, "[ENABLE]") -- Sending DISABLE To New script
table.insert(script, "") -- Sending Space To New Script
-- <-Change All 3 Pointers Match Your X Y and Z Pointers -> --
XCoord = "[[[[player1]+168]+118]+4D0]+220" -- Do Not Remove The "
YCoord = "[[[[player1]+168]+118]+4D0]+224" -- Do Not Remove The "
ZCoord = "[[[[player1]+168]+118]+4D0]+228" -- Do Not Remove The "
X = "writeFloat('"..XCoord.."',"..(readFloat(""..XCoord.."")..") -- X Coord") -- Store Pointer To X
table.insert(script, X) -- Send Value Of What's Inside X To New Script Because We Don't Have "" Around X To Define It As A String
Y = "writeFloat('"..YCoord.."',"..(readFloat(""..YCoord.."")..") -- Y Coord") -- Store Pointer To Y
table.insert(script, Y) -- Send Value Of What's Inside Y To New Script Because We Don't Have "" Around Y To Define It As A String
Z = "writeFloat('"..ZCoord.."',"..(readFloat(""..ZCoord.."")..") -- Z Coord") -- Store Pointer To Z
table.insert(script, Z) -- Send Value Of What's Inside Z To New Script Because We Don't Have "" Around Z To Define It As A String
table.insert(script, "") -- Sending Space To New Script
-- This will disable the script after 500ms so you dont have to keep unchecking it (adds this timer to saved script)
-- Sends timer To New Script Everything Between [[ ]]
table.insert(script, [[if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 500,function(tm)
tm.Destroy()
memrec.Active = false
end
end)
end]])
table.insert(script, "") -- Sending Space To New Script
table.insert(script, "[DISABLE]") -- Sending DISABLE To New script
MRLoc = AddressList.getMemoryRecordByDescription('Teleport Location Saver') -- Where You Want Saves To Go and put into MRLoc
local mr = AddressList.createMemoryRecord() -- Creates Memory Record (New Entry In CE) and stored it into mr
mr.Type = vtAutoAssembler -- Makes mr (New Entry) An Auto Assembler Script
mr.appendToEntry(MRLoc) -- adds MRloc (Locations Script Will GO) to mr (New Script)
mr.Description = 'Teleport to: ' -- Name of mr (New Script)
mr.Script = table.concat(script, '\n') -- Sends Everything with Table.insert (script,) to mr (New Script)
-- This will disable the script after 500ms so you dont have to keep unchecking it (Timer For This Script)
if not syntaxcheck then
synchronize(function()
local t = createTimer()
t.Interval,t.OnTimer = 500,function(tm)
tm.Destroy()
memrec.Active = false -- This Is The Part Of The Timer That Unchecks The Script
end
end)
end
[DISABLE]