LunaLua Offical Thread

The second SMBX collab!
Post Reply

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: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I just checked the code kil wrote. So the image is ALWAYS loaded from the custom-folder of the level.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:I just checked the code kil wrote. So the image is ALWAYS loaded from the custom-folder of the level.
This is a pain, but if this is the case, then there is something wrong with placeSprite in the API code. I haven't tested it on a loop, but it doesn't seem to work on load.
Image
Image
Image
Image
Image
Darkchaox100
Posts: 0
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

I tried loading & Placing sprites with a api too,doesnt seem to work.
with lunadll.lua it seems to work without any issues though.
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I just tested it, for me it works all fine:

in LuaScriptLib/sometestloader.lua

Code: Select all

local sometestloader = {}

function sometestloader.onInitAPI()
	registerEvent("sometestloader", "onLoad")
	registerEvent("sometestloader", "onLoop")
end

function sometestloader.onLoad()
	loadImage("sometest.bmp", 1, 0xFFFFFFFF)
end

function sometestloader.onLoop()
	placeSprite(1, 1, 20, 300)
end

return sometestloader
and in lunadll.lua:

Code: Select all

loader = loadAPI("sometestloader")
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

placeSprite in a loop with no duration is inefficient, as it places more sprites each frame (eventually causing the game to slow down). It's much more efficient to call placeSprite once when loading, and that is what doesn't work. I suspect it might be to do with the code that calls the onLoad function, but I'm not sure.

Try this code out:

Code: Select all

local sometestloader = {}

function sometestloader.onInitAPI()
   registerEvent("sometestloader", "onLoad")
end

function sometestloader.onLoad()
   loadImage("sometest.bmp", 1, 0xFFFFFFFF)
   placeSprite(1, 1, 20, 300)
end
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Works without problems (and yes, in the API file and not in the host file)!
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:Works without problems (and yes, in the API file and not in the host file)!
Interesting. Perhaps there is some difference between your version and the released version that has fixed the issue?

EDIT: Hmm. I just tried again, and it worked. My code is exactly the same as it was before, but now it seems to work fine. Interesting.

Would certainly be nice to be able to load from the main path, rather than the level folder, though. It would make global objects (such as the raocoin counter) much easier to load in reliably.

EDIT EDIT: Ah, turns out I was using the wrong lunaworld - it's still not working.

I'll post an update of my Raocoin system when I have this working. I'm not going to change anything in the trigger system, though. You can still use loadAPI to load it in, but you still need to manually check for triggers. The reason for this is that it requires you specify the item IDs of the triggers in question. Given time, I just might be able to work it so that it does it automatically, but at the moment, this is how it will be.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

LunaLua v0.3.3 is out!

Changes:
*Added new class Layer (speedX, speedY, layerName and stop-function)
*Added better layer access from NPC and Block by returning now a Layer Object.
Example:

Code: Select all

i = 0
run = true
function onLoop()
	i = i + 1 
	local myLayer = findlayer("MyLayer")
	if(myLayer)then
		printText(myLayer.layerName.str, 30, 200)
		if(i % 100 == 1)then
			run = not run
		end
		if(run)then
			myLayer.speedX = -1
		else
			myLayer:stop()
		end
	end
end
(requires a layer "MyLayer" added with some blocks :P)

Documentary will be updated soon!
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Going to check if this new version sorts out the placeSprite issue.

EDIT: Aha! I finally fixed it! Turns out, it was an issue with the path of the "init" function being mistyped! Seems to work fine now. Will upload a new version of the raocoin system soon.

New shop library! Now a lot easier to use. Requires only one line in lunaworld to implement the raocoin system!

Raocoin Library
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Hoeloe wrote:EDIT: Aha! I finally fixed it! Turns out, it was an issue with the path of the "init" function being mistyped! Seems to work fine now. Will upload a new version of the raocoin system soon.
Then all is good! :D

Btw guys: Do you need to change smbx events at runtime? I just asking if I should implement that.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:
Hoeloe wrote:EDIT: Aha! I finally fixed it! Turns out, it was an issue with the path of the "init" function being mistyped! Seems to work fine now. Will upload a new version of the raocoin system soon.
Then all is good! :D

Btw guys: Do you need to change smbx events at runtime? I just asking if I should implement that.
What do you mean by "change" SMBX events?
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Well, modify the events.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:Well, modify the events.
That's not entirely helpful. Do you mean changing what a specific event does? Changing which event is triggered by an object? There are a number of things that could mean.

For the record, of those two, the latter would be more useful.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Or better said: Modifiy the event properties/content... whatever.
Hoeloe wrote:Changing which event is triggered by an object.
Is currently difficult because of the ugly VB6 Strings. Might be possible in the future.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:Or better said: Modifiy the event properties/content... whatever.
I'm not sure it's really worth it. The ability to trigger Lua from SMBX events means you can essentially do this already, by using two different events and hooking up a condition in Lua. Still, might make things a bit easier, depending on implementation, and having an Event class would be useful in the long run anyway.
Image
Image
Image
Image
Image
User avatar
Oddwrath
The ghost of talkhaus unlikely
Posts: 17
Joined: 8 years ago
Pronouns: she/her
Location: Merry Old Europe

Re: Presenting: Lunadll for Lua!

Post by Oddwrath »

So, I've looked at the section class code and I'm still not sure about one thing: can we do autoscrolling like this yet?
TiKi
Posts: 690
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by TiKi »

Oddwrath wrote:So, I've looked at the section class code and I'm still not sure about one thing: can we do autoscrolling like this yet?
It better not be
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Probably by updating the level boundaries yourself.....
Rixithechao
https://www.youtube.com/watch?v=IwLdM6ejGAM
Posts: 1608
Joined: 8 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Oh, man, so close! Everything works except disabling the original NPC messages! Setting NPC.msg.str = "" just replaces the first character with a space.

Image

Which offset points to the NPC.msg VBStr? I could index the pointers, grab a dead end pointer from an NPC without a message and then selectively replace them based on the section number or some other scope condition; in theory, that should disable the default SMBX message functionality... if not, then it might just be controlled by another NPC offset and I'd just have to experiment with the remaining unknowns.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to follow and/or contribute to A2XT Episode 2's development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Quick question: how does playSFX work? I'm trying to use it to add more sound effects to my level, but it's just playing the Windows alert noise, not my sound file.
Image
Image
Image
Image
Image
User avatar
Holy
Posts: 111
Joined: 11 years ago

Re: Presenting: Lunadll for Lua!

Post by Holy »

Kevsoft wrote:1.) "player.UKeyState" is what your looking for. -1 if it is pressed, 0 if it is not pressed
Awesome, didn't know that was a thing!

Is there a way to "tighten" the block collision? Basically I'm tryin to do this bouncy ball thing:


and you can bounce up the walls because it still thinks you're colliding with the tops of the wall blocks.

Here's the current code for this btw in case there's a hilariously easier way to do it I didn't think of

Code: Select all

playerVel = 0

function onLoop()
	testVel = 0
	printText(tostring(player.speedX), 270, 250)
--FIND ALL WOOD BLOCKS
	local normBlock = findblocks(3)
--STORE THE PLAYER'S CURRENT SPEEDS TO USE WHEN A COLLISION HAPPENS
	if(player.speedY ~= 0) then
		playerVel = player.speedY
	end
	if(player.speedX ~= 0) then
		playerVelX = player.speedX
	end
--MAKE THE PLAYER SPARKLE WHEN PRESSING UP
	if(player.UKeyState == -1) then
		player:mem(0x02,FIELD_WORD,0xFFFF)
	else
		player:mem(0x02,FIELD_WORD,0)
	end
--CHECK IF EACH BLOCK IN THE ARRAY REGISTERS A COLLISION
	if(normBlock) then
		for k,v in pairs(normBlock) do
			if(v:collidesWith(player) == 1) then
				
--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

--IF PLAYER IS TOO SLOW GOING DOWN SET Y SPEED TO -5
--OTHERWISE PLAYER VELOCITY DECREASES ON BOUNCEBACK BY 9/10THS
if(player.UKeyState == 0 and player.DKeyState == 0) then
	if(playerVel < 5) then
		player.speedY = -5
	else
		player.speedY = playerVel * -.9
	end

--IF PLAYER HOLDING UP KEY VELOCITY INCREASES UNTIL IT REACHES LIMIT
elseif(player.UKeyState == -1) then
	if(playerVel < 5) then
		playerVel = 5
	end
	if(playerVel > 9) then
		player.speedY = playerVel * -.9
	else
		testVel = playerVel * -1.8
		if(testVel < -9) then
			player.speedY = -9
		else
			player.speedY = testVel
		end
	end

--IF PLAYER HOLDING DOWN KEY BOUNCES STAY AT MINIMUM LEVEL
elseif(player.DKeyState == -1) then
	player.speedY = -5
end

--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

--BOUNCE PLAYER OFF THE CEILING AND WALLS. ONLY WORKS WHEN PLAYER IS NOT HOLDING THE DIRECTIONAL KEYS. MAYBE REVAMP X MOVEMENT ENTIRELY?
			elseif(v:collidesWith(player) == 2) then
				player.speedX = playerVelX * -.8
			elseif(v:collidesWith(player) == 4) then
				player.speedX = playerVelX * -.8
			elseif(v:collidesWith(player) == 3) then
				player.speedY = playerVel * -1.1
			end
		end
	end
end
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

uff... I currently don't know a "easier" way. I might add a secondary function where you can add you offsets to the collision check.
Rixithechao
https://www.youtube.com/watch?v=IwLdM6ejGAM
Posts: 1608
Joined: 8 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

The block collision stuff is kinda finnicky, I tried to set up some stuff with it and Demo kept falling through the ground. Best to manipulate layers instead of blocks... unless you're doing something like a yellow devil battle (someone should get on that asap plz kthx).

Regarding playSFX, it may be the import path.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to follow and/or contribute to A2XT Episode 2's development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Is there a way to access and set the absolute position of a layer? I'm trying to create a series of looping events. Doing so in SMBX is difficult because the floating point values get truncated too early, meaning it drifts over time. Doing so in Lua seems to also drift off, but more severely, and only under certain circumstances (such as changing sections).

Oh, I also fixed playSFX - it only supports .wav files, not .mp3. Worth adding that to the documentation.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Layers in SMBX don't have positions. They only move their objects by the speed, nothing else.
Post Reply