LunaLua Offical Thread

Description: Archive discussion
============================
Original description:
Official subforum for LunaLua - an extension framework for SMBX Engine Version 1.3 (which a core of SMBX 2.0). Share your creations that require the use of LunaLUA. You may also share info/tutorials on how to use LunaLUA.

Shall I stream some LunaLua live development?

Yes
15
tb1024, h2643, hacheipe399, Wohlstand, cramps-man, Lotus006, wes, Saronin, Super Mario Player, 9th_core, MomsResetti, S.Koopa0, 5438ASPGE71
100%
No
2
Toshiie, 6824
13%
 
Total voters: 15
Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #81by Kevsoft » 27 Dec 2014, 12:57

Sambo wrote:Yes, it still hides the HUD and I can get the PrintText function to work. But the image codes don't work.
Mhh.... could you send me your level with the code and images or at least the code and images?

Anyway:
Image


LunaLua is now v0.5 BETA. We can now run code in the overworld YAY!
To run your code for the overworld make a file called "lunaoverworld.lua" in your episode dir.

Following events can be used for the world:
Spoiler
* onLoad
* onLoop
Following functions can be used for the world:
Spoiler
* windowDebug
* printText
* loadImage
* placeSprite
* mem
Classes are not supported yet!

A small Q&A to that:
Spoiler
Q: Can we run Autocode (lunadll.txt).
A: No you can only run lua code.

Q: Could you implement Autocode for overworld?
A: I could, but it would take way too long time. If kil does it then I am fine.

Q: Can we deactivate the world HUD?
A: No (maybe later), but the render code is the last painting code which is called. So you can overdraw everything if you want to.

Q: Why BETA?
A: There might be some bugs floating. If you have any issues please report them to me!
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

hacheipe399 M
Honourable citizen
Honourable citizen
Avatar
hacheipe399 M
Honourable citizen
Honourable citizen
Age: 24
Reputation: 14
Posts: 45
Joined: 24 Feb 2014

Post #82by hacheipe399 » 27 Dec 2014, 17:39

Good work!
I listen to energic music:
All kinds of metal.
Electronic music: Hard House, Hardstyle, Hardcore, Frenchcore, Terrorcore and anything that with ends in -core.
Best track of 2018: Cryogenic - Mot3rf$ck3r (wear earprotection when listenting to this).

I hope to be a major contributor of PGE when I'm more advanced in my engineering.

Veudekato M
Viscount
Viscount
Avatar
Veudekato M
Viscount
Viscount
Reputation: 79
Posts: 369
Joined: 19 Feb 2014
Location: Russia

Post #83by Veudekato » 27 Dec 2014, 19:34

hacheipe399 wrote:Good work!
Please in next time be more constructive..or something like that

Anyways, where i can find good lua tutorial for russian, i need to know lua ,for making lunalua
My channel (PlatGEnWohl news and tutorials , smbx tests):
http://www.youtube.com/channel/UC6h-42umT14iR1wa3VkOs3Q

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #84by Sambo » 28 Dec 2014, 0:25

Kevsoft wrote:
Sambo wrote:Yes, it still hides the HUD and I can get the PrintText function to work. But the image codes don't work.
Mhh.... could you send me your level with the code and images or at least the code and images?
https://www.sendspace.com/file/h7wshi
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #85by Kevsoft » 28 Dec 2014, 10:07

Okay, I just noticed that you are missing a HUD folder!

This code should work:

Code: Select all

function onLoad()
  loadImage ("HUD/hud.bmp", 1, 0xdc00ff);
  placeSprite (1, 1, 174, 8)
  hud(false)
end
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #86by Sambo » 29 Dec 2014, 23:45

I just tried that, and it still won't load the images. I'll try downloading v 0.5 and see if it works.
Also, the HUD code only works if it's placed under the onLoop function.

EDIT:Just downloaded v 0.5, and it finally works now. How do you type in the filename to go BACK a directory? I have the codes in the lunaworld file, but it still starts from the level's CGFX folder. I would like to go back a directory so I don't have to create a copy of my HUD image for each level.
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #87by Kevsoft » 30 Dec 2014, 9:44

simple do "../HUD/yourImg.bmp"

Added after 6 hours 45 minutes:
And here is the first LunaLua update for the overworld adding now the world class!
Example Code:
Spoiler

Code: Select all

function onLoop()
   local output = ""
   if world.playerIsCurrentWalking then
      output = output .. "Running "
   else
      output = output .. "Looking "
   end
   
   if world.playerCurrentDirection == ODIR_UP then
      output = output .. "Up"
   elseif world.playerCurrentDirection == ODIR_LEFT then
      output = output .. "Left"
   elseif world.playerCurrentDirection == ODIR_DOWN then
      output = output .. "Down"
   elseif world.playerCurrentDirection == ODIR_RIGHT then
      output = output .. "Right"
   end
   
   printText(output, 10, 10)
   if world.levelTitle then
      printText("Current Level: "..world.levelTitle.str, 10, 30)
   end
end

Changes for LunaLua 0.5.2:
Spoiler
* Added world class with following functions and properties:
** field double world.playerX
** field double world.playerY
** field int world.playerWalkingDirection
** field int world.playerWalkingTimer
** field int world.playerWalkingFrame
** field int world.playerWalkingFrameTimer
** field boolean world.playerIsCurrentlyWalking
** field nil or VBStr world.levelTitle
** function mem

Documentation will be updated soon!
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #88by Sambo » 2 Jan 2015, 23:12

Kevsoft wrote:simple do "../HUD/yourImg.bmp"
Thank you for all the help.

EDIT: Is there a way to count number of NPCs with a certain ID, like, for example, if I wanted to return the number of Dragon Coins in a level?
Also, how do I make a counter that goes up every time a certain NPC is destroyed?(with more than one of that NPC in the level)
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #89by Kevsoft » 3 Jan 2015, 1:36

Sambo wrote:if I wanted to return the number of Dragon Coins in a level?

Code: Select all


function countNPCID(id)
  local npcs = findnpcs(id, -1)
  local count = 0
  for k,v in pairs(npcs) do
    count = count + 1
  end
end

function onLoop()
  local goombaNPCCount = countNPCID(1)
  if goombaNPCCount == 5 then
    --do stuff
  end
end



Sambo wrote:Also, how do I make a counter that goes up every time a certain NPC is destroyed?(with more than one of that NPC in the level)
I could do it but with the restriction, that the type of that NPC has no spawner, or in other words: The value should not increase.
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #90by Sambo » 11 Jan 2015, 8:36

Is there a way to make it so an onLoopSection# function can have multiple section numbers? I don't want it to be for the whole level, just all the sections except for 1 or 2 of them. I would just do:

Code: Select all

function onLoopA()
  ...(stuff I want it to do goes HERE)...
end
function onLoopSection1()
  onLoopA()
end
function onLoopSection2()
  onLoopA()
end

...

end

But since the codes are run from lunaworld and this would only be for 1 level (lunadll), That wouldn't work in a way that wasn't a total pain to deal with, because I'd have to add all those codes to every level.
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #91by Kevsoft » 11 Jan 2015, 10:27

You can use player.section in onLoop:

Code: Select all

function onLoop()
  if(player.section == 0 and player.section == 1)then --section in lua are 0-20!
    --dostuff
  end
end


Please note that this only works for 1-player mode. If you want to use it for 2-player mode you have to also check player2.section!
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #92by Sambo » 13 Jan 2015, 4:29

What I'm trying to do is make it so my custom HUD is hidden while in sections 4 and 5, on just one level in the episode, while the HUD functions are run from lunaworld.lua.
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #93by Kevsoft » 13 Jan 2015, 17:57

You should be able to access variables from lunadll.lua in lunaworld.lua and the other way round.
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #94by Sambo » 14 Jan 2015, 4:54

This is a code that's supposed to save the user data when the checkpoint is reached, but it will not work. I get the checkpoint and die, and then test the level again and the values are the same as they were before. This is really odd because it was working earlier and I didn't change it. I didn't update LunaLua or anything. It just stopped working.

Code: Select all

function countNPCID(id)
   local npcs = findnpcs(id, -1)
   local count = 0
   for k,v in pairs(npcs) do
      count = count + 1
   end
end
function onLoop()
   local checkpoint_count = countNPCID(192)
   if checkpoint_count == 0 and checkpoint == 0 then
      UserData.save()
      checkpoint = 1
   end
Image
Current Project:
Image

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #95by Kevsoft » 14 Jan 2015, 10:10

Code: Select all

function countNPCID(id)
   local npcs = findnpcs(id, -1)
   local count = 0
   for k,v in pairs(npcs) do
      count = count + 1
   end
   return count
end

I probably forgot to tell you that you have to return the count value!

With return you can set the value you get from a function.
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #96by Sambo » 15 Jan 2015, 5:05

Oh, that was an obvious mistake. :facepalm:
I know how the return command works and I still didn't think to add it in.
Image
Current Project:
Image

Veudekato M
Viscount
Viscount
Avatar
Veudekato M
Viscount
Viscount
Reputation: 79
Posts: 369
Joined: 19 Feb 2014
Location: Russia

Post #97by Veudekato » 16 Jan 2015, 19:14

Can someone help me? how to make smb1 bowser throw hammer more often and more hammers
My channel (PlatGEnWohl news and tutorials , smbx tests):
http://www.youtube.com/channel/UC6h-42umT14iR1wa3VkOs3Q

Void
Bat
Bat
Avatar
Void
Bat
Bat
Age: 21
Reputation: 102
Posts: 279
Joined: 18 Apr 2014
Location: [REDACTED]

Post #98by Void » 23 Jan 2015, 1:35

You Know That Explosions Everwhere Code? Can Someone Make A Code That Makes it On A Layer Called "BottomPillar" Without Quotes? I Just Need It Without The Crab thing.
Join the SMBX 38a Discord Server!
Image

sweep a leaf sweep away a troubles

Kevsoft M
Topic author, Angry developer
Angry developer
Avatar
Kevsoft M
Topic author, Angry developer
Angry developer
Age: 24
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #99by Kevsoft » 24 Jan 2015, 9:45

You mean the code for this video?
phpBB [youtube]

Original link: https://www.youtube.com/watch?v=H--zvT5mWxo



Code: Select all

function onLoop()
   local myBlocks = blocks()
   local plScreen = player.screen
   local k = 0
   for _,v in pairs(myBlocks) do
      k = k + 1
      local curX = v.x
      local curY = v.y
      if(k % math.random(1,2000) == 0)then
         if(player.y-plScreen.top < curY and player.y-plScreen.top+600 > curY and player.x-plScreen.left < curX and player.x-plScreen.left+800 > curX)then
           if(v.layerName.str == "BottomPillar")then
             runAnimation(108, curX, curY+16, 1065353216)
           end
         end
      end
   end
end

▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

Sambo M
Count
Count
Avatar
Sambo M
Count
Count
Age: 25
Reputation: 15
Posts: 264
Joined: 27 Jun 2014

Post #100by Sambo » 30 Jan 2015, 5:17

Kevsoft wrote:You should be able to access variables from lunadll.lua in lunaworld.lua and the other way round.
I tried to access functions from lunaworld.lua in lunadll.lua and got "attempt to call a nil value." Functions are a type of variable, right?
Image
Current Project:
Image


Return to “LunaLua - Extension Framework”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest