# Prayer Form A {ref}`TLazForm` utility to aid in prayer selection settings. This will setup a {ref}`TLazButton` which opens a {ref}`TLazForm` that mimics the prayer tab and allows a user to select prayers to be used. - - - ## TRSPrayerForm The `TRSPrayerForm` type contains all of the components to build the button and form used for prayer selection settings. - - - ## TRSPrayerForm.Selected ```pascal property TRSPrayerForm.Selected(prayers: TRSPrayerSet); property TRSPrayerForm.Selected: TRSPrayerSet; ``` Get/Set the defined prayers as a set of selected prayers. Useful for saving user settings between sessions. Selected prayers from a previous session could be saved and then reset on the next session by setting them with the procedure upon building the form. Getting example: ```pascal {$I WaspLib/osrs.simba} var form: TScriptForm; tab: TTabSheet; prayerForm: TRSPrayerForm; begin form.Setup('Script settings'); tab := TLazTabSheet.Create(form.PageControl); prayerForm.Setup(tab, 50, 50); prayerForm.SetAllowedPrayers([ERSPrayer.EAGLE_EYE, ERSPrayer.RIGOUR]); form.Run(); WriteLn(prayerForm.Selected); end. ``` Setting example: ```pascal {$I WaspLib/osrs.simba} var prayerForm: TRSPrayerForm; config: TJSONParser; savedPrayers: TJSONItem; i: Integer; selected: TRSPrayerSet; begin ... config := new TJSONParser(); config.Load('my_script_config.json'); if config.GetArray('prayers', savedPrayers) then for i := 0 to savedPrayers.Count - 1 do selected += ERSPrayer(savedPrayers.Item[i].AsInt); prayerForm.SetSelected(selected); end; ``` - - - ## TRSPrayerForm SetAllowedPrayers ```pascal procedure TRSPrayerForm.SetAllowedPrayers(prayers: TRSPrayerSet); ``` Set's the defined prayers as the only selectable prayers. Prayers that arent defined here will be greyed out and unselectable. Use to narrow the selection for example, selections for offensive range prayer. Example: ```pascal {$I WaspLib/osrs.simba} var form: TScriptForm; tab: TTabSheet; prayerForm: TRSPrayerForm; begin form.Setup('Script settings'); tab := TLazTabSheet.Create(form.PageControl); prayerForm.Setup(tab, 50, 50); prayerForm.SetAllowedPrayers([ERSPrayer.EAGLE_EYE, ERSPrayer.RIGOUR]); form.Run(); end. ``` - - - ## TRSPrayerForm Setup ```pascal procedure TRSPrayerForm.Setup(buttonParent: Pointer; buttonLeft, buttonTop: Integer); ``` Setup the prayer form and add the select button to the defined parent at the defined position. Example: ```pascal {$I WaspLib/osrs.simba} var form: TScriptForm; tab: TTabSheet; prayerForm: TRSPrayerForm; begin form.Setup('Script settings'); tab := TLazTabSheet.Create(form.PageControl); prayerForm.Setup(tab, 50, 50) form.Run(); end; ```