LunaLua Offical Thread - SMBX Usermod Framework

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?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
Wohlstand
Van De Graf
Van De Graf
Posts: 2008
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby Wohlstand » Fri Sep 04, 2015 12:25 am

SuperMario12345 wrote:Does anyone know how to fix this code?
I want to make it where when you pick up a key a phanto chases you.

Code: Select all

local player = Player();

function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true noSmoke)
	  Phanto Chasing:show(true noSmoke))
      end
   end
end

Code: Select all

local player = Player();
local Phanto = .... -- here must me a construction of the layer pointer
local PhantoChasing = .... -- same
function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true)
	  PhantoChasing:show(true)
      else
          Phanto:show(true)
	  PhantoChasing:hide(true)
      end
   end
end

PersonNamedUser
Birdo
Birdo
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby PersonNamedUser » Fri Sep 04, 2015 12:48 am

Wohlstand wrote:
SuperMario12345 wrote:Does anyone know how to fix this code?
I want to make it where when you pick up a key a phanto chases you.

Code: Select all

local player = Player();

function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true noSmoke)
	  Phanto Chasing:show(true noSmoke))
      end
   end
end

Code: Select all

local player = Player();
local Phanto = .... -- here must me a construction of the layer pointer
local PhantoChasing = .... -- same
function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true)
	  PhantoChasing:show(true)
      else
          Phanto:show(true)
	  PhantoChasing:hide(true)
      end
   end
end
What's a layer pointer?

Edit:
I would use this code but it gives my game severe lag.

Wohlstand
Van De Graf
Van De Graf
Posts: 2008
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby Wohlstand » Fri Sep 04, 2015 1:34 am

SuperMario12345 wrote:
Wohlstand wrote:
SuperMario12345 wrote:Does anyone know how to fix this code?
I want to make it where when you pick up a key a phanto chases you.

Code: Select all

local player = Player();

function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true noSmoke)
	  Phanto Chasing:show(true noSmoke))
      end
   end
end

Code: Select all

local player = Player();
local Phanto = .... -- here must me a construction of the layer pointer
local PhantoChasing = .... -- same
function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
	  Phanto:hide(true)
	  PhantoChasing:show(true)
      else
          Phanto:show(true)
	  PhantoChasing:hide(true)
      end
   end
end
What's a layer pointer?

Edit:
I would use this code but it gives my game severe lag.
I wrote to you partial code and wrote comments where you SHOULD modify to make everything working + I was on smartphone
Now I'm on job workstation and I finished that part which you can try out. If some mistakes you will found, fix them

Code: Select all

local player = Player();
local Phanto = Layer.get("Phanto")
local PhantoChasing = Layer.get("Phanto Chasing ")
local holding = false
function onLoop()
   if(player.holdingNPC ~= nil) then
      if(player.holdingNPC.id == 31) then
          if(holding==false) then
	         Phanto:hide(true)
	         PhantoChasing:show(true)
                 holding=true
          end
      else
          if(holding==true) then
               Phanto:show(true)
	       PhantoChasing:hide(true)
               holding=false
          end
      end
   end
end

UninspiredUsername
Guest

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby UninspiredUsername » Sat Sep 05, 2015 3:02 pm

Few quick questions. Do custom functions defined in one level's lunadll.lua file work when called in another level's lunadll.lua file? If so, what are the mechanics of this? If not, how would you define a function that does? When deleting save files, do you have to delete any other files?

cramps-man
Koopa
Koopa
Posts: 15
Joined: Tue Dec 24, 2013 1:13 pm

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby cramps-man » Sat Sep 05, 2015 10:36 pm

UninspiredUsername wrote:Few quick questions. Do custom functions defined in one level's lunadll.lua file work when called in another level's lunadll.lua file? If so, what are the mechanics of this? If not, how would you define a function that does? When deleting save files, do you have to delete any other files?
No they do not. Which is why there are API's which are stored in the LuaScriptsLib folder. You can read on how to make and use one here. http://engine.wohlnet.ru/pgewiki/How_To ... custom_API

Also you mean the game save files for slot 1-3? If so, then no need to delete anything else.

UninspiredUsername
Guest

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby UninspiredUsername » Sat Sep 05, 2015 10:51 pm

cramps-man wrote:No they do not. Which is why there are API's which are stored in the LuaScriptsLib folder. You can read on how to make and use one here. http://engine.wohlnet.ru/pgewiki/How_To ... custom_API

Also you mean the game save files for slot 1-3? If so, then no need to delete anything else.
That's a bit odd, because I'm pretty sure variables defined without the "local" keyword will work across all files in a world (which can and will screw you up if you don't know what your doing, like me!)
Also, are global variables somehow stored inside the save file (or some other way?), or are they just thrown out when you quit the game?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby Kevsoft » Sun Sep 06, 2015 3:27 am

UninspiredUsername wrote:
cramps-man wrote:No they do not. Which is why there are API's which are stored in the LuaScriptsLib folder. You can read on how to make and use one here. http://engine.wohlnet.ru/pgewiki/How_To ... custom_API

Also you mean the game save files for slot 1-3? If so, then no need to delete anything else.
That's a bit odd, because I'm pretty sure variables defined without the "local" keyword will work across all files in a world (which can and will screw you up if you don't know what your doing, like me!)
Also, are global variables somehow stored inside the save file (or some other way?), or are they just thrown out when you quit the game?
LunaLua code gets reseted every new level. So if you want to keep data between levels you must use the data class: http://engine.wohlnet.ru/pgewiki/Data_%28class%29

If you want to access variables between lunaworld.lua and lunadll.lua you must use the _G table, i.e.:

Code: Select all

_G["myGlobalVariable"] = 5
and in the other code file:

Code: Select all

local myVariableFromGlobal = _G["myGlobalVariable"]
Please note that lunaworld.lua is loaded before lunadll.lua

UninspiredUsername
Guest

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby UninspiredUsername » Sun Sep 06, 2015 12:50 pm

Kevsoft wrote: LunaLua code gets reseted every new level. So if you want to keep data between levels you must use the data class: http://engine.wohlnet.ru/pgewiki/Data_%28class%29
If you use the data class, will it work across play sessions? And if so, does the player have to save the game for it to work across play sessions?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby Kevsoft » Sun Sep 06, 2015 12:58 pm

UninspiredUsername wrote:
Kevsoft wrote: LunaLua code gets reseted every new level. So if you want to keep data between levels you must use the data class: http://engine.wohlnet.ru/pgewiki/Data_%28class%29
If you use the data class, will it work across play sessions? And if so, does the player have to save the game for it to work across play sessions?
You can make the data class "saveslot-local" or global across saveslots.

UninspiredUsername
Guest

Re: LunaLua Offical Thread [Streaming Question Poll]

Postby UninspiredUsername » Sun Sep 06, 2015 2:20 pm

Kevsoft wrote: You can make the data class "saveslot-local" or global across saveslots.
Yeah, I found out about that after re-reading some of the documentation. Sorry If I was a bit ambiguous, but what I meant was that I'm afraid that if I write something to a saveslot-local data class and the player quits the game without saving, to the player, the game will have acted like the lunalua aspects of the game saved anyway, even though the vanilla aspects didn't. If not handled correctly, this could potentially turn out really weird for episodes that use something like say, switch palaces for example. Like the player could save the game before the switch palace, beat the switch palace, quit the game, and even though the palace was (according to the save file) never beaten, the blocks that rely on the switch palace will be activated anyway.

FanofSMBX
Mouser
Mouser
Posts: 3878
Joined: Sun Dec 22, 2013 12:01 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby FanofSMBX » Sat Sep 12, 2015 7:02 pm

Would it be possible to have multiple kinds of hammer bros in the same level? Like one who throws hammers, one for shells, one for Goombas etc.? Or is it only 1 type per level?

UninspiredUsername
Guest

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby UninspiredUsername » Sat Sep 12, 2015 8:13 pm

FanofSMBX wrote:Would it be possible to have multiple kinds of hammer bros in the same level? Like one who throws hammers, one for shells, one for Goombas etc.? Or is it only 1 type per level?
Probably. How are you changing what item the hammer brother throws in the first place?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Sun Sep 13, 2015 1:40 am

UninspiredUsername wrote:
FanofSMBX wrote:Would it be possible to have multiple kinds of hammer bros in the same level? Like one who throws hammers, one for shells, one for Goombas etc.? Or is it only 1 type per level?
Probably. How are you changing what item the hammer brother throws in the first place?
Generally by modifying the id of the npc. So every new hammer is transformed to a new one, which means that you cannot have any hammers in your level.

UninspiredUsername
Guest

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby UninspiredUsername » Sun Sep 13, 2015 3:22 pm

Kevsoft wrote:Generally by modifying the id of the npc. So every new hammer is transformed to a new one, which means that you cannot have any hammers in your level.
Let me see if I can get something working that allows you to change that on a per section or per area basis.

Here's something i whipped up real quick:

Code: Select all

--To change hammers into an npc of the given id on a per-section basis (or whole level)
function swapHammers(npcID, sections)
	sections = sections or -1 --if sections is nil, make it -1
	local tableOfHammers = NPC.get(30, sections);

	for i = 1, table.getn(tableOfHammers) do
		tableOfHammers[i].id = npcID;
	end
end

--To change on a per area basis
function swapHammersIntersecting(npcID, x1, y1, x2, y2) --WARNING: don't make areas too close
	local tableOfNPCs = NPC.getIntersecting(x1, y1, x2, y2);

	for i = 1, table.getn(tableOfNPCs) do
		if tableOfNPCs[i].id == 30 then
			tableOfNPCs[i].id = npcID;
		end
	end
end

--Whichever comes first in onLoop function will take priority
I tested it, and it'll work as long as you don't use an npc that can hurt the hammer brother.

Axiom
Foo
Foo
Posts: 1471
Joined: Tue Dec 24, 2013 2:23 pm

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Axiom » Sun Sep 13, 2015 8:05 pm

add an if(table.getn(tableOfHammers) > 0) around the for loop and you'll be fine

UninspiredUsername
Guest

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby UninspiredUsername » Sun Sep 13, 2015 9:05 pm

Axiom wrote:add an if(table.getn(tableOfHammers) > 0) around the for loop and you'll be fine
I know that's supposed to prevent crashes but for some reason the crash never happened, even when there was no hammers.

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby HenryRichard » Tue Sep 15, 2015 8:18 pm

Has the PlayerSettings class been implemented yet, or am I using it wrong, or is it just someone trying to troll me?

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Wed Sep 16, 2015 12:08 am

Sorry, it is still WIP.

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Sat Sep 19, 2015 12:29 pm

LunaLua v0.7.1.1 is out with following changes:
Spoiler: show
* Added comparing operator for some LunaLua classes.
* Added PlayerSettings-Class
* Added PNG support for custom level items (i.e. npc-1.png)
* Fixed screenshot-function (With changes: PNG-Format and filename is now date + time)
* Added experimental gif recorder using FreeImage library. Can be toggled with F11. Don't record for too long or it may crash due to memory overflow (too much frames to encode)
* Added Graphics.isOpenGLEnabled() for checking if the new renderer is active.
* Replacing WIC-functions with FreeImage
* Added Level class for overworld
Unfortunatly the zip packer system broke, so here is a direct-link to the new update: https://dl.dropboxusercontent.com/u/457 ... 20BETA.zip

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: LunaLua Offical Thread - SMBX Usermod Framework

Postby PixelPest » Sat Sep 26, 2015 8:27 am

Which do I download--Hexed or Vanilla + Launcher?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari