[Reusable] Simple Key System

This thread contains content that may be reused, modified, or ported by anyone.

Xelork

What can I type here?
Welcome!

A friend of mine asked me if i could code some sort of key that can open doors on maps, and then, with help of the #scripting at the SRB2 Discord Server, this is now real and also re-usable for everyone!

Very simple to use, you just need to set an activating sector with a tag that will activate a linedef with Call Lua Action, a poly object to work as a door, and a control sector that will rotate the polyobject with a different tag from the sector, and type some things in the lua to make it work. Like this for example:

Code:
local function open1(line, p, sec)
    if keycount == 0
        S_StartSound(p, sfx_kc5d)
    end
    if keycount > 0
        sec.tag = 3
        keycount = $ - 1
        S_StartSound(p, sfx_kc5c)
    elseif keycount == 0
        S_StartSound(p, sfx_kc5d)
    end
end

 addHook("LinedefExecute", open1, "DOOR1")
An example wad is available for reference, and you're free to modify everything!


Major thanks to my friend, TorLes, for the idea and HUD & Key sprites. <3
 

Attachments

  • Simple Key System.zip
    5.1 KB · Views: 204
  • srb20037.gif
    srb20037.gif
    7.8 MB · Views: 510
Last edited:

Sz_

Member
This is awesome! It opens up a lot of potential for puzzle maps and I personally like 'em!
 
Top