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?
|
|
|
|
-
seiteom
- Goomba

- Posts: 4
- Joined: Mon Jun 27, 2016 5:59 pm
Postby seiteom » Mon Jun 27, 2016 6:13 pm
S1eth wrote:Mario_and_Luigi_55 wrote:RhysOwens wrote:Has anyone forgotten about me?
I'm not really making levels with LunaLua right now.
I'm messing around with it and experimenting with it so I can get used to it.
The NPCs all take more hits even when I've set the ID to 1 NPC with HealthPoint.lua.
I have same problem.
It's not you. HealthPoint is bugged.
First of all, when you load the API, it automatically sets all NPCs to 3 health. (the creator apparently thought that was a good idea...)
If you don't want that, you'd want to iterate over all NPC ids and call healthPoint.makeNPCNormal(id), but that doesn't work either.
healthPoint.makeNPCNormal is supposed to remove the entry for a specific NPC id from a table, but instead, it removes the value with the index of the npc id, and then pushes all other indexes in the table forward to fill in the gap.
It's pretty broken.
Here is a fix: http://hastebin.com/anerequxef.lua
Create a new text file inside your level folder. Copy and paste the hastebin text in there. Rename the file to HealthPoint.lua (remove the .txt extension)
Test it by having the following code in your lunadll.lua file for your level:
Code: Select all local healthPoint = API.load("HealthPoint");
--healthPoint.healthbar = true; -- optional, use to activate healthbars above NPCs
for _,id in pairs(healthPoint.allNPCs) do
healthPoint.makeNPCNormal(id);
end
healthPoint.setNPCHealth(1, 3);
This makes a goomba (ID 1) take 3 hits to kill. All other enemies are unaffected.
I wish S1eths code was still available. Anyway, if we look past the problem that all npcs are assigned 3 health points by default by the HealthPoint API, it is also true that setNPCHealth cannot be called within the onLoop function. If you call it in the onLoad function it works well however, and healthPoint.setNPCHealth(1, 1) will make Goombas die after only one hit.
Hope this helps someone!
|
|
|
|
|
|
|
|
|
-
S1eth
- Bot

- Posts: 54
- Joined: Sat Apr 23, 2016 10:44 am
Postby S1eth » Mon Jun 27, 2016 6:31 pm
seiteom wrote:
I wish S1eths code was still available. Anyway, if we look past the problem that all npcs are assigned 3 health points by default by the HealthPoint API, it is also true that setNPCHealth cannot be called within the onLoop function. If you call it in the onLoad function it works well however, and healthPoint.setNPCHealth(1, 1) will make Goombas die after only one hit.
Hope this helps someone!
https://www.mediafire.com/?ue6293oz6dm7id3
|
|
|
|
|
|
|
|
|
-
Quantix
- Chain Chomp

- Posts: 333
- Joined: Tue Jan 26, 2016 5:04 pm
Postby Quantix » Mon Jun 27, 2016 7:57 pm
S1eth wrote:seiteom wrote:
I wish S1eths code was still available. Anyway, if we look past the problem that all npcs are assigned 3 health points by default by the HealthPoint API, it is also true that setNPCHealth cannot be called within the onLoop function. If you call it in the onLoad function it works well however, and healthPoint.setNPCHealth(1, 1) will make Goombas die after only one hit.
Hope this helps someone!
https://www.mediafire.com/?ue6293oz6dm7id3
I think you should put this in the PGE wiki.
|
|
|
|
|
|
|
|
|
-
aero
- Palom

- Posts: 4787
- Joined: Fri Mar 28, 2014 2:51 pm
Postby aero » Mon Jun 27, 2016 8:17 pm
I searched but couldn't find anywhere where this question was asked: Is it possible to have variables not reset in a luaworld.lua file when a level is loaded in an episode? When a new level is loaded the integer variables reset to 0 when they should be increasing as you play levels. Also, is it possible to save variable data and then load it? I'm not sure how limited my options are (or what my options even are.)
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Mon Jun 27, 2016 9:47 pm
AeroMatter wrote:I searched but couldn't find anywhere where this question was asked: Is it possible to have variables not reset in a luaworld.lua file when a level is loaded in an episode? When a new level is loaded the integer variables reset to 0 when they should be increasing as you play levels. Also, is it possible to save variable data and then load it? I'm not sure how limited my options are (or what my options even are.)
Use the Data class: http://wohlsoft.ru/pgewiki/Data_(class). A tutorial for it can be found here: http://wohlsoft.ru/pgewiki/How_To:_Using_the_data_class. The best way you can avoid variable resets that I can think of is to test one string of data to see if it's nil (if Data:get("stringkey") == nil then) and then only set the data if it is nil. If not, then you will know that you can access the held values from before. Not sure if it was a typo, but it's also lunaworld.lua and not luaworld.lua
|
|
|
|
|
|
|
|
|
-
LM280
- Monty Mole

- Posts: 121
- Joined: Wed Jan 15, 2014 7:10 pm
Postby LM280 » Mon Jun 27, 2016 10:17 pm
Spinda wrote:Looks like a fault on the API. Wind reported a similar problem on the irc, and the problem seems to be that it uses Graphics.placeSprite instead of Graphics.drawImage. You could probably update it on your end, but the API should hopefully be updated soon.
Do you know how you would do this? As far as I can tell it hasn't been updated, and I tried replacing all of the Graphics.placeSprite with Graphics.drawImage and that just gave me an error.
|
|
|
|
|
|
|
|
|
-
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 » Mon Jun 27, 2016 10:27 pm
I'm trying to do a small trick : when an event is called, the player will be killed.
Code: Select all function onEvent()
if calledEvent =="KILLPlayer" then
player:kill()
end
end
This code doesn't give me any errors but this code doesn't work :/
halp
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Mon Jun 27, 2016 10:55 pm
You have to put calledEvent between the first pair of parenthesis.
|
|
|
|
|
|
|
|
|
-
aero
- Palom

- Posts: 4787
- Joined: Fri Mar 28, 2014 2:51 pm
Postby aero » Tue Jun 28, 2016 12:00 am
PixelPest wrote:AeroMatter wrote:I searched but couldn't find anywhere where this question was asked: Is it possible to have variables not reset in a luaworld.lua file when a level is loaded in an episode? When a new level is loaded the integer variables reset to 0 when they should be increasing as you play levels. Also, is it possible to save variable data and then load it? I'm not sure how limited my options are (or what my options even are.)
Use the Data class: http://wohlsoft.ru/pgewiki/Data_(class). A tutorial for it can be found here: http://wohlsoft.ru/pgewiki/How_To:_Using_the_data_class. The best way you can avoid variable resets that I can think of is to test one string of data to see if it's nil (if Data:get("stringkey") == nil then) and then only set the data if it is nil. If not, then you will know that you can access the held values from before. Not sure if it was a typo, but it's also lunaworld.lua and not luaworld.lua
This guide kind of helped, as I was able to save my variable data. It's not exactly clear how I can save multiple variables though.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Tue Jun 28, 2016 3:09 am
AeroMatter wrote:
This guide kind of helped, as I was able to save my variable data. It's not exactly clear how I can save multiple variables though.
You can just uh... save multiple variables?
The "set" function takes a key and a value, so you can save two different keys to store two different values, and use the "get" function with the key you used to get individual values back.
|
|
|
|
|
|
|
|
|
-
Reign
- Chain Chomp

- Posts: 327
- Joined: Tue Jan 21, 2014 4:22 am
Postby Reign » Tue Jun 28, 2016 3:53 am
Two issues I'm struggling with.
a) Reversed controls, meaning when the player presses right key, the character moves left and vice versa.
if(player.leftKeyPressing) then
player.leftKeyPressing = false;
player.rightKeyPressing = true;
end
if(player.rightKeyPressing) then
player.rightKeyPressing = false;
player.leftKeyPressing = true;
end
This doesn't seem to work as the player always goes left no matter which key you press.
b) A victory sound when the level ends
The level ends with a door warp which you need a key for. I currently have this set up in a way that once the key "dies", an event with a sound will occur. This works fine, however when the player throws the key to lava for example, the victory sound also plays. Another thing is when you play as Link, the sound plays immediately when you collect the key, not when you use it at the door.
So I was wondering if this victory sound when you enter a door could be done with LunaLua?
|
|
|
|
|
|
|
|
|
-
S1eth
- Bot

- Posts: 54
- Joined: Sat Apr 23, 2016 10:44 am
Postby S1eth » Tue Jun 28, 2016 4:03 am
Reign wrote:Two issues I'm struggling with.
a) Reversed controls, meaning when the player presses right key, the character moves left and vice versa.
if(player.leftKeyPressing) then
player.leftKeyPressing = false;
player.rightKeyPressing = true;
end
if(player.rightKeyPressing) then
player.rightKeyPressing = false;
player.leftKeyPressing = true;
end
This doesn't seem to work as the player always goes left no matter which key you press.
You want to replace "end if" with "elseif".
Currently, you are turning all LEFT into RIGHT. And then, you are turning all RIGHT into LEFT., which includes all the LEFT which were just turned into RIGHT.
But what you want is: if X then Y elseif Y then X.
For your other issue, you will probably need lua for that. The thing is that your "key dies" trigger condition is not really what you want, since as you said, the key dies when Link picks it up.
If your door has a lock (bg object), you can check if the lock doesn't exist anymore with lua during onTick() and make that your trigger,
or check if the player with key collides with the locked door.
|
|
|
|
|
|
|
|
|
-
Reign
- Chain Chomp

- Posts: 327
- Joined: Tue Jan 21, 2014 4:22 am
Postby Reign » Tue Jun 28, 2016 7:39 am
S1eth wrote:For your other issue, you will probably need lua for that. The thing is that your "key dies" trigger condition is not really what you want, since as you said, the key dies when Link picks it up.
If your door has a lock (bg object), you can check if the lock doesn't exist anymore with lua during onTick() and make that your trigger,
or check if the player with key collides with the locked door.
The reverse control works now, thank you!
Do you have an example (or could you point me to the right direction) on how you would check if a lock does not exist in the level anymore?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Jun 28, 2016 7:43 am
Reign wrote:S1eth wrote:For your other issue, you will probably need lua for that. The thing is that your "key dies" trigger condition is not really what you want, since as you said, the key dies when Link picks it up.
If your door has a lock (bg object), you can check if the lock doesn't exist anymore with lua during onTick() and make that your trigger,
or check if the player with key collides with the locked door.
The reverse control works now, thank you!
Do you have an example (or could you point me to the right direction) on how you would check if a lock does not exist in the level anymore?
You could check to see if the number of instances of that NPC is nil (or it might be 0, not exactly sure) or you could set a Death event for that NPC and check if the event has been triggered via LunaLua
|
|
|
|
|
|
|
|
|
-
Reign
- Chain Chomp

- Posts: 327
- Joined: Tue Jan 21, 2014 4:22 am
Postby Reign » Tue Jun 28, 2016 8:57 am
Hmm, thanks for the advice but I'm at a dead end again.  I tried something like
function onTick()
Text.print(tostring(BGO.count()), 0, 0)
if(BGO.count() == 51) then
triggerEvent("Exit level");
end
end
The idea is that I have 52 BGOs in the level and once the lock disappears there should be 51. However, once the lock disappears there still seems to be 52 BGOs in the level (I made the text.print to check that). The lock is not an NPC afaik so I'm not sure if a death event can be made for it. Or am I mistaken on that?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Tue Jun 28, 2016 9:03 am
Reign wrote:Hmm, thanks for the advice but I'm at a dead end again.  I tried something like
function onTick()
Text.print(tostring(BGO.count()), 0, 0)
if(BGO.count() == 51) then
triggerEvent("Exit level");
end
end
The idea is that I have 52 BGOs in the level and once the lock disappears there should be 51. However, once the lock disappears there still seems to be 52 BGOs in the level (I made the text.print to check that). The lock is not an NPC afaik so I'm not sure if a death event can be made for it. Or am I mistaken on that?
Oh sorry. I thought you were referring to the blockade NPC that you stick a key in and then it disappears, allowing you to pass
|
|
|
|
|
|
|
|
|
-
aero
- Palom

- Posts: 4787
- Joined: Fri Mar 28, 2014 2:51 pm
Postby aero » Tue Jun 28, 2016 10:57 am
Hoeloe wrote:AeroMatter wrote:
This guide kind of helped, as I was able to save my variable data. It's not exactly clear how I can save multiple variables though.
You can just uh... save multiple variables?
The "set" function takes a key and a value, so you can save two different keys to store two different values, and use the "get" function with the key you used to get individual values back.
I didn't know that, thanks.
|
|
|
|
|
|
|
|
|
-
Mario_and_Luigi_55
- Spike

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
Postby Mario_and_Luigi_55 » Tue Jun 28, 2016 12:20 pm
Would it be possible to make a health bar like on this picture:

for both player and a boss?
|
|
|
|
|
|
|
|
|
-
h2643
- Reznor

- Posts: 2890
- Joined: Sat Dec 21, 2013 7:23 am
-
Contact:
Postby h2643 » Tue Jun 28, 2016 12:28 pm
There's a boss in 2k16 VVinter Redemption that has a health bar, so yes.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 2 guests
|