Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Hero Lab Forums > HL - Pathfinder Roleplaying Game

Notices

Reply
 
Thread Tools Display Modes
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old July 28th, 2019, 07:56 AM
I'm trying to deepen my knowledge of hero labs code and break into some of the more crazy aspects of the code. :P So this is completely new territory for me hehe.

I am trying to create a custom ability with a chooser that references an element within a gizmo. I have found a way to grab the name of the specific entity that I want to grab, but I cannot find a way to use that in the custom expression.

What I want to do is have a dropdown that selects each settlement in the kingdom so I can make adjustments on buildings do in each settlement and a variety of other operations.

I can grab the name of each settlement and display it in the debug using a script but I cant figure out a way to use this to create a custom expression to create a custom ability which uses the Name of the Settlement for the choice rather than the name of the parent terrain type (which is the parent element the gizmo is attached to). Or the name of the settlement tag (either Settlement or Settlement Expansion)

Render/9000
Code:
~ Seach the Kingdom Hexes and find those with a settlement
      foreach pick in hero from KingHex where "HexFeature.Settle"
      
      debug "Settlement Names: " & eachpick.field[hxName].text
      debug "Settlement IDSTRING: " & eachpick.idstring
      debug "thingid." & eachpick.idstring & "|"
     nexteach
Using the above code I can grab the name settlements and the id if the terrain but neither is very useful for creating a custom expression.
TobyFox2002 is offline   #1 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old July 28th, 2019, 08:11 AM
Here's my article about traveling between contexts (since what you want to do is to travel from the hex pick you've found to the gizmo of that pick, and then to the children within that gizmo: http://forums.wolflair.com/showthread.php?t=21663


Post #3 is about the pick context, and "eachpick" lets you target a specific pick, so that's the context you're in.
Mathias is offline   #2 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old July 28th, 2019, 09:51 AM
Well, I had already examined that, and took from it what I could. I am honestly begining to think that it isnt an issue with the code that I have as it appears from the debug output that I should get some positive result.

Instead when I look at the usrCandid1 gives um.. EVERYTHING as an option instead of being limited to the custom expression that I HL says that it should be using.

Using this code:
Code:
    debug "~~~~~~ Settlement & Building Selection ~~~~~~~"
    debug "{b}Location:{/b} cLGCoEdict | {b}Timing:{/b} Render/999999/1"
~ Seach the Kingdom Hexes and find those with a settlement
      foreach pick in hero from KingHex where "HexFeature.Settle"
debug "==============================================="
debug "{b}Settlement Name:{/b} " & eachpick.field[hxName].text
        foreach pick in eachpick.gizmo where "TerrImpCat.Building"
           debug "{b}Gizmo ID:{/b} " & eachpick.idstring
        nexteach

       field[abText].text &= "thingid." & eachpick.idstring & "|"
     nexteach
debug "==============================================="
debug "=====================END======================"
      debug "abText : " & field[abText].text
      field[usrCandid1].text &= field[abText].text
See the attached image for the output for the result. Not sure what I'm doing wrong..
Attached Images
File Type: png what i'm trying to do.png (317.0 KB, 3 views)
TobyFox2002 is offline   #3 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old July 28th, 2019, 01:26 PM
Problem #1 - as coded, your candidate Id will always end in "|", with no final tag Id - that will fail to be recognized as a valid candidate expression, meaning HL defaults to "absolutely everything" for the drop-down.



Problem #2 - A drop-down menu can only select within the container it is in (or from inside a gizmo, it can be set to select things in the hero container). It cannot select from among the picks inside another pick's gizmo.


Try adding a "building" that can be added to the settlement it's being applied to that can then select from among the buildings in its same settlement (same gizmo). then, if this is more of an ability than a building you'd build in some settlement, you can look for ways to hide it in most cases, but still leave it visible within that settlement so the user can select the building to apply it to.


Oh, and coding style note - don't use idstring unless there's no other option. eachpick.tagids[thingid.?,"|"] would give you the same result.
Mathias is offline   #4 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old July 28th, 2019, 01:40 PM
Quote:
Originally Posted by Mathias View Post
Problem #1 - as coded, your candidate Id will always end in "|", with no final tag Id - that will fail to be recognized as a valid candidate expression, meaning HL defaults to "absolutely everything" for the drop-down.



Problem #2 - A drop-down menu can only select within the container it is in (or from inside a gizmo, it can be set to select things in the hero container). It cannot select from among the picks inside another pick's gizmo.


Try adding a "building" that can be added to the settlement it's being applied to that can then select from among the buildings in its same settlement (same gizmo). then, if this is more of an ability than a building you'd build in some settlement, you can look for ways to hide it in most cases, but still leave it visible within that settlement so the user can select the building to apply it to.


Oh, and coding style note - don't use idstring unless there's no other option. eachpick.tagids[thingid.?,"|"] would give you the same result.
1) That is the exact problem I was running into, and couldnt figure out why. So using the tagid would correct that? I got around it by using eachpick.assign shoving a custom tag to each of the hexes with a settlement and using that as the custom expression. But your idea seems like it would be easier.

2) Yeah, adding new buildings isnt the issue, I need to access EXISTING buildings because I need to alter their fields and tags. So I assumed that the only way to do that would be to find the settlement they are in and then just going down until I get to the building... That isnt possible? How would I alter tags and fields of existing buildings?
TobyFox2002 is offline   #5 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old July 28th, 2019, 01:55 PM
tagid wouldn't solve that, but string manipulation should always be avoided if you can - it's faster for HL to process tags than strings.

Here's what can:

Code:
field[abText].text = splice(field[abText].text,eachpick.tagids[thingid.?],"|")

splice() appends the first two arguments together, and if both of them have something in them, it puts the third argument in-between them, so that way, there's only ever "|" between tags - since field[abText].text is empty for the very first item it finds, it doesn't add the "|", but it does for all the other tags.


You can alter their tags and fields, but you can't use a drop-down to select which one to alter - drop-downs have only two containers they can choose from - their own, or the hero, and here, you have an ability that's external to the settlement that wants to offer a drop-down of choices within the gizmo of something else.


So, the work-around I'm suggesting is that instead of running this script from an external thing, have the user add a fake building to the settlement that can then apply changes to the other things in that same settlement.
Mathias is offline   #6 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old July 28th, 2019, 02:21 PM
Quote:
Originally Posted by Mathias View Post
So, the work-around I'm suggesting is that instead of running this script from an external thing, have the user add a fake building to the settlement that can then apply changes to the other things in that same settlement.
You mean like a proxy starting point, so we dont have to navigate 16 million different transitions? And to skip the obvious problem of not being able to use the dropdown to select the correct building?

Hmm, is there an example of this in concept so I'd be able to see it in practice? I'm not exactly sure how I'd force bootstrap a building to every settlement on demand.

And also make it hidden so that the player cannot see it. I'd also at least like to be able to keep have the chooser for the player's benefit to keep track of what they are altering or working with. Even if it doesnt functionally do anything.

Thank you for helping with this, I am enjoying the challenge of learning new aspects of code.
TobyFox2002 is offline   #7 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old July 28th, 2019, 02:38 PM
If this is a thing that's selecting a specific building in every settlement, but always applies to all settlements, that's entirely different than the ability I thought you were writing, based on the questions you've been asking. Please post the description text of what you're creating, so I can evaluate what the best approach is.
Mathias is offline   #8 Reply With Quote
TobyFox2002
Senior Member
 
Join Date: Nov 2013
Location: Andover, Ma
Posts: 632

Old July 28th, 2019, 02:54 PM
Quote:
Originally Posted by Mathias View Post
If this is a thing that's selecting a specific building in every settlement, but always applies to all settlements, that's entirely different than the ability I thought you were writing, based on the questions you've been asking. Please post the description text of what you're creating, so I can evaluate what the best approach is.
The problem I am working on at the moment is the Commission Edict from Ult. Rulership.

The rulers of a city can commission an item to be constructed provided that their is an appropriate building that can make magical items of that type.

You need to know what settlement to use and which building in that settlement to use. You also need to know the gp cost of the item for calculating unrest.

If their are more than one building that can produce magical items (in a single city) and you force more than one the unrest increases.

You can also use the commission edict to reduce the BP cost of buildings in the same settlement or terrain improvements in adjacent hexes by 2 BP for a medium for EACH major item slot being expended and by 1 for each medium item slot expended. This alternate use, i am fairly certain I know how to do once I can manipulate the buildings.

So, yes Specific settlement and specific singular buildings within that settlement. This would only affect ONE building of that type within a settlement not all buildings in the settlement nor all buildings of that type in the kingdom.

This basic concept will be needed repeatedly, as will the ability to alter ALL buildings (both in a settlement and kingdom), which I expect to give me a great deal of trouble if I cannot figure a way to add additional tags and fields to some elements. But I will cross that bridge when I come to them.
TobyFox2002 is offline   #9 Reply With Quote
Mathias
Senior Member
Lone Wolf Staff
 
Join Date: May 2005
Posts: 13,207

Old July 28th, 2019, 03:01 PM
This is not something we would implement with something that chooses settlements and buildings if we were doing this book (maybe just a text field to let the user write those in) - this doesn't create long-term record keeping entries on the kingdom other than the initial cost of the edict, and recording the finished magic item at the end - just let the user fill in the amount of unrest for the exact details of how they're implementing the edict.

Manipulating costs of things that the user is purchasing before the user purchases them (so that the cost is changed for the user) is not something that can be done from the editor - you need access to the core files and the purchase scripts. So that will also have to be a text-only ability that is up to the user to apply at the game table.
Mathias is offline   #10 Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:15 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.