# LUA & Patch Request

**URL:** <https://forum.electra.one/t/lua-patch-request/807>\
**Category:** Developers\
**Created:** [June 25, 2021, 8:55am UTC](https://forum.electra.one/t/lua-patch-request/807 "2021-06-25T08:55:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joris.roling](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/joris.roling/32/375_2.png) [@joris.roling](https://forum.electra.one/u/joris.roling)\
**Post date:** [June 25, 2021, 8:55am UTC](https://forum.electra.one/t/lua-patch-request/807/1 "2021-06-25T08:55:46Z")

</div>

Hi @martin,

Quick question about LUA and Presets. If remember right I once asked about why the ‘Request Patch’ thingy is not automaticly triggered at Preset load time, and you replied that it indeed was not done automaticly, but would be a perfect case for LUA to fill the gap. How would I proceed, is there a way (in LUA) to ‘know’ the the exacte SysEx to fire (by say interrogating the Preset for this), or is that not possible and the LUA script should just fire the same SysEx?

Cheers, Joris

---

<div class="post-metadata">

**Author:** ![martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/martin/32/145_2.png) [@martin](https://forum.electra.one/u/martin)\
**Post date:** [June 25, 2021, 9:11am UTC](https://forum.electra.one/t/lua-patch-request/807/2 "2021-06-25T09:11:56Z")

</div>

Hi @joris,

pls check the `patch.requestAll ()` command. If you place it in _setup_ part of the Lua script, it will be executed when the preset is loaded. It forces Electra to send out all Patch Requests defined in the preset, ie.the same action as if you pressed the `[PATCH REQUEST]` button.

[Lua Extension - Patch](https://docs.electra.one/developers/luaext.html#patch)

---

<div class="post-metadata">

**Author:** ![joris.roling](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/joris.roling/32/375_2.png) [@joris.roling](https://forum.electra.one/u/joris.roling)\
**Post date:** [June 25, 2021, 9:14am UTC](https://forum.electra.one/t/lua-patch-request/807/3 "2021-06-25T09:14:35Z")

</div>

Thanks @martin, yes, tried it. Upload the script with only that one line. It works immediate when uploading, but when I than change Preset (on the device), and later come back to the Preset (where I uploaded this script), it does not fire the request as I would expect. Do I miss something?

---

<div class="post-metadata">

**Author:** ![martin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/martin/32/145_2.png) [@martin](https://forum.electra.one/u/martin)\
**Post date:** [June 25, 2021, 9:19am UTC](https://forum.electra.one/t/lua-patch-request/807/4 "2021-06-25T09:19:13Z")

</div>

ahh, that is a good one. I will check.

---

<div class="post-metadata">

**Author:** ![oldgearguy](https://avatars.discourse-cdn.com/v4/letter/o/f4b2a3/32.png) [@oldgearguy](https://forum.electra.one/u/oldgearguy)\
**Post date:** [October 22, 2021, 3:01pm UTC](https://forum.electra.one/t/lua-patch-request/807/5 "2021-10-22T15:01:27Z")

</div>

never mind - solved it. Needed to define the patch response part properly in the JSON.  
Now I see the on.Response() getting the sysex data
