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?
|
|
|
|
-
Mario_and_Luigi_55
- Spike

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
Postby Mario_and_Luigi_55 » Sun Apr 10, 2016 2:20 pm
Catastrophe wrote:PixelPest wrote:Catastrophe wrote:The code didn't crash when I added the other end but it's not making the blocks slippery. ???
Then use function onTick(). That should work
function onTick() also doesn't work.
Did you put next end?
|
|
|
|
|
|
|
|
|
-
Hani
- Volcano Lotus

- Posts: 565
- Joined: Mon Apr 13, 2015 6:34 pm
Postby Hani » Sun Apr 10, 2016 2:21 pm
Mario_and_Luigi_55 wrote:
Did you put next end?
Code: Select all function onTick()
end
for k,v in pairs(Block.get()) do
v.slippery = true
end
I think so..
|
|
|
|
|
|
|
|
|
-
Mario_and_Luigi_55
- Spike

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
Postby Mario_and_Luigi_55 » Sun Apr 10, 2016 2:24 pm
Catastrophe wrote:Mario_and_Luigi_55 wrote:
Did you put next end?
Code: Select all function onTick()
end
for k,v in pairs(Block.get()) do
v.slippery = true
end
I think so..
That way you qre ending function right after start.
Code: Select all function onTick()
for k,v in pairs(Block.get(id of block,-1)) do
v.slippery = true
end
end
|
|
|
|
|
|
|
|
|
-
Hani
- Volcano Lotus

- Posts: 565
- Joined: Mon Apr 13, 2015 6:34 pm
Postby Hani » Sun Apr 10, 2016 2:27 pm
Mario_and_Luigi_55 wrote:Catastrophe wrote:Mario_and_Luigi_55 wrote:
Did you put next end?
Code: Select all function onTick()
end
for k,v in pairs(Block.get()) do
v.slippery = true
end
I think so..
That way you qre ending function right after start.
Code: Select all function onTick()
for k,v in pairs(Block.get(id of block,-1)) do
v.slippery = true
end
end
Thank you! I finally know a little bit more of lunalua coding now.
|
|
|
|
|
|
|
|
|
-
Quantix
- Chain Chomp

- Posts: 333
- Joined: Tue Jan 26, 2016 5:04 pm
Postby Quantix » Sun Apr 10, 2016 3:19 pm
Okay, so I've used the raocoin2 lua, and when I copypaste the code from the wiki, which is this:
Code: Select all raocoin = loadSharedAPI("raocoin2");
rc = raocoin.registerCurrency(274, true, 472, 66);
coins = raocoin.registerMemCurrency(0x00B2C5A8,FIELD_WORD,true,false,0,0,"coins.png");
Then I load a level,and I get this error:
Code: Select all lunaworld.lua:2: attempt to index global 'raocoin' (a nil value)
I swear this error is really annoying. Is it because you're not supposed to put it in a lunaworld file or something?
|
|
|
|
|
|
|
|
|
-
Mudkip
- Lakitu

- Posts: 458
- Joined: Mon Jan 06, 2014 11:35 pm
Postby Mudkip » Sun Apr 10, 2016 4:39 pm
How do I make Link-6 the only character with his own health bar for a whole episode?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sun Apr 10, 2016 7:51 pm
Mudkip wrote:How do I make Link-6 the only character with his own health bar for a whole episode?
Put this in your lunaworld.lua:
Code: Select all if player.character == 5 then
--health bar script
end
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg

- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Mon Apr 11, 2016 12:30 am
PixelPest wrote:Mudkip wrote:How do I make Link-6 the only character with his own health bar for a whole episode?
Put this in your lunaworld.lua:
Code: Select all if player.character == 5 then
--health bar script
end
I thought you need to set the player to player 6. If the player gets hurt, it will go to player 2 or 1. Check if that is occurring, the set it to 6. That way, it will keep track, but if the health bar reaches 0, you need to use tbe "kill" command. It is later, so I can not think straight, bjt that should be the jeist of it.
|
|
|
|
|
|
|
|
|
-
Quill
- Rydia

- Posts: 812
- Joined: Tue Dec 03, 2013 12:51 pm
-
Contact:
Postby Quill » Mon Apr 11, 2016 2:33 am
lol
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Mon Apr 11, 2016 7:02 am
MECHDRAGON777 wrote:PixelPest wrote:Mudkip wrote:How do I make Link-6 the only character with his own health bar for a whole episode?
Put this in your lunaworld.lua:
Code: Select all if player.character == 5 then
--health bar script
end
I thought you need to set the player to player 6. If the player gets hurt, it will go to player 2 or 1. Check if that is occurring, the set it to 6. That way, it will keep track, but if the health bar reaches 0, you need to use tbe "kill" command. It is later, so I can not think straight, bjt that should be the jeist of it.
Sorry, didn't read the whole question. You just have to do this then:
Code: Select all if Player.character == 5 and Player.powerup == 6 then
--health bar script
end
That should work. Btw MECHDRAGON777 you can't just set "player" to something, that's not how that works at all for what you're trying to do
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon Apr 11, 2016 7:38 am
PixelPest wrote:
That should work.
No it won't. You've used "Player" when it should be "player". There is a big difference between the two.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Mon Apr 11, 2016 8:02 am
Hoeloe wrote:PixelPest wrote:
That should work.
No it won't. You've used "Player" when it should be "player". There is a big difference between the two.
Right. Sorry. So Mudkip, do:
Code: Select all if player.character == 5 and player.powerup == 6 then
--health bar script
end
Last edited by PixelPest on Mon Apr 11, 2016 12:22 pm, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg

- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Mon Apr 11, 2016 8:25 am
PixelPest wrote:Hoeloe wrote:PixelPest wrote:
That should work.
No it won't. You've used "Player" when it should be "player". There is a big difference between the two.
Right. Sorry. So RoundPiplup, do:
Code: Select all if player.character == 5 and player.powerup == 6 then
--health bar script
end
Mudkip is the one asking though... I never wrote the code for him to use because I can not reference the wiki while on a phone. I also do not have the entire wiki printed out yet as of today... I was just trying to help a little bit.
|
|
|
|
|
|
|
|
|
-
Mudkip
- Lakitu

- Posts: 458
- Joined: Mon Jan 06, 2014 11:35 pm
Postby Mudkip » Mon Apr 11, 2016 1:00 pm
I copypaste'd the code you wrote but I still play as Link normally. Don't I need to activate the code first or something?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Apr 11, 2016 1:58 pm
PixelPest wrote:
Right. Sorry. So Mudkip, do:
Code: Select all if player.character == 5 and player.powerup == 6 then
--health bar script
end
What no
How is
how is what you're doing even remotely helpful.
He's asking how he should tackle a healthbar script and how to force the character to state 6 at all times.
While I won't write the code for you (mudkip), because it's important that you work this out for yourself, I'm gonna (unlike other people *nudge*) provide some sources and tips on what to do and how to tackle this.
-Setting the player to link and initially setting him to state 6 is no issue. Use function onStart() and player.powerup, as well as player.character, which you can find here:
http://wohlsoft.ru/pgewiki/Player_%28class%29
You might want to build in a check though for the latter.
-Setting the player powerup to 6 might be a bit tricky. If the player powerup was 1 before, link will start clipping through the ground. There are a few workarounds, but the safest is probably breifly setting the powerup state to 2 before setting it to 6.
-To impliment your own health bar you want to create a variable in the data class:
http://wohlsoft.ru/pgewiki/Data_%28class%29
The data class is a class which you can use to save variables between levels. Pyro made a tutorial on it, too: https://www.youtube.com/watch?v=dnTH_cBYZhs
By using it you can make a variable which will store the player's current HP. Once it reaches 0 you kill the player (once).
-The normal way how smbx handles health might sound to be obsolete, however you can still use it to detect changes to the player's hp.
http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Offset 0x16 stores the number of hearts. Ideally you want this to be 2 at all times, breifly falling back to 1 when hit and going to 3 when getting a powerup for a frame or two. During that time you catch the difference and adjust your data class variable (and the player powerup if needed).
For a first-hand look on a health bar script like this, take a look at hudOfTime.lua. It does what I described here. Make sure to not copy the code though without having understood what it does, since else you might end up puzzled in a few weeks when something breaks somehow.
|
|
|
|
|
|
|
|
|
-
pal4
- Swooper

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Mon Apr 11, 2016 4:43 pm

local hasGenerated = false;
local ran;
function onLoop()
tableOfBirdo = NPC.get(39, -1);
tableOfBirdoEggs = NPC.get(40, -1);
Text.print(tostring(ran),0,0)
if(tableOfBirdo[1] ~= nil) then
if(tonumber(tableOfBirdo[1]:mem(0xF0, FIELD_DFLOAT)) = 1) then
if(hasGenerated ~= true) then
ran = math.random(0, 2);
hasGenerated = true;
end
if(ran == 2) then
if(table.getn(tableOfBirdoEggs) > 0) then
tableOfBirdoEggs[table.getn(tableOfBirdoEggs)].id = 282;
playSFX(42);
end
end
end
if(tonumber(tableOfBirdo[1]:mem(0xF8, FIELD_DFLOAT)) == 280) then
hasGenerated = false;
end
end
end
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Apr 11, 2016 4:45 pm
pal4 wrote:
local hasGenerated = false;
local ran;
function onLoop()
tableOfBirdo = NPC.get(39, -1);
tableOfBirdoEggs = NPC.get(40, -1);
Text.print(tostring(ran),0,0)
if(tableOfBirdo[1] ~= nil) then
if(tonumber(tableOfBirdo[1]:mem(0xF0, FIELD_DFLOAT)) = 1) then
if(hasGenerated ~= true) then
ran = math.random(0, 2);
hasGenerated = true;
end
if(ran == 2) then
if(table.getn(tableOfBirdoEggs) > 0) then
tableOfBirdoEggs[table.getn(tableOfBirdoEggs)].id = 282;
playSFX(42);
end
end
end
if(tonumber(tableOfBirdo[1]:mem(0xF8, FIELD_DFLOAT)) == 280) then
hasGenerated = false;
end
end
end
http://hastebin.com
Last edited by Emral on Mon Apr 11, 2016 4:46 pm, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Mon Apr 11, 2016 4:46 pm
pal4 wrote:
Code: Select all local hasGenerated = false;
local ran;
function onLoop()
tableOfBirdo = NPC.get(39, -1);
tableOfBirdoEggs = NPC.get(40, -1);
Text.print(tostring(ran),0,0)
if(tableOfBirdo[1] ~= nil) then
if(tonumber(tableOfBirdo[1]:mem(0xF0, FIELD_DFLOAT)) = 1) then
if(hasGenerated ~= true) then
ran = math.random(0, 2);
hasGenerated = true;
end
if(ran == 2) then
if(table.getn(tableOfBirdoEggs) > 0) then
tableOfBirdoEggs[table.getn(tableOfBirdoEggs)].id = 282;
playSFX(42);
end
end
end
if(tonumber(tableOfBirdo[1]:mem(0xF8, FIELD_DFLOAT)) == 280) then
hasGenerated = false;
end
end
end
It might help if you mention your issue
|
|
|
|
|
|
|
|
|
-
Alagirez
- Ludwig von Koopa

- Posts: 3617
- Joined: Tue Dec 02, 2014 2:28 am
- Flair: Legalize Awooo!
- Pronouns: He/Him/That wolf
-
Contact:
Postby Alagirez » Tue Apr 12, 2016 2:17 am
so i tried to load an image with onEvent function and it doesn't work
Code: Select all function onEvent
if calledEvent == "Peta Jamaa Township 2" then
img = Graphics.loadimage ("rumah.png")
Graphics.placeSprite (1, img, 0, 0)
end
end
help
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 4 guests
|