Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compile-time switches #22

Closed
huderlem opened this issue Nov 2, 2019 · 3 comments
Closed

Support compile-time switches #22

huderlem opened this issue Nov 2, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@huderlem
Copy link
Owner

huderlem commented Nov 2, 2019

Allow compile-time switches to be passed into the poryscript compiler. This will allow things like localization or game version differences.

Idea for syntax:

script LittlerootTown_RivalHouseSign {
    lockall
    checkplayergender
    if (var(VAR_RESULT) == MALE) {
        poryswitch(LANGUAGE) {
            DE: msgbox("Das ist MAY's Haus.")
            FR {
                msgbox("French words.")
                foo(1, 2)
            }
            _:  msgbox("This is any language except German and french.")
        }
    }
    releaseall
}

You would invoke poryscript like this:

poryscript.exe -s LANGUAGE=DE -s GAME_VERSION=RUBY
@huderlem huderlem added the enhancement New feature or request label Nov 2, 2019
@huderlem
Copy link
Owner Author

huderlem commented Nov 3, 2019

text MyText {
    poryswitch(LANGUAGE) {
        DE: "Das ist MAY's Haus."
        FR: format("French words.")
        _:  "Fallback text\n"
             "Still the same text."
    }
}

movement MyMovement {
    poryswitch(GAME_VERSION) {
        RUBY {
           walk_left
           walk_right
        }
        SAPPHIRE: walk_up
    }
}

@huderlem
Copy link
Owner Author

huderlem commented Nov 6, 2019

3c22421

@huderlem huderlem closed this as completed Nov 6, 2019
@martingaldeca
Copy link

This seems to me like a very useful thing, but for non technical users add it into the makefile can be difficult. I suggest to add in the readme how to modify the makefile to make this clear. I was trying to open a PR but it seems that it is not possible to open new branches.

I wanted to suggest this change into the README file, just after line 789:

### Add switches to a decomp project

If you want to add any switch to your project automatically, you need to modify the Makefile this way (Note, don't add the `+` symbol at the start of the lines. That's just to show the line is being added.):
```diff
FIX := tools/gbafix/gbafix$(EXE)
MAPJSON := tools/mapjson/mapjson$(EXE)
JSONPROC := tools/jsonproc/jsonproc$(EXE)
SCRIPT := tools/poryscript/poryscript$(EXE)
+ YOUR_SWITCH := YOUR_SWITCH_VALUE
```
```diff
sound/%.bin: sound/%.aif ; $(AIF) $< $@
+ data/%.inc: data/%.pory; $(SCRIPT) -i $< -o $@ -fc tools/poryscript/font_config.json -s YOUR_SWITCH=$(YOUR_SWITCH)
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants