Page 1 of 1

Any way to make a level warp vertically?

Posted: Sun Sep 03, 2017 7:27 pm
by Oshi
There's on option for it in the PGE editor in 2.0 Beta3, but it's grayed out and unselectable. How do are you supposed to make it selectable?

Re: Any way to make a level warp vertically?

Posted: Sun Sep 03, 2017 11:24 pm
by HenryRichard
You can't currently. You'll have to do it with Lua.

Re: Any way to make a level warp vertically?

Posted: Mon Sep 04, 2017 12:08 am
by Julia Pseudo
Grayed out PGE options indicate that they're features of the (currently in Alpha) PGE engine, separate from SMBX I believe. As HenryRichard said, you'll have to use Lua if you want to implement this in SMBX.

Re: Any way to make a level warp vertically?

Posted: Mon Sep 04, 2017 2:07 am
by ElectriKong
The greyed out features will likely be available in the future (either in a future version of 2.0 or when PGE is fully released and replaces SMBX).

The best way to make vertically wraping is to use instant warps although they don't really work very well.

Re: Any way to make a level warp vertically?

Posted: Mon Sep 04, 2017 9:58 am
by The0x539
Electriking wrote:The best way to make vertically wraping is to use instant warps although they don't really work very well.
Then it's clearly not the best way, because the vertical wrap in Hypnosis Redo's intro level is s l i c k.

Re: Any way to make a level warp vertically?

Posted: Tue Oct 09, 2018 6:21 pm
by ClapClop
HenryRichard wrote:
Sun Sep 03, 2017 11:24 pm
You can't currently. You'll have to do it with Lua.
I did not understand, how I use lua to be able to use the warp vertically

Re: Any way to make a level warp vertically?

Posted: Tue Oct 09, 2018 8:40 pm
by HenryRichard
ClapClop wrote:
Tue Oct 09, 2018 6:21 pm
HenryRichard wrote:
Sun Sep 03, 2017 11:24 pm
You can't currently. You'll have to do it with Lua.
I did not understand, how I use lua to be able to use the warp vertically
Throw something like this in your onTick() function. You'll have to change the coordinates to match your section's, and probably limit it to the current section as well.

Code: Select all

if player.y >= -140000 then --coords
			player.y = -140632
		end
		if player.y <= -140638 then
			player.y = -140004
		end
This code is from Hypnosis Redo - I don't know if Enjl wants credit for this or not (more likely than not he doesn't care, but I'd be on the safe side).

Re: Any way to make a level warp vertically?

Posted: Wed Oct 10, 2018 1:06 am
by Enjl
HenryRichard wrote:
Tue Oct 09, 2018 8:40 pm
ClapClop wrote:
Tue Oct 09, 2018 6:21 pm
HenryRichard wrote:
Sun Sep 03, 2017 11:24 pm
You can't currently. You'll have to do it with Lua.
I did not understand, how I use lua to be able to use the warp vertically
Throw something like this in your onTick() function. You'll have to change the coordinates to match your section's, and probably limit it to the current section as well.

Code: Select all

if player.y >= -140000 then --coords
			player.y = -140632
		end
		if player.y <= -140638 then
			player.y = -140004
		end
This code is from Hypnosis Redo - I don't know if Enjl wants credit for this or not (more likely than not he doesn't care, but I'd be on the safe side).
Someone in codehaus needed vertical wrap recently so here's a more dynamic variant:

Code: Select all

local _scrollSections = {0, 1, 2}

local scrollSectionMap = {}

for k,v in ipairs(scrollSections) do
    scrollSectionMap[v] = true
end

local allNPCIDs = {}
for i=1, 300 do
    allNPCIDs[i] = i
end

function onTickEnd()

    local checkedNPCSections = {}
    for _,p in ipairs(Player.get()) do
        if scrollSectionMap[p.section] then
            local s = Section(p.section)
            local b = s.boundary
	    local sheight = b.bottom - b.top + 32
            if p.y > b.bottom + 16 then
                p.y = p.y - sheight
            elseif p.y + p.height < b.top - 16 then
                p.y = p.y + sheight
            end
            if not checkedNPCSections[p.section] then
                for k,v in ipairs(NPC.get(allNPCIDs, p.section)) do
                    if v:mem(0x12A, FIELD_WORD) > 0 then
                        if v.y > v.bottom + 16 then
                            v.y = v.y - sheight
                        elseif v.y + v.height < v.top - 16 then
                            v.y = v.y + sheight
                        end
                    end
                end
            end
            checkedNPCSections[p.section] = true
        end
    end
end
Just adjust scrollSections with the section numbers you want to scroll. Remember that section numbers are 0-indexed so Section 1 in the editor is Section 0 in game.

No credit needed.