OpenXRay / OpenXRay/xray-16

Add parameters to actions & conditions in dialogs.xml

Open
#105 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement
Dominant language
C++
Stars
3.6k
Forks
536
Avg merge
6d 1h
Merged PRs (30d)
3

Description

Now modmakers must write a similar separate functions for different things.
For example,

<phrase id = "1">
    ...
    <precond> file.hasItem_pm </ precond>
    <action> file.addItem_ak74 </ action>
    ...
</phrase>

<phrase id = "2">
    ...
    <precond> file.hasItem_vodka </ precond>
    <action> file.addItem_bread </ action>
    ...
</phrase>
function addItem_ak74 (first_speaker, second_speaker)
    return dialogs.relocate_item_section_to_actor (first_speaker, second_speaker, 'wpn_ak74')
end

function addItem_Bread (first_speaker, second_speaker)
    return dialogs.relocate_item_section_to_actor (first_speaker, second_speaker, 'bread')
end

function hasItem_pm (first_speaker, second_speaker)
    return db.actor:object('wpn_pm ') ~ = nil
end

function hasItem_vodka (first_speaker, second_speaker)
    return db.actor:object('vodka ') ~ = nil
end

I propose to make support arguments so as not to produce a bunch of similar functions.

For example,

<phrase id = "1">
    ...
    <precond> file.hasItem ({"wpn_pm"}) </ precond>
    <action> file.addItem ({"wpn_ak74"}) </ action>
    ...
</phrase>

<phrase id = "2">
    ...
    <precond> file.hasItem ({"vodka"}) </ precond>
    <action> file.addItem ({"bread"}) </ action>
    ...
</phrase>
function addItem (first_speaker, second_speaker, sections)
    for k, v in pairs (sections)
        dialogs.relocate_item_section_to_actor (first_speaker, second_speaker, v)
    end
end

function hasItem (first_speaker, second_speaker, sections)
    for k, v in pairs (sections)
        if (db.actor:object(v) == nil) then
            return false
        end
    end
    return true
end

It does not greatly affect the already made dialogues, in a pinch, you can go by regular expressions of action\precond\.. and add to the end of the parenthesis

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review dialogs.xml and the Lua action and precondition examples in the issue to trace how these handlers are currently referenced and invoked. Define support for argument lists while preserving existing dialogue syntax; the examples should no longer require one function per item, and existing dialogues should continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, xml
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.