LunaLua Offical Thread - SMBX Usermod Framework

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?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
Kevsoft
Flurry
Flurry
Posts: 374
Joined: Sun Jul 27, 2014 8:03 am

LunaLua Offical Thread - SMBX Usermod Framework

Postby Kevsoft » Mon Dec 01, 2014 7:57 am

LunaLua documentation: https://wohlsoft.ru/pgewiki/Category:LunaLua_API



I recently had the idea if I should stream some LunaLua live development. Just say if you would be interested or not.

Because I get often ask where you can download LunaLua, I make a own topic about it.

LunaLua is a addition to lunadll which adds the script language lua. The problem with Autocode (the lunadll-language) is the lack of flexibility that it has (such as the way it lacks custom functions, variables,... etc). With this we don't need any hardcoded code for complex ideas anymore.

So first of all: What is lua?
Lua is an actual script language, which supports custom functions, variables and much more. The script type is something like JavaScript + Visual Basic



Download
Most recent Documentation
Source Code
LunaDLL for lua reference & example page (outdated since v0.2.7, but the examples still working)
LunaLua Tutorial
You might want to google other lua tutorials too.

How to install:
1. Check "Full Installation", check all checkboxes and download the most recent package.
2. Extract the package and profit!

How to update:
1. Check "Only Update" and replace the LuaScriptLib and lunadll.dll in your existing installation.

Example to see if LunaLua is working:
Spoiler: show

Code: Select all

function onLoop()
  printText("PLAYER x="..tostring(player.x).." y="..tostring(player.y), 30, 60)
end
Video Showcase:
Spoiler: show




Which lua-libs can I access?

Code: Select all

string.*
math.*
table.*
debug.*
os.* --Limited (only time/date works), because of security reasons
Reference to the lua libs:
string.*
math.*
table.*
debug.* (probably not needed)
os.* Note: Only os.clock, os.time and os.date works. The rest is limited due security reasons.
Last edited by Kevsoft on Wed Oct 28, 2015 1:30 pm, edited 31 times in total.

h2643
Birdo
Birdo
Posts: 2890
Joined: Sat Dec 21, 2013 7:23 am
Contact:

Re: LunaLua - Lunadll with lua

Postby h2643 » Mon Dec 01, 2014 8:56 am

Cool, I hope this awesomeness will be stickied! You could add into the post some example videos, which were posted at PGE forum too, that would be better in my opinion ;)

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Mon Dec 01, 2014 9:08 am

Updated my main post with some videos, so people can see what you can do with it.

Destiny
Volcano Lotus
Volcano Lotus
Posts: 572
Joined: Tue Apr 22, 2014 2:40 pm
Flair: bnuuy
Pronouns: she/her
Contact:

Re: LunaLua - Lunadll with lua

Postby Destiny » Sat Dec 06, 2014 1:18 pm

So, apparently, LunaLua isn't working for me. I saved this test code in a lunaworld file (obviously in .lua format) but nothing happens. I still need a new exe or something?

EDIT: Yeah, I still need a new exe.
Spoiler: show
Image

francot514
Guest

Re: LunaLua - Lunadll with lua

Postby francot514 » Sat Dec 06, 2014 2:51 pm

This will be work without need of new code into the main program?? becuase as i know there is no lua support in sbmx...

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Sat Dec 06, 2014 5:02 pm

Sorry if you guys missed that: Yes you need the modded exe file! The modded exe

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Sun Dec 21, 2014 3:42 am

v0.4 BETA is out.

Please read if you are an api-developer:
Spoiler: show
registerEvent has changed: The first argument has to be the api-table itself and not the api-string anymore!!!!

Code: Select all

registerEvent(table thisTable, string internalEventName, string functionToCall, boolean callBeforeMain)
This change is necessary to make a unique instance of a API.
In Addition for both api-developers and normal users:
Spoiler: show
* loadAPI is no longer using 'require'. I've writte my own loading function.
It will search in following paths for an API:
"{SMBXPath}\LuaScriptsLib\{apiName}.lua"
"{SMBXEpisodePath}\{apiName.lua}"
"{SMBXEpisodePath}\{CustomLevelFolder}\{apiName}.lua"
* loadSharedAPI added: Loads or gets (if already loaded) a shared instance of an API. (lunaworld.lua and lunadll.lua will reference the same API memory)
* hud(boolean displayHud) add: Toggle hud display on/off
Because there are lot of code changes I mark this version as "BETA". If there are any problems then please let me know!

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

Re: LunaLua - Lunadll with lua

Postby Wohlstand » Tue Dec 23, 2014 6:37 pm

SnifitGuy wrote:Could you possibly make an updated reference page? I know it may sound stupid, but I just don't want to have to go searching everywhere for new kinds of codes. Also, I tried using this code to display text, but it won't work. Any help?
Code:
Spoiler: show
function onLoop()
printText("This is a test", 3, 30, 30)
end
You also can check the Wiki page with latest LunaLUA references:
http://engine.wohlnet.ru/pgewiki/Category:LunaLua_API

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

Re: LunaLua - Lunadll with lua

Postby Wohlstand » Tue Dec 23, 2014 7:54 pm

SnifitGuy, quick question:
1) did you saved as "lunadll.lua" file in your custom dir of level?
2) did you correctly installed LunaLUA?

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

Re: LunaLua - Lunadll with lua

Postby Wohlstand » Thu Dec 25, 2014 4:37 pm

SnifitGuy wrote:
Wohlstand wrote:SnifitGuy, quick question:
1) did you saved as "lunadll.lua" file in your custom dir of level?
2) did you correctly installed LunaLUA?
1) It's LunaDLL with Lua, yes? That's the zip I have.
2) I put all the contents of the zip (the folder and two Dll files) in C:\SMBX
Do you got hexed SMBX's exe file which linked with LunaDLL?

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Fri Dec 26, 2014 2:17 am

Try to run Autocode (aka. lunadll.txt with some debug code) first. Because when it is executing then it is a issue on my side. Also please check if you have a folder in your main dir called "LuaScriptsLib".

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Fri Dec 26, 2014 7:47 am

I have a idea: Provide me a screenshot of your custom folder with the lunadll.lua inside.

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Sat Dec 27, 2014 5:01 am

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: show
* onLoad
* onLoop
Following functions can be used for the world:
Spoiler: show
* windowDebug
* printText
* loadImage
* placeSprite
* mem
Classes are not supported yet!

A small Q&A to that:
Spoiler: show
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!

DarkShadeX
Volcano Lotus
Volcano Lotus
Posts: 535
Joined: Sat Jan 18, 2014 11:34 am

Re: LunaLua - Lunadll with lua

Postby DarkShadeX » Sat Dec 27, 2014 6:54 am

i fu****g love you kevy!

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

Re: LunaLua - Lunadll with lua

Postby Kevsoft » Sat Dec 27, 2014 8:17 am

DarkShadeX wrote:i fu****g love you kevy!
Hehe, thanks :P

I also updated the package with a small hotfix towards loadImage.

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

Re: LunaLua - Lunadll with lua [Now with Overworld]

Postby Kevsoft » Sat Dec 27, 2014 11:24 am

I am currently trying to fix a bug where the overworld is crashing when lunaoverworld.lua is missing. I'll release a new version soon!

Okay: Just fixed the small bug. Just download the same ZIP and overwrite the LunaDll.dll file.

UberAndrew
Cheep-Cheep
Cheep-Cheep
Posts: 12
Joined: Thu May 08, 2014 4:51 pm

Re: LunaLua - Lunadll with lua [Now with Overworld]

Postby UberAndrew » Sun Dec 28, 2014 5:23 am

Man, this is really looking amazing.

If this was included with SMBX 1.3.2 and there were in depth tutorials, this could really revitalize SMBX.

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

Re: LunaLua - Lunadll with lua [Now with Overworld]

Postby Kevsoft » Tue Dec 30, 2014 8:29 am

And here is the first LunaLua update for the overworld adding now the world class!
Example Code:
Spoiler: show

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: show
* 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!

DarkShadeX
Volcano Lotus
Volcano Lotus
Posts: 535
Joined: Sat Jan 18, 2014 11:34 am

Re: LunaLua - Lunadll with lua [Now with Overworld]

Postby DarkShadeX » Tue Dec 30, 2014 9:30 am

The code above doesnt work.

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

Re: LunaLua - Lunadll with lua [Now with Overworld]

Postby Kevsoft » Tue Dec 30, 2014 11:29 am

What doesn't work?
Do you get any errors?


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari