Re: Need help with lua? - LunaLua General Help
Posted: Fri Feb 24, 2017 10:29 am
Take a look at NPC.getIntersecting()
Forums for SMBX
https://www.smbxgame.com/forums/
Either that, or using the colliders library, which allows you to call colliders.collideNPC, which can detect against all NPCs of a given ID.PixelPest wrote:Take a look at NPC.getIntersecting()
I don't believe it is, not directly at least.Quantumenace wrote:Is there a way to access the profiler lag data with lua (the stuff that shows up when you push F3)?
Ah, dynamic adjustment. Neat. You'd be better off measuring between the same call, though, as that's what the actual framerate would be. The eventu API provides a "deltaTime" value that you could use for this, which gives you the time the last frame took to render.Quantumenace wrote:Thanks. Ok, yeah, it is kind of out there. I just wanted to know if there was a better way to measure lag.
Currently I have it set up to measure the wait time after onDrawEnd and before the next onTick. If it starts getting low I throttle the number of particles produced. It actually works pretty well.
Thanks, but deltaTime doesn't start to change until the game has already started lagging and I'm trying to head that off. I should probably measure the time taken between onLoop and onDrawEnd, the wait afterward might get inflated by other processes on low-number core systems as far as I know.Hoeloe wrote:Ah, dynamic adjustment. Neat. You'd be better off measuring between the same call, though, as that's what the actual framerate would be. The eventu API provides a "deltaTime" value that you could use for this, which gives you the time the last frame took to render.Quantumenace wrote:Thanks. Ok, yeah, it is kind of out there. I just wanted to know if there was a better way to measure lag.
Currently I have it set up to measure the wait time after onDrawEnd and before the next onTick. If it starts getting low I throttle the number of particles produced. It actually works pretty well.
It's difficult to detect frame loss before it happens. If all you're doing is changing particle counts, then your best bet is probably to wrap just those particle draw calls in a time test. You can use os.clock() to get the current time, and if you store that before drawing them, then compare it after drawing them, you can get a good idea of just how long your particle rendering takes (and therefore is a useful measure for how much you should decrease it by).Quantumenace wrote: Thanks, but deltaTime doesn't start to change until the game has already started lagging and I'm trying to head that off.
What transition? Can't you just speed up the transition or the camera itself?Angelus wrote:What can I do regards camera with LunaLua? Can I increase the camera update speed, so the transition is faster?
I'm trying to account for all sources of lag, including Spike Tops and other gameplay stuff. The particles are the only thing I can really scale to compensate.Hoeloe wrote: you can get a good idea of just how long your particle rendering takes (and therefore is a useful measure for how much you should decrease it by).
Yeah, this is what I'm doing. I tested, and onLoop executes before onInputUpdate. Didn't know about the lunatime one though, thanks.Hoeloe wrote:If you want to run across the whole frame, you should start from onInputUpdate and end with onDrawEnd, I think, which should get you a measure for how long your Lua is taking. Compare that to the value in lunatime.toSeconds(1), which will give you an accurate default frame rate without lag (the time in seconds for one tick). Your measured value should be a lot lower than that. If it gets even above half that value, you can start dropping particles.
The autoscroll API has a autoscroll.scrollToBox(gX1, gY1, gX2, gY2, speed, section) function. It looks like you can put the new section bounds in there and it will expand at the specified speed without disabling player controls at all. Try a speed of 8, faster than running speed. It's possible to set the bounds instantly but that can end up jarring.Angelus wrote:No, it's not autoscroll. Let me elaborate it better:
In the event settings, you can set the camera boundaries to move somewhere else if a specific event is activated. Then it will lock into a new area. It can be to the right of the screen (which was not accessible earlier on until you activated the said event), or to any other direction. When you activate it, the camera moves its boundaries to a new area defined at the event settings. Then, we have a transition, where the camera slowly moves to the right, or to the left, etc., 'till it stops so you can regain control over the player. I would like to increase the speed of this short transition of the camera boundaries movement when it is setting to a new place.
Code: Select all
function OnLoad()
Level.loadPlayerHitBoxes(4, 1, "toad-1.ini")
Level.loadPlayerHitBoxes(4, 2, "toad-2.ini")
Level.loadPlayerHitBoxes(4, 3, "toad-3.ini")
Level.loadPlayerHitBoxes(4, 4, "toad-4.ini")
Level.loadPlayerHitBoxes(4, 5, "toad-5.ini")
Level.loadPlayerHitBoxes(4, 6, "toad-6.ini")
Level.loadPlayerHitBoxes(4, 7, "toad-7.ini")
end
function onTick()
if Player.jumpKeyPressing == true then
if player.character == 4 then
if Player.altRunKeyPressing == true then
if Player.rightKeyPressing == true then
player.speedX = 5;
Audio.playSFX("dash.wav")
elseif Player.altRunKeyPressing == true then
if Player.leftKeyPressing == true then
player.speedX = -5;
Audio.playSFX("dash.wav")
elseif Player.altRunKeyPressing == true then
if Player.downKeyPressing == true then
player.speedY = 7;
Auido.playSFX("dash.wav")
end
end
end
Code: Select all
local dashsound = Audio.playSFX("dash.wav")
local TableOfBoostDash = {a = player.jumpKeyPressing, b = player.altRunKeyPressing, c = player.rightKeyPressing, d = player.leftKeyPressing, e = player.downKeyPressing}
local TableOfBoostDirection = {sa = player.speedX = -5, sb = player.speedX = 5, sc = player.speedY = 5}
local a = player.jumpKeyPressing
local b = player.altRunKeyPressing
local c = player.rightKeyPressing
local d = player.leftKeyPressing
local e = player.downKeyPressing
local sa = player.speedX = -5
local sb = player.speedX = 5
local sc = player.speedY = 5
local haveBoosted = false;
local haveBoostedDown = false;
function onLoop()
if player:mem(0x146, FIELD_WORD) == 2 then
HaveBoosted = false;
HaveBoostedDown = false;
end
end
function onStart()
for i = 1, 7 do
Level.loadPlayerHitboxes(4, i, "toad-"..tostring(i)..".ini");
end
end
function OnStart()
if TableOfBoostDash[a] then
if TableOfBoostDash[b] then
if TableOfBoostDash[c] > TableOfBoostDash[d] and TableOfBoostDash[e] then
if haveBoosted == false then
local sa
do dashsound
do haveBoosted = true;
elseif TableOfBoostDash[d] > TableOfBoostDash[c] and TableOfBoostDash[e] then
if haveBoosted == false then
local sb
do dashsound
do haveBoosted = true
elseif TableOfBoostDash[e] > TableOfBoostDash[d] and TableOfBoostDash[e] then
if haveBoostedDown == false then
local sc
do dashsound
do haveBoostedDown = true;
do haveBoosted = true;
end
end
end