This is the place for discussion and support for LunaLua and related modifications and libraries.
Moderator: Userbase Moderators
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?
|
|
|
|
-
Quantix
- Chain Chomp

- Posts: 333
- Joined: Tue Jan 26, 2016 5:04 pm
Postby Quantix » Sat Jul 16, 2016 1:04 pm
Spinda wrote:Do you mean sprites you draw with Lua or built-in graphics like NPCs?
Oh I meant regular custom graphics.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 16, 2016 1:17 pm
Quantix wrote:Spinda wrote:Do you mean sprites you draw with Lua or built-in graphics like NPCs?
Oh I meant regular custom graphics.
I think the best way to do it would be to use the Sprite Override class. You would start by loading an image of a fully transparent graphics file of the correct size and then use the Graphics.sprites function to override whatever graphic(s) you want. For example, if you wanted to make npc-1 transparent using a graphics file named "transparent", you would do:
Code: Select all local transparent = Graphics.loadImage("transparent.png");
function onStart()
Graphics.sprites.npc[1] = transparent;
end
To undo this, do:
I haven't tried it, but you could probably pass a table of NPC IDs through the function by doing:
Code: Select all local transparent = Graphics.loadImage("transparent.png");
local spriteIDs = {1, 6, 29, 46, 48};
function onStart()
for i = 1, 5 do
Graphics.sprites.npc[i] = transparent;
end
end
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg

- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Sat Jul 16, 2016 1:31 pm
Yoshi021 wrote:Code: Select all function onKeyUp()
Counter = Counter + 1
end
I want to trigger an event, every time I press the "Spin Jump" button, but this script triggers the event everytime I press any button. How do I fix this?
Code: Select all function onInputUpdate(KEY_SPINJUMP)
if player.altJumpKeyPressing then
Counter = Counter + 1
end
end
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg

- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Sat Jul 16, 2016 1:37 pm
MECHDRAGON777 wrote:Yoshi021 wrote:Code: Select all function onKeyUp()
Counter = Counter + 1
end
I want to trigger an event, every time I press the "Spin Jump" button, but this script triggers the event everytime I press any button. How do I fix this?
Code: Select all function onInputUpdate(KEY_SPINJUMP)
if player.altJumpKeyPressing then
Counter = Counter + 1
end
end
Thanks
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 16, 2016 1:44 pm
Yoshi021 wrote:MECHDRAGON777 wrote:Yoshi021 wrote:Code: Select all function onKeyUp()
Counter = Counter + 1
end
I want to trigger an event, every time I press the "Spin Jump" button, but this script triggers the event everytime I press any button. How do I fix this?
Code: Select all function onInputUpdate(KEY_SPINJUMP)
if player.altJumpKeyPressing then
Counter = Counter + 1
end
end
Thanks
That's actually wrong in a sense though. You shouldn't be putting KEY_SPINJUMP in the onInputUpdate event's brackets. It's like typing into a calculator 2+2 to find that it equals four and then typing the same thing into another answer to find out again that you get the same answer
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Jul 16, 2016 1:47 pm
MECHDRAGON777 wrote:Yoshi021 wrote:Code: Select all function onKeyUp()
Counter = Counter + 1
end
I want to trigger an event, every time I press the "Spin Jump" button, but this script triggers the event everytime I press any button. How do I fix this?
Code: Select all function onInputUpdate(KEY_SPINJUMP)
if player.altJumpKeyPressing then
Counter = Counter + 1
end
end
No.
Few problems.
1) you don't pass any variables to onInputUpdate. KEY_SPINJUMP in this code will ALWAYS be nil.
2) This script will trigger every time the player will press ANY button while the spinjump button is held.
If you wanna check for the frame a key is pressed I suggest loading the inputs2 api:
Code: Select all local inputs2 = API.load("inputs2")
local Counter = 0
function onTick()
if inputs2.state[1].altjump == inputs.PRESS then --if player 1 pressed altjump this frame
Counter = Counter + 1
end
end
http://wohlsoft.ru/pgewiki/Inputs2.lua
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg

- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Sat Jul 16, 2016 4:01 pm
Code: Select all function onKeyDown(value)
if value == KEY_SPINJUMP then
CharacterState = CharacterState - 1
end
end
function onTick()
player:mem(0x120,FIELD_WORD,1)
end
Somehow this managed to work. I don't know if the inputs2.lua better, but this seems to get the work done.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 16, 2016 4:21 pm
Yoshi021 wrote:Code: Select all function onKeyDown(value)
if value == KEY_SPINJUMP then
CharacterState = CharacterState - 1
end
end
function onTick()
player:mem(0x120,FIELD_WORD,1)
end
Somehow this managed to work. I don't know if the inputs2.lua better, but this seems to get the work done.
Use inputs2.lua
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg

- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Mon Jul 18, 2016 8:41 pm
How can I trigger an event once when the player gets hurt?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Mon Jul 18, 2016 9:15 pm
Yoshi021 wrote:How can I trigger an event once when the player gets hurt?
Use the Event class and a condition involving the Player memory regarding player state. I think 2 is powering down which is what you'll want to check for
|
|
|
|
|
|
|
|
|
-
TheWarpyro
- Hoopster

- Posts: 46
- Joined: Fri Jul 15, 2016 3:30 pm
Postby TheWarpyro » Tue Jul 19, 2016 10:32 am
Hey, after i download the vanilla+launcher version of Lunalua (v 0.7.3 Beta), do i place it on the smbx folder with the other smbx files?
|
|
|
|
|
|
|
|
|
-
Reign
- Chain Chomp

- Posts: 327
- Joined: Tue Jan 21, 2014 4:22 am
Postby Reign » Tue Jul 19, 2016 10:50 am
I guess my idea for a boo that always follows you isn't really working like this?
function onLoop()
for k,v in pairs(NPC.get(38,player.section)) do
v:mem(0xF0,FIELD_DFLOAT,1)
end
end
Is it even possible to manipulate this AI value?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Jul 19, 2016 10:54 am
TheWarpyro wrote:Hey, after i download the vanilla+launcher version of Lunalua (v 0.7.3 Beta), do i place it on the smbx folder with the other smbx files?
Yes.
Reign wrote:I guess my idea for a boo that always follows you isn't really working like this?
function onLoop()
for k,v in pairs(NPC.get(38,player.section)) do
v:mem(0xF0,FIELD_DFLOAT,1)
end
end
Is it even possible to manipulate this AI value?
v.ai1 for boos overrides your changes because it's set by smbx around where speedX and speedY are set. The boo ai is pretty simple to recreate though so just creating a lua object or replacing a goomba shouldn't be too much of an issue.
Also use onTick instead of onLoop :V
|
|
|
|
|
|
|
|
|
-
TheWarpyro
- Hoopster

- Posts: 46
- Joined: Fri Jul 15, 2016 3:30 pm
Postby TheWarpyro » Tue Jul 19, 2016 10:57 am
All of them?
(Mind talking about this via PMs?)
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Jul 19, 2016 11:04 am
yes all of them
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg

- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Wed Jul 20, 2016 1:21 am
Is it possible to freeze time with a lua code on the press of a button?
Code: Select all local menu = 0
local mapNil = Graphics.loadImage("Map Tiles/Empty Map.png")
local mapUnexplored = Graphics.loadImage("Map Tiles/Unexplored Map.png")
function onKeyUpdate()
if menu = 0 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (FREEZE ALL ACTIONS)>
menu = 1
end
elseif menu = 1 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (UNFREEZE ALL ACTIONS)>
menu = 0
end
end
end
function onTick()
onMap()
if menu == 1 then
onMenuA()
elseif menu == 0 then
onMenuB()
end
end
function onMenuA()
if Graphics.activateHud then
Graphics.activateHud = false
end
if mapData:get("Map Collected") == 0 then
Graphics.drawImageWP(mapNil, 0, 0, 3)
elseif mapData:get("Map Collected") == 1 then
Graphics.drawImageWP(mapUnexplored, 0, 0, 3)
end
end
function onMenuB()
if Graphics.activateHud == false then
Graphics.activateHud
end
end
I know you can lock controls, I even know how to do it. I just want to know how to make the game act like it is paused while the menu is up. (It is quite obvious it is a map from when you look at the code.) My thing is just trying to get the game to freeze all actions like the game was paused, and show the image instead of the pause screen. I think I messed up the function to hide the HUD during that time, but freezing all actions, that is what I am confused on how to do.
|
|
|
|
|
|
|
|
|
-
Yoshi021
- Gold Yoshi Egg

- Posts: 691
- Joined: Thu Jan 21, 2016 9:06 pm
- Flair: :)
- Pronouns: He/Him
Postby Yoshi021 » Wed Jul 20, 2016 8:44 am
MECHDRAGON777 wrote:Is it possible to freeze time with a lua code on the press of a button?
Code: Select all local menu = 0
local mapNil = Graphics.loadImage("Map Tiles/Empty Map.png")
local mapUnexplored = Graphics.loadImage("Map Tiles/Unexplored Map.png")
function onKeyUpdate()
if menu = 0 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (FREEZE ALL ACTIONS)>
menu = 1
end
elseif menu = 1 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (UNFREEZE ALL ACTIONS)>
menu = 0
end
end
end
function onTick()
onMap()
if menu == 1 then
onMenuA()
elseif menu == 0 then
onMenuB()
end
end
function onMenuA()
if Graphics.activateHud then
Graphics.activateHud = false
end
if mapData:get("Map Collected") == 0 then
Graphics.drawImageWP(mapNil, 0, 0, 3)
elseif mapData:get("Map Collected") == 1 then
Graphics.drawImageWP(mapUnexplored, 0, 0, 3)
end
end
function onMenuB()
if Graphics.activateHud == false then
Graphics.activateHud
end
end
I know you can lock controls, I even know how to do it. I just want to know how to make the game act like it is paused while the menu is up. (It is quite obvious it is a map from when you look at the code.) My thing is just trying to get the game to freeze all actions like the game was paused, and show the image instead of the pause screen. I think I messed up the function to hide the HUD during that time, but freezing all actions, that is what I am confused on how to do.
This will work:
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg

- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Wed Jul 20, 2016 8:50 am
Yoshi021 wrote:MECHDRAGON777 wrote:Is it possible to freeze time with a lua code on the press of a button?
Code: Select all local menu = 0
local mapNil = Graphics.loadImage("Map Tiles/Empty Map.png")
local mapUnexplored = Graphics.loadImage("Map Tiles/Unexplored Map.png")
function onKeyUpdate()
if menu = 0 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (FREEZE ALL ACTIONS)>
menu = 1
end
elseif menu = 1 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (UNFREEZE ALL ACTIONS)>
menu = 0
end
end
end
function onTick()
onMap()
if menu == 1 then
onMenuA()
elseif menu == 0 then
onMenuB()
end
end
function onMenuA()
if Graphics.activateHud then
Graphics.activateHud = false
end
if mapData:get("Map Collected") == 0 then
Graphics.drawImageWP(mapNil, 0, 0, 3)
elseif mapData:get("Map Collected") == 1 then
Graphics.drawImageWP(mapUnexplored, 0, 0, 3)
end
end
function onMenuB()
if Graphics.activateHud == false then
Graphics.activateHud
end
end
I know you can lock controls, I even know how to do it. I just want to know how to make the game act like it is paused while the menu is up. (It is quite obvious it is a map from when you look at the code.) My thing is just trying to get the game to freeze all actions like the game was paused, and show the image instead of the pause screen. I think I messed up the function to hide the HUD during that time, but freezing all actions, that is what I am confused on how to do.
This will work:
Thanks, now I just got to hope that
Code: Select all if Graphics.activateHud == false then
Graphics.activateHud
end
is the correct thing as well as the opposite of it.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Wed Jul 20, 2016 3:42 pm
MECHDRAGON777 wrote:Yoshi021 wrote:MECHDRAGON777 wrote:Is it possible to freeze time with a lua code on the press of a button?
Code: Select all local menu = 0
local mapNil = Graphics.loadImage("Map Tiles/Empty Map.png")
local mapUnexplored = Graphics.loadImage("Map Tiles/Unexplored Map.png")
function onKeyUpdate()
if menu = 0 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (FREEZE ALL ACTIONS)>
menu = 1
end
elseif menu = 1 then
if Player.pauseKeyPressing then
Player.pauseKeyPressing = false
<HELP (UNFREEZE ALL ACTIONS)>
menu = 0
end
end
end
function onTick()
onMap()
if menu == 1 then
onMenuA()
elseif menu == 0 then
onMenuB()
end
end
function onMenuA()
if Graphics.activateHud then
Graphics.activateHud = false
end
if mapData:get("Map Collected") == 0 then
Graphics.drawImageWP(mapNil, 0, 0, 3)
elseif mapData:get("Map Collected") == 1 then
Graphics.drawImageWP(mapUnexplored, 0, 0, 3)
end
end
function onMenuB()
if Graphics.activateHud == false then
Graphics.activateHud
end
end
I know you can lock controls, I even know how to do it. I just want to know how to make the game act like it is paused while the menu is up. (It is quite obvious it is a map from when you look at the code.) My thing is just trying to get the game to freeze all actions like the game was paused, and show the image instead of the pause screen. I think I messed up the function to hide the HUD during that time, but freezing all actions, that is what I am confused on how to do.
This will work:
Thanks, now I just got to hope that
Code: Select all if Graphics.activateHud == false then
Graphics.activateHud
end
is the correct thing as well as the opposite of it.
Graphics.activateHud() is a function to activate the HUD using an argument with a boolean value, Graphics.isHudActivated() returns whether or not the HUD is activated
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: Ahrefs [Bot] and 1 guest
|