dabber's questions: vision to location
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Re: dabber's questions: object on unit
Many leaders are created in the side definitions. How do I set a variable in the scenario file and then use that variable to modify the leader in the side definition? Even if I set the variable in a prestart event, I get errors trying to access it in the side definition.
Re: dabber's questions: object on unit
If you figure it out, I'd love to know that, too! I can share a couple of workarounds I thought of, though:
- When you create the side, DON'T put a leader in it. Instead, write no_leader=yes. Then, in the prestart event, set your variable, then create your leader unit (making sure to write "canrecruit=yes" in its definition.)
- Since variables persist from one scenario to the next, you might be able to create a dummy scenario for setting variables that will be used in later scenarios.
- When you create the side, DON'T put a leader in it. Instead, write no_leader=yes. Then, in the prestart event, set your variable, then create your leader unit (making sure to write "canrecruit=yes" in its definition.)
- Since variables persist from one scenario to the next, you might be able to create a dummy scenario for setting variables that will be used in later scenarios.
Re: dabber's questions: object on unit
I'm not sure I understand the question entirely, but if you want to define a variable that is already accessed in a side definition, then I guess that's what a preload event is for, or equivalently, you could define it at the very end of the previous scenario.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: dabber's questions: object on unit
preload event doesn't work. A lua error shows up, and its definitely from using the variable. I am using 1.14.9 (which reminds me, I should upgrade to 14.14), so maybe that works in 1.15.x?
Re: dabber's questions: object on unit
Preload and variable should not be related. I doubt [side] supports variable evaluation.
So use case I would solve by setting objects during prestart.
So use case I would solve by setting objects during prestart.
Re: dabber's questions: object on unit
I solved the leader modification problem with a turn 1 event that does all the work. That is much easier long term, because now each scenario needs less editing. It also lets me work on any units spawned in the [side] definition automatically.
Re: dabber's questions: logging explanation
I solved my unit modification issue using a "unit placed" event.
Where in the documentation web pages is logging explained? Domains, levels, files, etc. I've pieced together enough knowledge to find my debug outputs in a file, but I have no understanding.
Where in the documentation web pages is logging explained? Domains, levels, files, etc. I've pieced together enough knowledge to find my debug outputs in a file, but I have no understanding.
Re: dabber's questions: objective notes
Is there a way to append to the existing notes section of objectives? I want to make one macro/event for the whole campaign that adds information without having to modify every scenario. Can I read the objectives into a variable in some fashion and then modify?
- Lord-Knightmare
- Discord Moderator
- Posts: 2364
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: dabber's questions: objective notes
Yesdabber wrote: ↑July 11th, 2022, 11:41 am Is there a way to append to the existing notes section of objectives? I want to make one macro/event for the whole campaign that adds information without having to modify every scenario. Can I read the objectives into a variable in some fashion and then modify?
You can store the descriptions as text and then have them adding to objectives.
like:
Code: Select all
{VARIABLE win_condition "Defeat Delfador"}
{VARIABLE defeat_condition "Death of Konrad"}
{SCENARIO_OBJECTIVE ("$win_condition") ("$defeat_conditon")}
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: dabber's questions: objective notes
Lord-Knightmare, thanks for the response, but that doesn't do what I'm after. Each scenario already sets objectives. I want to add the same note to every scenario objective, without having to modify each scenario file. I want to read the objective note previously set.
I tried {VARIABLE old_note $objective.note} but that didn't work.
I tried {VARIABLE old_note $objective.note} but that didn't work.
- beetlenaut
- Developer
- Posts: 2827
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: dabber's questions: objective notes
That's because "objective" is not a stored container variable, and there is no command to store it. You may be able to access the strings with lua, but you would still have to do it in each scenario file.
What I think you should do is use a program that allows you to search & replace across multiple files. Search your scenario folder for
[/objectives]
and replace it with Code: Select all
[note]
# Your new note
[/note]
[/objectives]
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Re: dabber's questions: objective notes
Thanks beetlenaut. Search+replace is probably the best option. I wanted a more programmatical method. Maybe I can still create that, I just have to put using it into each scenario.
Re: dabber's questions: recruit cost
How can I find the cost to recruit a unit, inside a scenario? Once a leader has too little money to recruit, I want him to do something. When he has enough money, I want him to do something else. For that to happen, I need to figure out the cost of the one unit type he can recruit. But since I want this to work for different leaders with different recruit types, I need a way to programmatically figure out the recruit cost.
- Pentarctagon
- Project Manager
- Posts: 5566
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: dabber's questions: objective notes
You could use [store_unit_type] and check its cost.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: dabber's questions: recruit cost
Thanks! Certainly that was a function I didn't realize existed. I think that means the critical code is basically this, and it works!
For anyone interested, this is the code I'm really using:
Code: Select all
[store_side]
side={SIDE}
variable=this_side
[/store_side]
[store_unit_type]
type=$this_side.recruit
variable=recruit_option
[/store_unit_type]
{VARIABLE min_gold $recruit_option.cost}
Code: Select all
#define RECRUIT_COST_MIN SIDE
## returns gold_min_to_recruit
[store_side]
side={SIDE}
variable=this_side
[/store_side]
[store_unit_type]
type=$this_side.recruit
variable=recruit_option
[/store_unit_type]
{VARIABLE gold_min_to_recruit 10000}
[foreach]
array=recruit_option
[do]
{ERROR "Recruit_Cost_Min : index $i cost $this_item.cost"}
[if]
[variable]
name=this_item.cost
less_than=$gold_min_to_recruit
[/variable]
[then]
{VARIABLE gold_min_to_recruit $this_item.cost.cost}
{ERROR "Recruit_Cost_Min : gold_min_to_recruit = $gold_min_to_recruit"}
[/then]
[/if]
[/do]
[/foreach]
{CLEAR_VARIABLE this_side,recruit_option}
#enddef
Last edited by dabber on September 1st, 2023, 3:19 pm, edited 1 time in total.