ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Changing the name of an arbitrary location

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Changing the name of an arbitrary location

Postby The0didactus » Tue Feb 25, 2020 2:24 am

So...I recall posing a more general question relating to this, but I figured I'd ask a more specific question, in the hopes that someone figures it out.

As some of you know, I'm working on and off on a game that procedurally generates locations. I have the coding for most of the map at this point, a gigantic spaghetti-coded mess of tasks and variables and groups that, alone, is nearly 100 kb of text-based weirdness.

One final puzzle perplexes me. Rather than say exactly how I want it to work in the game, I'll describe a simpler version of what I want to do.
Imagine a grid like this

[location1][location2][location3]
[location4][location5][location6]
[location7][location8][location9]

now let's say I have a way to randomly drop an item into one of these 9 locations. We'll call the item "sarah's house"
What's the easiest way to make ANY short description location the item is dropped into become "sarah's house?"
your solution must not involve making a separate task for every location ("if sarah's house is in location 1 change the short description of location 1 to 'sarah's house'") in reality, we're talking about a grid of hundreds of locations, and more than one item like this....it would take hours upon hours to code that. I'll do it if I have to, but I'd appreciate some way to arbitrarily change short descriptions of locations based on what item "falls" there. It also "really has to" change the short location description, such that it appears on the game map.
The0didactus
 
Posts: 272
Joined: Sun Mar 30, 2014 8:20 pm
Points: 125

Re: Changing the name of an arbitrary location

Postby ralphmerridew » Tue Feb 25, 2020 2:46 am

I don't have A5 installed on my current computer, so I can't check whether these would work:

Can locations belong to classes or are classes reserved for objects? (If the first, you might try deriving all your rooms from a class, and putting alternate descriptions that set the short name into that.)

If that fails, you could:
1) Export the game as XML
2) Write a program in a non-IF language that would read that file, add a special description to every single location, then write out the modified file
3) Import the resulting module
But that would require knowing something like Perl, Python, or Javascript.
Bloodhounds can make you laugh and cuss in the same breath. They are endearing, faithful, and can sling drool ten feet in any direction. -- Virginia Lanier
User avatar
ralphmerridew
 
Posts: 2585
Joined: Fri Dec 13, 2002 11:56 pm
Location: Missouri
Points: 10

Re: Changing the name of an arbitrary location

Postby The0didactus » Tue Feb 25, 2020 4:53 am

ralphmerridew wrote:1) Export the game as XML
2) Write a program in a non-IF language that would read that file, add a special description to every single location, then write out the modified file
3) Import the resulting module
But that would require knowing something like Perl, Python, or Javascript.


I did parts of Tingalan using a system like this! I think I can actually make this work!
The0didactus
 
Posts: 272
Joined: Sun Mar 30, 2014 8:20 pm
Points: 125

Re: Changing the name of an arbitrary location

Postby Denk » Tue Feb 25, 2020 5:05 am

I thought I knew how to do it from within ADRIFT but then I stumbled upon a bug, which Lazzah reported back in 2016: http://www.adrift.co/bug/19129

As a consequence, the action:
SET 'location name' SHORT LOCATION DESCRIPTION TO 'new name'
doesn't work.

So until this bug gets fixed, I doubt it can be done from within ADRIFT. We might as well upvote the bug-report.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
Denk
 
Posts: 401
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark
Points: 226

Re: Changing the name of an arbitrary location

Postby DazaKiwi » Sat Feb 29, 2020 9:18 pm

I made a demo of how to do it, although in my demo you would have to alter it so it would only work in specific locations and when the player enters that location that the name is changed and then moving an object to that location. This demo is more of a general one rather than specifically doing what Theo asked but still applies, as i have store owners matched and moved to the randomly named locations. The 'read me' shows how it works as an overview for those learning and i like to add info in general for myself if i ever go back to something in the future to remember. Hope this is helpful.
Attachments
LocNaming_v2_1.taf
(17.53 KiB) Downloaded 44 times
User avatar
DazaKiwi
 
Posts: 712
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 21

Re: Changing the name of an arbitrary location

Postby The0didactus » Sun Mar 01, 2020 12:52 am

Oh, *thats* how you use parameters.

Yes,this is exactly what I was looking for.
This actually probably could have made the lost coastlines procedural generator a lot simpler, but its too late for that now.
The0didactus
 
Posts: 272
Joined: Sun Mar 30, 2014 8:20 pm
Points: 125

Re: Changing the name of an arbitrary location

Postby Denk » Sun Mar 01, 2020 3:22 pm

DazaKiwi wrote:I made a demo of how to do it, although in my demo you would have to alter it so it would only work in specific locations and when the player enters that location that the name is changed and then moving an object to that location. This demo is more of a general one rather than specifically doing what Theo asked but still applies, as i have store owners matched and moved to the randomly named locations. The 'read me' shows how it works as an overview for those learning and i like to add info in general for myself if i ever go back to something in the future to remember. Hope this is helpful.
Ahh - of course - thanks DazaKiwi! :Thanks:

So a very simple example would be to initially name the location e.g. %Loc1% i.e. the text variable Loc1. Whenever the variable is altered from a task, the name of the location changes. So for more advanced examples like yours, group properties can be applied, though they are not necessary for modifying location names.
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
Denk
 
Posts: 401
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark
Points: 226

Re: Changing the name of an arbitrary location

Postby The0didactus » Sun Mar 01, 2020 3:56 pm

Yeah this demo solved a problem I'd been working on for almost a year.

I will note that alternate location short descriptions don't seem to work at all. At least, whenever I add even one to my game, it crashes upon beginning play. This feature isn't like, essential, but it might explain weird crashes in other people's games.
The0didactus
 
Posts: 272
Joined: Sun Mar 30, 2014 8:20 pm
Points: 125


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 2 guests