Page 1 of 1

Changing the name of an arbitrary location

PostPosted: Tue Feb 25, 2020 2:24 am
by The0didactus
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.

Re: Changing the name of an arbitrary location

PostPosted: Tue Feb 25, 2020 2:46 am
by ralphmerridew
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.

Re: Changing the name of an arbitrary location

PostPosted: Tue Feb 25, 2020 4:53 am
by The0didactus
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!

Re: Changing the name of an arbitrary location

PostPosted: Tue Feb 25, 2020 5:05 am
by Denk
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.

Re: Changing the name of an arbitrary location

PostPosted: Sat Feb 29, 2020 9:18 pm
by DazaKiwi
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.

Re: Changing the name of an arbitrary location

PostPosted: Sun Mar 01, 2020 12:52 am
by The0didactus
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.

Re: Changing the name of an arbitrary location

PostPosted: Sun Mar 01, 2020 3:22 pm
by Denk
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.

Re: Changing the name of an arbitrary location

PostPosted: Sun Mar 01, 2020 3:56 pm
by The0didactus
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.