pge projectirc.cat.biosmw central

LunaLua Offical Thread

The second SMBX collab!

Shall I stream some LunaLua live development?

Yes
23
92%
No
2
8%
 
Total votes: 25

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

LunaLua Offical Thread

Postby Kevsoft » 3 years ago

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

Heya all, I'm here to present Lunadll with Lua (Alpha-Version)!
I used most of the last week to work on this, and I think it's turning out pretty well. 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). Kil is currently developing his own language, when he provides me the source code I would merge it together with this lua part. 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 and Tutorials
Source Code
LunaDLL for lua reference & example page (outdated since v0.2.7)
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.

Examples are provided in the reference page.

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 28 Oct 2015, 17:30, edited 64 times in total.

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Update 0.2.1:

* Added section class
* Added direct memory editing

User avatar
Darkonius64
Is pizza a verb?
Posts: 60
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Darkonius64 » 3 years ago

A friend of mine, the same that made the Luna.txt help program, has been experimenting with this, he made a fully working dino rhino torch thingy, and added a double jump to yoshi!

User avatar
Willhart
Stalker, Doxxer, and Sexual Harasser
Banned
Posts: 2533
Joined: 6 years ago
Location: Finland

Re: Presenting: Lunadll for Lua!

Postby Willhart » 3 years ago

Darkonius64 wrote:A friend of mine, the same that made the Luna.txt help program, has been experimenting with this, he made a fully working dino rhino torch thingy, and added a double jump to yoshi!
This sounds pretty awesome. Would it be possible to change the player jumping/running physics to SMW ones with the help of this thing?
Willhart wrote:Being a fan means... blind obsession.... She does not have to accept it... I thought it brought me closer to her.
Willhart wrote:[She] is planning on joining the patreon discord thing on advanced group, and that likely means that I'll listen trough every single one of those as they happen...

Part of me feels like writing her name over and over again
...I should not give up.
💔

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Technical yes, but I am not sure how SMBX handels modified physics. Anyway, I added a "onJump" event and a "onJumpEnd" event in the next version (will release soon)

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Man, I'm not really that familiar with Lua but I just had to try something with this thing! So I drafted up a basic cutscene framework. Currently it just has timed subtitles and NPC talking animations, but based on that reference document I have a few ideas for other potentially useful features...

Code: Select all

dialogSpeaker = 0

dialogTextTime = 0
dialogSpeakerTime = 0

dialogName = ""
dialogText = ""

-- Can the player press the key to skip the current line?
dialogSkippable = true

-- Does the dialogue halt the cutscene timing?
dialogPause = true

-- Does the player have to press a key to continue?
dialogEndWithInput = true

-- Can the entire cutscene be skipped?
cutsceneSkippable = true

-- Current cutscene time in frames
cutsceneFrame = 0


-- Constants
NPCID_DEMO = 101
NPCID_IRIS = 102
NPCID_KOOD = 103




function onLoad()
  dialogSpeaker = 0
  
  dialogTextTime = 0
  dialogSpeakerTime = 0
  
  dialogName = ""
  dialogText = ""
  
  dialogSkippable = true
  dialogPause = true
  dialogEndWithInput = true
  
  cutsceneFrame = 0

  setDialogRules(true, true, true)
end




function onLoop()
  -- Trigger sequenced cutscene events
  processCutscene()

  -- Control specific NPC talking/idle animations
  processNPCTalkAnim(NPCID_DEMO, 0, 3, 4, 7)
  processNPCTalkAnim(NPCID_IRIS, 0, 0, 1, 4)
  processNPCTalkAnim(NPCID_KOOD, 0, 15, 16, 19)

  -- Control dialogue display
  processDialogue()
end


function processCutscene()
  if(dialogPause == false  or  dialogTextTime <= 0)then
    cutsceneFrame = cutsceneFrame + 1
  end

  -- Add subtitle commands here
  timedDialog(30, NPCID_DEMO, "Demo", "Testing, testing, 1, 2, 3...", 120, 180)
  timedDialog(60, NPCID_IRIS, "Iris", "Hey there, everyone!", 60, 120)
  timedDialog(90, NPCID_KOOD, "Kood", "This is a test of a LunaLUA cutscene system.", 150, 180)  
end



function setDialogRules(pause, skippable, needInput)
  dialogPause = pause
  dialogSkippable = skippable
  dialogEndWithInput = needInput
end


function timedDialog(frame, speakerid, name, text, textTime, speakTime, sound)
  if(cutsceneFrame == frame)then
    -- Insert play sound command here
    timedDialog(frame, speakerid, name, text, textTime, speakTime)
  end
end

function timedDialog(frame, speakerid, name, text, textTime, speakTime)
  if(cutsceneFrame == frame)then
    triggerSpeaker(speakerid, speakTime)
    triggerDialog(name, text, textTime)
  end
end


function triggerSpeaker(npcid, time)
  dialogSpeaker = npcid
  dialogSpeakerTime = time
end

function triggerDialog(name,text,time)
  dialogName = name
  dialogText = text
  dialogTextTime = textTime
end


function processDialog() 

  -- Decrement the dialogue timer.
  if(dialogTextTime > 0)then
    if(dialogEndWithInput == true  and  player:mem(0x134, FIELD_WORD) == 1)then
      dialogTextTime = 0
      dialogSpeakerTime = 0
    else
      dialogTextTime = dialogTextTime - 1
    end

    -- While the dialogue timer counts down, display the dialogue.  
    printText(dialogName..":\n"..dialogText, 30, 500)
  end


  -- When the speaker timer reaches zero, reset the speaker.
  speakerTime = speakerTime - 1

  if(speakerTime == 0)then
    dialogSpeaker = 0
  end
end


function processNPCTalkAnim(npcid, idleMin, idleMax, talkMin, talkMax)
  -- Control the specified NPC's animation based on whether or not it's currentSpeaker
  if(currentSpeaker == npcid)then
    clampNPCAnim(npcid, talkMin, talkMax)
  else
    clampNPCAnim(npcid, idleMin, idleMax)
  end
end


function clampNPCAnim(npcid, min, max)
  local myNPC = findnpcs(npcid, -1)[0]
  animFrame = getNPCAnimFrame(myNPC)
  if(animFrame < min  or  animFrame > max)then
    setNPCAnimFrame(myNPC, min)
end


function getNPCAnimFrame(myNPC)
  return myNPC:mem(0xE4, FIELD_WORD)
end


function setNPCAnimFrame(myNPC, frame)
  myNPC:mem(0xE4, FIELD_WORD, frame)
end
To use it, include a processNPCTalkAnim() command in onLoop for each NPC ID you want to animate, then add timedDialog() commands to processCutscene to create a sequence of subtitles and character animations. You can use setDialogRules() to control how dialogue flows/progresses. The NPC sprites can have any number of animation frames, but you'll want at least two so you can specify separate frames/ranges for idle and talking animations.

Again, I'm not super Lua-savvy, so apologies if there are any syntax errors or other major issues here. Hopefully this thing'll aid folks in making more cinematic cutscenes; at the very least it should help clear up issues people have with identifying which character is speaking, as has been the case with Youtubers being introduced to the siblings for the first time.
Last edited by Rockythechao on 22 Sep 2014, 14:28, edited 6 times in total.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

There are some syntax errors. Lua is case sensitiv with functions and variables.

Also:

Code: Select all

local myNPC = findnpcs(npcid, -1)[0]
add '[0]' to get the first npc match, because findnpcs returns an array :P

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Arright, fixed some misnamed variables and incorrectly-formatted hex addresses, added the [0] (not really sure what I was thinking trying to do that to the whole array), changed some of the spacing to be closer to the examples. Did I miss anything?
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Lua unfortunaly doesn't support one-line if, for, function and while-loops. You always have to close them with the 'end' keyword.

processDialogue() to processDialog()

EDIT: Here the fixed code:

Code: Select all

dialogSpeaker = 0

dialogTextTime = 0
dialogSpeakerTime = 0

dialogName = ""
dialogText = ""

-- Can the player press the key to skip the current line?
dialogSkippable = true

-- Does the dialogue halt the cutscene timing?
dialogPause = true

-- Does the player have to press a key to continue?
dialogEndWithInput = true

-- Can the entire cutscene be skipped?
cutsceneSkippable = true

-- Current cutscene time in frames
cutsceneFrame = 0


-- Constants
NPCID_DEMO = 101
NPCID_IRIS = 102
NPCID_KOOD = 103




function onLoad()
  dialogSpeaker = 0
 
  dialogTextTime = 0
  dialogSpeakerTime = 0
 
  dialogName = ""
  dialogText = ""
 
  dialogSkippable = true
  dialogPause = true
  dialogEndWithInput = true
 
  cutsceneFrame = 0

  setDialogRules(true, true, true)
end




function onLoop()
  -- Trigger sequenced cutscene events
  processCutscene()

  -- Control specific NPC talking/idle animations
  processNPCTalkAnim(NPCID_DEMO, 0, 3, 4, 7)
  processNPCTalkAnim(NPCID_IRIS, 0, 0, 1, 4)
  processNPCTalkAnim(NPCID_KOOD, 0, 15, 16, 19)

  -- Control dialogue display
  processDialog()
end


function processCutscene()
  if(dialogPause == false  or  dialogTextTime <= 0)then
    cutsceneFrame = cutsceneFrame + 1
  end

  -- Add subtitle commands here
  timedDialog(30, NPCID_DEMO, "Demo", "Testing, testing, 1, 2, 3...", 120, 180)
  timedDialog(60, NPCID_IRIS, "Iris", "Hey there, everyone!", 60, 120)
  timedDialog(90, NPCID_KOOD, "Kood", "This is a test of a LunaLUA cutscene system.", 150, 180) 
end



function setDialogRules(pause, skippable, needInput)
  dialogPause = pause
  dialogSkippable = skippable
  dialogEndWithInput = needInput
end


function timedDialog(frame, speakerid, name, text, textTime, speakTime, sound)
  if(cutsceneFrame == frame)then
    -- Insert play sound command here
    timedDialog(frame, speakerid, name, text, textTime, speakTime)
  end
end

function timedDialog(frame, speakerid, name, text, textTime, speakTime)
  if(cutsceneFrame == frame)then
    triggerSpeaker(speakerid, speakTime)
    triggerDialog(name, text, textTime)
  end
end


function triggerSpeaker(npcid, time)
  dialogSpeaker = npcid
  dialogSpeakerTime = time
end

function triggerDialog(name,text,textTime)
  dialogName = name
  dialogText = text
  dialogTextTime = textTime
end


function processDialog()

  -- Decrement the dialogue timer.
  if(dialogTextTime > 0)then
    if(dialogEndWithInput == true  and  player:mem(0x134, FIELD_WORD) == 1)then
      dialogTextTime = 0
      dialogSpeakerTime = 0
    else
      dialogTextTime = dialogTextTime - 1
    end

    -- While the dialogue timer counts down, display the dialogue. 
    printText(dialogName..":\n"..dialogText, 30, 500)
  end


  -- When the speaker timer reaches zero, reset the speaker.
  dialogSpeakerTime = dialogSpeakerTime - 1

  if(dialogSpeakerTime == 0)then
    dialogSpeaker = 0
  end
end


function processNPCTalkAnim(npcid, idleMin, idleMax, talkMin, talkMax)
  -- Control the specified NPC's animation based on whether or not it's currentSpeaker
  if(currentSpeaker == npcid)then
    clampNPCAnim(npcid, talkMin, talkMax)
  else
    clampNPCAnim(npcid, idleMin, idleMax)
  end
end


function clampNPCAnim(npcid, min, max)
  local myNPC = findnpcs(npcid, -1)[0]
  animFrame = getNPCAnimFrame(myNPC)
  if(animFrame < min  or  animFrame > max)then
    setNPCAnimFrame(myNPC, min)
  end
end


function getNPCAnimFrame(myNPC)
  return myNPC:mem(0xE4, FIELD_WORD)
end


function setNPCAnimFrame(myNPC, frame)
  myNPC:mem(0xE4, FIELD_WORD, frame)
end

function processNPCTalkAnim(npcid, idleMin, idleMax, talkMin, talkMax)
  -- Control the specified NPC's animation based on whether or not it's currentSpeaker
  if (currentSpeaker == npcid)then
    clampNPCAnim(npcid, talkMin, talkMax)
  else
    clampNPCAnim(npcid, idleMin, idleMax)
  end
end


function clampNPCAnim(npcid, min, max)
  local myNPC = findnpcs(npcid, -1)[0]
  animFrame = getNPCAnimFrame(myNPC)
  if (animFrame < min  or  animFrame > max)then
    setNPCAnimFrame(myNPC, min)
  end
end


function getNPCAnimFrame(tarNPC)
  return tarNPC:mem(0xE4, FIELD_WORD)
end

function setNPCAnimFrame(tarNPC, val)
  tarNPC:mem(0xE4, FIELD_WORD, val)
end
Althought it doesn't work really as expect. May you need to test it...

btw, when you run the code, lua should give you the errors anyway.... (You can even use it in the editor)

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

There is a decent text editor named SciTE that comes with Lua, which has highlighting and things. Very helpful 8-)
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Or Notepad++ :D

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

oh, thanks for telling me about that. That's the one I was looking for 8-)
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Ah, thought I capped off all of those, guess I missed a few ends.

Yeah, had I been using a proper IDE I would've caught those, but admittedly I haven't set everything up yet for incredibly dumb reasons -- I had trouble getting LunaDLL to work in the past so I was kinda worried that I'd end up spending all my free time on the installation process the DLLs and never get around to actually working with it.

That said, I've probably spent more time on this back-and-forth thingamajig than it probably would take me install it, and now I'm out of time. I'll get back to this thing this weekend. Thanks for the help and apologies for the trouble!
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Version 0.2.2 is out!

Changes:
*Added playSFX
*Added triggerEvent
*Added access to player 2
*Added new events onJump, onJumpEnd, onKeyDown, onKeyUp

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Test video time.
More details in the video description.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Just on the notice about the third line, it is because only Uppercase is allowed, I will implement a auto-uppercase soon. Keep up with the videos ;)

User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 3 years ago

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Version 0.2.3 is out!

Changes:
* Added event support for player 2.
* printText now auto-uppercase the text.

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Dangit, I took too long to reply!

When you say only uppercase is allowed, do you mean that this extension (I'm just gonna call it LuaLuna from now on) can't do lowercase or SMBX? According to the LunaDLL documentation there is a font that features lowercase letters:
FONT 1 only displays black letters (overworld level name font)
FONT 2 only displays numbers (score font)
FONT 3 only displays uppercase (normal game font)
...but I haven't been able to get Font 1 to work for whatever reason. I don't know if it's just an issue on my part or if Font 1 simply doesn't work in LunaLua, but unless it's the latter I don't recommend auto-capitalizing displayed text. At least not for fonts besides #3, anyway.

On another note, can this extension (I'm just gonna call it LuaLuna from now on) reference the level directory like LunaDLL autocode can? It would be great if we had the option to use file names for playSFX in addition to indexes, and there's so much that could be done with LoadImage and PlaceSprite. In general, it'd be helpful to have a list of planned features as well as which LunaDLL functionality, if any, can't be implemented in LuaLuna for whatever reason.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

Font 1 should be able to display small letters. It's the smbx font used for level names. Only problem is that that font is black, so it's ugly. ALso that's a cool cutscene thing.
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

...So I tried something. I set up a simple loop and iterated through fonts 0 to 6.

Image

I'mma do it 30 times or more and see if there are any others tucked away in there.

EDIT:
Image

Also past me, that's not how you spell "LuaLuna".
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

Wait, there's a 4th font I never knew about? ... God damnit.
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Yep, I thought the message box font was just the overworld font inverted but I guess it's a different thing altogether.

EDIT: The animation stuff is mostly working now. I can't get characters to stop jittering when I specify a single-frame loop, but as long as the max is greater than the min it works perfectly. I'll record another video once I get text wrapping to work.
Last edited by Rockythechao on 25 Sep 2014, 01:28, edited 1 time in total.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Hoeloe
One of them Lua people
Posts: 830
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Rockythechao wrote:Yep, I thought the message box font was just the overworld font inverted but I guess it's a different thing altogether.
Looks to be a monospaced version, probably to make fitting the font to the text box easier.
Image
Image
Image
Image

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

I guess font 1 is the score and only displays integers
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 499
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Oh, one more thing! Does version 0.2.2 (not gonna update just yet due to autocaps) process both Lua and autocode or just one or the other? I remember seeing something in the LunaDLL help thread about it disabling one if the other is detected, but if it allows both I'mma try out some HUD stuff.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image


Return to “A2XT”

Who is online

Users browsing this forum: No registered users and 2 guests

cron