Re: Helpful/Cool LunaLua Codes Thread
Posted: Tue Sep 06, 2016 1:09 pm
No. That's not LuaKesterTank wrote:Works in tea script AKA SMBX 1.4.2?
Forums for SMBX
https://www.smbxgame.com/forums/
No. That's not LuaKesterTank wrote:Works in tea script AKA SMBX 1.4.2?
Lunalua is different from TeaScript, so the code PixelPest has would not work in 1.4.3, but it's possible. Also, remember that 1.4 is banned at the moment, so please use the 1.4 forum for 1.4 questions.KesterTank wrote:Works in tea script AKA SMBX 1.4.2?
Code: Select all
function onTick()
if player:mem(0x34, FIELD_WORD) == 2 then
player:kill();
end
end
All of these codes are LunaLuna, not Teascript. Teascript is a substantially less powerful language than LunaLua, and won't be able to do a lot of what can be done here. (That doesn't mean none of this is possible with Teascript, but not everything will be, and the codes certainly won't work).KesterTank wrote:Works in tea script AKA SMBX 1.4.2?
Code: Select all
local text = "'write message here'"
local otu = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
local storage = {}
function mes(input)
if input == "SOMETHING" then -- make an if statement on what you want the player to input, and what should happen when the player writes something
--code here -- you can also use triggerEvent("<EVRNTNAME>")
end
end
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function string.ends(String,End)
return End=='' or string.sub(String,-string.len(End))==End
end
function onStart()
player:mem(0x112,FIELD_WORD,2)
end
function onTick()
Text.print(text, 18, 576)
for i=0, #storage do --This is for debugging, you can delete this
Text.print(storage[i], 0, i*16-16)
end
end
function onKeyboardPress(vk)
if text == "'write message here'" and (vk == 8 or vk == 32 or (vk >= 48 and vk <= 57) or (vk >= 65 and vk <= 90)) then
text = ""
end
if vk >= 65 and vk <= 90 then
text = text..otu[vk - 64]
elseif vk >= 48 and vk <= 57 then
text = text..vk - 48
elseif vk == 32 then
text = text.." "
elseif vk == 8 then
text = text:sub(1, -2)
elseif vk == 13 and text ~= "'write message here'" then
local i = 0
while i>=0 do
i = i+1
if storage[i] == nil then
storage[i] = text
mes(text)
text = ""
i = -1
end
end
end
end
I haven't tried your code, but that sounds a lot like Misc.cheatBuffer.Yoshi021 wrote:This code lets the player be able to write a message in order to activate something. For example, you can use this for a puzzle where the player can't move and has to input commands in order to win. As of right now, messages can only be composed of letters and numbers. You can make your own function by making "if statements" (since Lua doesn't have select case" on the mes function(). Make sure to have the message in CAPS, or it won't work!
Code: Select all
local text = "'write message here'" local otu = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} local storage = {} function mes(input) if input == "SOMETHING" then -- make an if statement on what you want the player to input, and what should happen when the player writes something --code here -- you can also use triggerEvent("<EVRNTNAME>") end end function string.starts(String,Start) return string.sub(String,1,string.len(Start))==Start end function string.ends(String,End) return End=='' or string.sub(String,-string.len(End))==End end function onStart() player:mem(0x112,FIELD_WORD,2) end function onTick() Text.print(text, 18, 576) for i=0, #storage do --This is for debugging, you can delete this Text.print(storage[i], 0, i*16-16) end end function onKeyboardPress(vk) if text == "'write message here'" and (vk == 8 or vk == 32 or (vk >= 48 and vk <= 57) or (vk >= 65 and vk <= 90)) then text = "" end if vk >= 65 and vk <= 90 then text = text..otu[vk - 64] elseif vk >= 48 and vk <= 57 then text = text..vk - 48 elseif vk == 32 then text = text.." " elseif vk == 8 then text = text:sub(1, -2) elseif vk == 13 and text ~= "'write message here'" then local i = 0 while i>=0 do i = i+1 if storage[i] == nil then storage[i] = text mes(text) text = "" i = -1 end end end end
Code: Select all
local horikawaTools = API.load("horikawaTools");
function onTick()
local keyholes = BGO.getIntersecting(player.x + 0.5*player.width - 1, player.y + 0.5*player.height - 1, player.x + 0.5*player.width + 1, player.y + 0.5*player.height + 1);
for _, k in pairs(keyholes) do
if k.id == 35 then
local npc = NPC.spawn(31, player.x, player.y, player.section);
horikawaTools.makeNPCInvisible(npc);
for m, n in pairs(NPC.get(31)) do
if n == npc then
player:mem(0x154, FIELD_WORD, m);
end
end
Level.winState(3);
end
end
end
You added the onTick function after I have written my reply. 7 edits total. At the time of my reply, your code had no chance of working.PixelPest wrote:I most certainly did test it. The cheat you mentioned also doesn't seem to work with characters that don't have the ability to hold items, which was the purpose of this code
Code: Select all
local npcconfig = API.load("npcconfig");
npcconfig[15].cliffturn = -1;
function onTick()
for _, v in pairs(NPC.get(15)) do
if v.ai1 == 3 then
v.ai1 = 0;
end
end
end
Code: Select all
local function reload()
Graphics.glDraw{vertexCoords = {0, 0, 800, 0, 800, 600, 0, 600}, color = {0, 0, 0, 1}, primitive = Graphics.GL_TRIANGLE_FAN, priority = 10};
mem(0x00B2C6DA, FIELD_WORD, player:mem(0x15E, FIELD_WORD));
mem(0x00B25720, FIELD_STRING, Level.filename());
mem(0x00B250B4, FIELD_WORD, 0);
mem(0x00B25134, FIELD_WORD, 0);
mem(0x00B2C89C, FIELD_WORD, 0);
mem(0x00B2C620, FIELD_WORD, 0);
mem(0x00B2C5B4, FIELD_WORD, -1);
end
Code: Select all
local pnpc = API.load("pnpc");
local npcconfig = API.load("npcconfig");
local framespeed = npcconfig[15].framespeed;
local frameSets = {[true] = 1, [false] = -1};
function onDraw()
for _, v in pairs(NPC.get(15)) do
if (v.ai1 == 0) and (v:mem(0x0A, FIELD_WORD) == 2) then
local bb = pnpc.wrap(v);
if bb.data.up == nil then
bb.data.up = true;
bb.data.counter = 0;
bb.data.frame = 1;
end
if bb.data.counter == math.floor(framespeed/2) then
bb.data.frame = bb.data.frame + frameSets[bb.data.up]
bb.data.counter = 1;
if bb.data.frame == 4 then
bb.data.up = false;
elseif bb.data.frame == 1 then
bb.data.up = true;
end
else
bb.data.counter = bb.data.counter + 1;
end
v:mem(0xE4, FIELD_WORD, bb.data.frame);
end
end
end
What? PixelPest's code is meant to be placed in level Lua, not in an API file.Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.
This had nothing to do with PP. Every time I come across a LunaLua code, the Read Me says to paste in the API code. THEY FRICKING LEFT IT OUT!The0x539 wrote:What? PixelPest's code is meant to be placed in level Lua, not in an API file.Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.
This isn't 38A. You don't need to paste all the code in one file. It's telling you to paste the API FILE (most of which are unnecessary anyway since they're included in beta 3), not to copy the actual code.Noodle wrote:This had nothing to do with PP. Every time I come across a LunaLua code, the Read Me says to paste in the API code. THEY FRICKING LEFT IT OUT!The0x539 wrote:What? PixelPest's code is meant to be placed in level Lua, not in an API file.Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.