Is it possible to create a linedef/sector type with Lua?

BizarreLobo

Lone gamer wolf
Hi. It has been a while since I last tried modding. I want to make a volcano-themed map someday, but I'm not a fan of the 2.2 ring-eating lava, so I wish I could create a lava FOF that is solid, but doesn't eat rings.

Can I accomplish this using Lua, or do I need to modify the source code directly?

Forgive me if there's already some info about this on the wiki. I haven't checked it out yet.
 
Natively you can't create new sector types or linedef actions (i mean it in terms of doing something like freeslotting them), but you can totally use Lua to check for a specific sector/linedef special number that doesn't correspond to any existing special effect and act upon it.
 
you can totally use Lua to check for a specific sector/linedef special number that doesn't correspond to any existing special effect and act upon it.
So you mean I can overwrite an existing linedef/sector effect with Lua? That's nice, but can you give me an example on how to do this? I'm not yet familiar with Lua or how SRB2 makes use of it.
 
So you mean I can modify an existing linedef/sector effect with Lua?
Not quite.
What I said was that, just as you can check for any existing special number, you can also check for special numbers that don't correspond to effects.

A cheap example:
addHook("PlayerThink", function(player)
   
    -- See https://wiki.srb2.org/wiki/Sector_types
    -- Group (section) 3 only has stock effects on numbers 2, 4, 5 and 6
    -- Looks like number 10 is free, so we're going to check for that!
    -- In the map, click the drop down text field, and enter the number directly
    -- instead of choosing any of the existing ones.
    -- The game will do nothing with that effect, AND we can check for it later :)
   
    -- P_PlayerTouchingSectorSpecial(player_t player, int section, int specialnum)
    local isTouchingFunny = P_PlayerTouchingSectorSpecial(player, 3, 10)
   
    if isTouchingFunny then
        if player.mo then
            player.mo.momz = 99*FRACUNIT -- ascend to heaven
        end
    end
   
end)

This only works on binary maps, since the UDMF editor deprecated the sector specials in favor of sector flags.
Technically you could apply the same concept to the flags part, but the editor doesn't allow you to input a number directly.
You could edit the 2.2 configuration file to add your custom flag, but I don't have the knowledge on how to do it.

This idea also extends to linedefs, except with the difference where you can get the current line special and arguments of it with less hassle than with a sector, and it is UDMF compatible!
See https://wiki.srb2.org/wiki/Lua/Userdata_structures#line_t

UDMF introduces the concept of custom fields and they are written to the map file, but unfrotunately SRB2 doesn't interpret those yet.
Hope we get support for them someday, would be baller :)
 
After @KirbyDL's message I figured I'd check the source code to see WHEN do rings get killed off.
1715812693421.png


Rings only melt if the FOF is swimmable and it has the fire or lava damage type.
Therefore,
I wish I could create a lava FOF that is solid, but doesn't eat rings.
you can totally do this, no problem. Just don't make the solid FOF a water FOF and you're good to go!
 
rather than lua, i recommend instead using a solid fof, and setting the sectors damage type to fire to fake the effect.
you can totally do this, no problem. Just don't make the solid FOF a water FOF and you're good to go!
Hmm, I just remembered something. Actually, I did try using solid FOFs with a fire sector effect before, but if I'm not mistaken, the FOF does not damage the player if they touch it from the sides. Which is a problem if I want to, say, create a big lavafall.

That was why I was wondering if I could implement this custom lava using Lua.
 
Last edited:
You should give it a try. It seems that FOFs marked to deal lava damage can harm players that touch the walls.
 
So, I just opened Zone Builder (took a while; my current PC is so crappy) and created a solid FOF with the Damage Fire effect on the control sector.

The attached GIF shows that the red FOF only deals damage from the top. Even hitting the walls at high speed has no effect (btw, the orange block is just a normal sector).

In fact, the wiki confirms that the sides and bottom of a solid "lava" FOF are safe.


Oh, I am using version 2.2.13 of SRB2.
 

Attachments

  • LavaTest.gif
    12.4 MB · Views: 52
Last edited:
Oh oops, I forgot.
I strictly meant lava damage, not fire damage, and it can be set in an UDMF map.

You can download Ultimate Zone Builder (has UDMF support, unlike base Zone Builder) here:
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top