Page 15 of 47
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Fri Sep 04, 2015 12:25 am
by Wohlstand
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
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Fri Sep 04, 2015 12:48 am
by PersonNamedUser
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.
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Fri Sep 04, 2015 1:34 am
by Wohlstand
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
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sat Sep 05, 2015 3:02 pm
by UninspiredUsername
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?
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sat Sep 05, 2015 10:36 pm
by cramps-man
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.
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sat Sep 05, 2015 10:51 pm
by UninspiredUsername
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?
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sun Sep 06, 2015 3:27 am
by Kevsoft
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.:
and in the other code file:
Code: Select all
local myVariableFromGlobal = _G["myGlobalVariable"]
Please note that lunaworld.lua is loaded
before lunadll.lua
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sun Sep 06, 2015 12:50 pm
by UninspiredUsername
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?
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sun Sep 06, 2015 12:58 pm
by Kevsoft
UninspiredUsername wrote:
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.
Re: LunaLua Offical Thread [Streaming Question Poll]
Posted: Sun Sep 06, 2015 2:20 pm
by UninspiredUsername
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Sep 12, 2015 7:02 pm
by FanofSMBX
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?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Sep 12, 2015 8:13 pm
by UninspiredUsername
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?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Sep 13, 2015 1:40 am
by Kevsoft
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Sep 13, 2015 3:22 pm
by UninspiredUsername
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Sep 13, 2015 8:05 pm
by Axiom
add an if(table.getn(tableOfHammers) > 0) around the for loop and you'll be fine
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sun Sep 13, 2015 9:05 pm
by UninspiredUsername
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.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Tue Sep 15, 2015 8:18 pm
by HenryRichard
Has the PlayerSettings class been implemented yet, or am I using it wrong, or is it just someone trying to troll me?
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Wed Sep 16, 2015 12:08 am
by Kevsoft
Sorry, it is still WIP.
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Sep 19, 2015 12:29 pm
by Kevsoft
LunaLua v0.7.1.1 is out with following changes:
* 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
Re: LunaLua Offical Thread - SMBX Usermod Framework
Posted: Sat Sep 26, 2015 8:27 am
by PixelPest
Which do I download--Hexed or Vanilla + Launcher?