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?
|
|
|
|
-
Zant
- Volcano Lotus

- Posts: 570
- Joined: Sat Dec 21, 2013 2:58 pm
Postby Zant » Fri Apr 29, 2016 12:43 pm
Is it possible to create a portal system(like in Mari0)with LunaLua?
|
|
|
|
|
|
|
|
|
-
lotus006
- Mega Mole

- Posts: 284
- Joined: Thu Sep 24, 2015 12:59 am
Postby lotus006 » Fri Apr 29, 2016 1:37 pm
Zant wrote:Is it possible to create a portal system(like in Mari0)with LunaLua?
That's why I asked about to link boundaries to a block if this possible and how I can do this :S
I mean on an earlier post or thread not sure wich one :S
|
|
|
|
|
|
|
|
|
-
Enjl
- Cute Yoshi Egg

- Posts: 7622
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Orphion Egamalenitar Osmos IV, Esq.
Postby Enjl » Fri Apr 29, 2016 1:39 pm
lotus006 wrote:Zant wrote:Is it possible to create a portal system(like in Mari0)with LunaLua?
That's why I asked about to link boundaries to a block if this possible and how I can do this :S
I mean on an earlier post or thread not sure wich one :S
Keep in mind that you have to essentially get rid of collision for the blocks where the portals are on. Making the player show on both ends can be troublesome, too.
|
|
|
|
|
|
|
|
|
-
Mario_and_Luigi_55
- Mega Mole

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
- Current Project: Super Mario Bros Adventure
Postby Mario_and_Luigi_55 » Sat Apr 30, 2016 7:17 am
Can I make check if player touches ice block?
I have that:
Code: Select all timerApi.setSecondsLeft(timerApi.getSecondsLeft()-3)
and I want to reduce time every time that player touches ice block.
|
|
|
|
|
|
|
|
|
-
S1eth
- Spiny

- Posts: 54
- Joined: Sat Apr 23, 2016 10:44 am
Postby S1eth » Sat Apr 30, 2016 7:34 am
Mario_and_Luigi_55 wrote:Can I make check if player touches ice block?
I have that:
Code: Select all timerApi.setSecondsLeft(timerApi.getSecondsLeft()-3)
and I want to reduce time every time that player touches ice block.
You can use (Block.collidesWith(player) > 0) to check if a player touches a block.
Code: Select all for _,iceblock in pairs(Block.get(put_Ice_block_id_here) do
if (iceblock.collidesWith(player) > 0) then
--do stuff
end
end
EDIT: iceblock:collidesWith ( : instead of . )
You need: http://wohlsoft.ru/pgewiki/Block_%28class%29 and http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions
Now, this would be put into onTick or onLoop.
If you don't want to reduce the timer every frame the player touches the block, you'll need to remember which block the player has touched.
I don't think blocks have some kind of unique id for you to access, so you'd have to get some other unique information, such as the block's x and y coordinates and save them in a table. (doesn't work with moving layers)
Or if you have a very limited number of blocks, you could put each block on their own layer and use the layer to identify the block.
Or you create "invincibility frames" in which your timer cannot be reduced which lasts X ticks after touching an ice block.
Or do you mean ice blocks as in NPCs turned into ice?
Last edited by S1eth on Sat Apr 30, 2016 8:06 am, edited 1 time in total.
|
|
|
|
|
|
|
|
|
-
Mario_and_Luigi_55
- Mega Mole

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
- Current Project: Super Mario Bros Adventure
Postby Mario_and_Luigi_55 » Sat Apr 30, 2016 7:54 am
S1eth wrote:Mario_and_Luigi_55 wrote:Can I make check if player touches ice block?
I have that:
Code: Select all timerApi.setSecondsLeft(timerApi.getSecondsLeft()-3)
and I want to reduce time every time that player touches ice block.
You can use (Block.collidesWith(player) > 0) to check if a player touches a block.
Code: Select all for _,iceblock in pairs(Block.get(put_Ice_block_id_here) do
if (iceblock.collidesWith(player) > 0) then
--do stuff
end
end
You need: http://wohlsoft.ru/pgewiki/Block_%28class%29 and http://wohlsoft.ru/pgewiki/LunaLua_glob ... _functions
Now, this would be put into onTick or onLoop.
If you don't want to reduce the timer every frame the player touches the block, you'll need to remember which block the player has touched.
I don't think blocks have some kind of unique id for you to access, so you'd have to get some other unique information, such as the block's x and y coordinates and save them in a table. (doesn't work with moving layers)
Or if you have a very limited number of blocks, you could put each block on their own layer and use the layer to identify the block.
Or you create "invincibility frames" in which your timer cannot be reduced which lasts X ticks after touching an ice block.
Or do you mean ice blocks as in NPCs turned into ice?
Code:
Code: Select all function onLoopSection0()
local odlicz=0
Text.print(odlicz,0,0)
for e,f in pairs(Block.get(633)) do
if (f.collidesWith(player)> 0) then
if odlicz == 0 then
timerApi.setSecondsLeft(timerApi.getSecondsLeft()-3)
odlicz=300
else
odlicz=odlicz-1
end
end
end
end
gives me this:

|
|
|
|
|
|
|
|
|
-
underFlo
- Mario

- Posts: 4481
- Joined: Mon Jul 14, 2014 10:44 am
- Flair: sup im lesbiab
- Current Project: actually nothing i lied to you
- Chat Username: underFlo
-
Contact:
Postby underFlo » Sat Apr 30, 2016 7:57 am
collidesWith is a method, so you need to write it with a colon (':') instead of a period ('.'), so it's f:collidesWith(player). Also, I recommend giving all your variables English names, as it makes your code far more comprehensible for other people.
im a girl yo
|
|
|
|
|
|
|
|
|
-
S1eth
- Spiny

- Posts: 54
- Joined: Sat Apr 23, 2016 10:44 am
Postby S1eth » Sat Apr 30, 2016 8:17 am
What Spinda said. I did this quickly and obviously without testing.
object:function() is just syntactic sugar for object.function(object), and collidesWith requires two parameters (the block, and the player).
Code: Select all for e,f in pairs(Block.get(633)) do
As a general recommendation: e,f is your (key, value) pair. Typically written as "k, v".
If you do not use the 'key' in your code, it is common to store it in "_", so: for _,v in pairs(.....) do
Then, everyone who reads your code knows that they can ignore that variable.
As for "f", you should just name it "v" for value, or name it after the type of object you are working with, in this case "block" or "iceblock".
Last edited by S1eth on Sat Apr 30, 2016 9:06 am, edited 2 times in total.
|
|
|
|
|
|
|
|
|
-
Mario_and_Luigi_55
- Mega Mole

- Posts: 270
- Joined: Sat Feb 27, 2016 12:01 pm
- Current Project: Super Mario Bros Adventure
Postby Mario_and_Luigi_55 » Sat Apr 30, 2016 8:33 am
S1eth wrote:What Spinda said. I did this quickly and obviously without testing.
object:function() is just syntactic sugar for object.function(object), and collidesWith requires two parameters (the block, and the player).
Code: Select all for e,f in pairs(Block.get(633)) do
As a generation recommendation: e,f is your (key, value) pair. Typically written as "k, v".
If you do not use the 'key' in your code, it is common to store it in "_" for it, so: for _,v in pairs(.....) do
Then, everyone who reads your code knows that they can ignore that variable.
As for "f", you should just name it "v" for value, or name it after the type of object you are working with, in this case "block" or "iceblock".
That's my whole code, so e,f aren't just random:
Code: Select all local bloki = { 80, 81, 82, 83, 84, 85, 86, 87, 263, 264, 265, 266, 273, 299, 300, 301, 302, 303, 304, 309, 310, 616, 617, 618, 619 }
timerApi = loadAPI("leveltimer");
local particles = API.load("particles");
local odlicz = 0
function onTick()
for a, b in pairs (Block.get(bloki)) do
b.slippery = true
end
for c, d in pairs (NPC.get(9,-1)) do
d.id = 185
end
end
function onLoad()
timerApi.setSecondsLeft(300);
timerApi.setTimerState(true);
end
local effect = particles.Emitter(0, 0, Misc.resolveFile("particles\\p_snow.ini"));
effect:AttachToCamera(Camera.get()[1]);
function onCameraUpdate()
effect:Draw();
end
function onLoopSection0()
Text.print(odlicz,0,0)
for e,f in pairs(Block.get(633)) do
if (f:collidesWith(player) > 0) then
if odlicz == 0 then
timerApi.setSecondsLeft(timerApi.getSecondsLeft()-5)
odlicz=50
else
odlicz=odlicz-1
end
end
end
end
I'm waiting for you to say that the variables aren't in English. I have a link that may help: translate.google.com
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Grinder

- Posts: 1055
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Current Project: A2XT Episode 2
Postby Hoeloe » Sat Apr 30, 2016 9:03 am
Mario_and_Luigi_55 wrote:
That's my whole code, so e,f aren't just random:
Those variables only exist inside the loop. There's no reason to give them unique names because the variable "a", for example, doesn't exist outside the loop it's used in anyway.
Plus, since you aren't using the keys, it's clearer to use _,v instead.
|
|
|
|
|
|
|
|
|
-
underFlo
- Mario

- Posts: 4481
- Joined: Mon Jul 14, 2014 10:44 am
- Flair: sup im lesbiab
- Current Project: actually nothing i lied to you
- Chat Username: underFlo
-
Contact:
Postby underFlo » Sat Apr 30, 2016 8:32 pm
Mario_and_Luigi_55 wrote:I'm waiting for you to say that the variables aren't in English. I have a link that may help: translate.google.com
Like honestly if comprehension of your code requires using Google translate for literally every variable then that's just bad programing practice.
im a girl yo
|
|
|
|
|
|
|
|
|
-
WerewolfGD
- Wart

- Posts: 3256
- Joined: Tue Dec 02, 2014 2:28 am
- Flair: Daily life of Alagirez
- Current Project: Questioning my life
- Chat Username: Alagirez
-
Contact:
Postby WerewolfGD » Sun May 01, 2016 5:12 am
Zant wrote:Is it possible to create a portal system(like in Mari0)with LunaLua?
I usually do that trick with Simple filters with a portal graphic and "function onEvent" code.
Yep, it's possible.
|
|
|
|
|
|
|
|
|
-
pal4
- Fighter Fly

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Mon May 02, 2016 4:45 pm
Enjl wrote:You make a file with the extension .lua
How do I do that?
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Grinder

- Posts: 1055
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Current Project: A2XT Episode 2
Postby Hoeloe » Mon May 02, 2016 5:59 pm
pal4 wrote:Enjl wrote:You make a file with the extension .lua
How do I do that?
1. Right click where you want to make the file.
2. Select "New >Text Document"
3. A file will appear named "New Text Document.txt" (see note)
4. Rename the file to "lunadll.lua"
NOTE: If the file is called "New Text Document", and does not have ".txt" on the end, you may have to right click, and go to the folder properties to make sure the file extensions are not hidden, otherwise you can end up with "lunadll.lua.txt", which will not work.
Alternatively, open Notepad, and go to File > Save. From the dropdown menu, make sure "All Files" is selected (NOT "Text Document"), and save the empty file as lunadll.lua.
|
|
|
|
|
|
|
|
|
-
Zant
- Volcano Lotus

- Posts: 570
- Joined: Sat Dec 21, 2013 2:58 pm
Postby Zant » Wed May 04, 2016 8:48 am
I want to have a background with five bg layers how do I do dis?
|
|
|
|
|
|
|
|
|
-
Reign
- Mega Mole

- Posts: 298
- Joined: Tue Jan 21, 2014 4:22 am
- Current Project: On a break from projects.
Postby Reign » Thu May 05, 2016 3:52 am
Just starting with Lua and I've finally gotten it to work.
Now I'm wondering how to properly trigger events? Looking at the tutorial didn't make me smarter and I ended up getting errors. So if I want to trigger the event "Toggle Blue" every time the player jumps, what should I put in here?
function onJump()
???
end
|
|
|
|
|
|
|
|
|
-
Reign
- Mega Mole

- Posts: 298
- Joined: Tue Jan 21, 2014 4:22 am
- Current Project: On a break from projects.
Postby Reign » Thu May 05, 2016 5:22 am
Thanks, but I actually already tried that. I'm afraid I'm going to need some dumbing down to get this to work.
function onJump()
triggerEvent(Toggle Blue)
end
|
|
|
|
|
|
|
|
|
-
Enjl
- Cute Yoshi Egg

- Posts: 7622
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Orphion Egamalenitar Osmos IV, Esq.
Postby Enjl » Thu May 05, 2016 5:25 am
Familiarise yourself with the basics of programming in lua. Strings have to be put in "".
triggerEvent("Toggle Blue")
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 1 guest
|