This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Sep 06, 2016 1:09 pm
KesterTank wrote:Works in tea script AKA SMBX 1.4.2?
No. That's not Lua
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg
- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Tue Sep 06, 2016 7:53 pm
KesterTank 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.
http://wohlsoft.ru/forum/viewforum.php?f=58
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sun Oct 09, 2016 9:30 pm
This is a really short but simple script to make poison water/quicksand. Instead of just reskinning lava and having NPCs perish as well, this short code makes the player die whenever they touch a water box
Code: Select all function onTick()
if player:mem(0x34, FIELD_WORD) == 2 then
player:kill();
end
end
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon Oct 10, 2016 2:28 am
KesterTank wrote:Works in tea script AKA SMBX 1.4.2?
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).
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg
- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Mon Oct 10, 2016 7:17 pm
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
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9723
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Oct 10, 2016 7:20 pm
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
I haven't tried your code, but that sounds a lot like Misc.cheatBuffer.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Wed Dec 14, 2016 7:19 pm
Here's a code that allows players to enter keyhole exits without keys. This is especially useful for characters that can't hold items:
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
Last edited by PixelPest on Thu Dec 15, 2016 8:58 am, edited 8 times in total.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9723
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Dec 15, 2016 8:39 am
It is also most certainly untested and made obsolete thanks to a 2.0 cheat code that ends the level with a key exit, namely "foundmycarkeys"!
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Thu Dec 15, 2016 8:48 am
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.
EDIT: I just missed the onTick() in the code I posted
Last edited by PixelPest on Thu Dec 15, 2016 8:58 am, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9723
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Dec 15, 2016 8:57 am
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
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
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Thu Dec 15, 2016 8:59 am
Yeah sorry. I just submitted the edit for my other post as you posted that
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sun Aug 06, 2017 6:25 pm
Bringing this thread back 'cause why not.
This code makes a Boom Boom cliffturn perfectly without ever jumping so that it will never fall off edges:
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
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Aug 12, 2017 1:54 pm
Here's a snippet of code that some might find useful (especially for puzzle levels) which reloads the current level, making the player exit from the last-used warp or at the beginning of the level, if no warps have been used yet, upon reloading:
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
|
|
|
|
|
|
|
|
|
-
PixelPest
- Raccoon Mario
- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Wed Aug 30, 2017 3:07 pm
Boom Boom does some pretty interesting shenanigans when introduced to moving layers. Here's a fix for NPC-15 animations:
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
|
|
|
|
|
|
|
|
|
-
Noodle
- Banned
- Posts: 595
- Joined: Mon Aug 15, 2016 9:34 am
Postby Noodle » Wed Aug 30, 2017 3:55 pm
Why do people leave out the API code and have the player paste it in? Does not make sense.
|
|
|
|
|
|
|
|
|
-
The0x539
- Eerie
- Posts: 751
- Joined: Fri Jan 22, 2016 8:02 pm
Postby The0x539 » Wed Aug 30, 2017 5:41 pm
Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.
What? PixelPest's code is meant to be placed in level Lua, not in an API file.
|
|
|
|
|
|
|
|
|
-
Noodle
- Banned
- Posts: 595
- Joined: Mon Aug 15, 2016 9:34 am
Postby Noodle » Wed Aug 30, 2017 5:43 pm
The0x539 wrote:Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.
What? PixelPest's code is meant to be placed in level Lua, not in an API file.
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!
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Wed Aug 30, 2017 5:47 pm
Noodle wrote:The0x539 wrote:Noodle wrote:Why do people leave out the API code and have the player paste it in? Does not make sense.
What? PixelPest's code is meant to be placed in level Lua, not in an API file.
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!
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.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 0 guests
|