Help with FOCS macro arguments (nested, special chars)

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Post Reply
Message
Author
Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Help with FOCS macro arguments (nested, special chars)

#1 Post by Ophiuchus »

I am working on PR-2908.

While doing that I wanted to pass parenthesis to a macro argument. Is that possible?

Code: Select all

[[EG_SYSTEM_MINES(2 * (GameRule name = "RULE_SHIP_STRUCTURE_FACTOR"),75,EMPIRE)]]
Another question: is it possible to nest macro calls? Something like the following would be helpful

Code: Select all

[[EG_SYSTEM_MINES(2 * [[SHIP_STRUCTURE_FACTOR]],75,EMPIRE)]]
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Help with FOCS macro arguments (nested, special chars)

#2 Post by Geoff the Medio »

Something like this should work:

Code: Select all

[[WRAPPER_TEST(SetTargetResearch value = [[RESEARCH_PER_POP]])]]

WRAPPER_TEST
'''@1@'''

RESEARCH_PER_POP
'''0.2'''
But seemingly this doesn't:

Code: Select all

[[WRAPPER_TEST(SetTargetResearch value = (1 + CurrentTurn))]]

WRAPPER_TEST
'''@1@'''
and resolves, due to a failed substitution, to

Code: Select all

[[WRAPPER_TEST(SetTargetResearch value = (1 + CurrentTurn))]]
But this does:

Code: Select all

[[WRAPPER_TEST(SetTargetResearch value = 2*,1 + CurrentTurn)]]

WRAPPER_TEST
'''@1@ (@2@)'''
and is rendered in the pedia as:

Code: Select all

SetTargetResearch value = 2.000000 * (1.000000 + CurrentTurn)
And so does:

Code: Select all

[[WRAPPER_TEST(SetTargetResearch value = [[WRAPPER_TEST(1)]])]]

WRAPPER_TEST
'''@1@'''
and is rendered in the pedia as:

Code: Select all

SetTargetResearch value = 1.000000
So you can nest stuff, as long as the same kind of bracket doesn't appear without another kind of bracket between, I think.

Post Reply