Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How do you include a string variable in text?

A topic by Polyducks created Sep 03, 2019 Views: 210 Replies: 18
Viewing posts 1 to 5
Submitted

Hi! I was expecting something like
: print "$this_variable$ is here."

But I completed the classroom tutorial and looked through the docs and can't find anything on the subject.

Host

Funnily enough, I was just adding this to the upcoming cookbook.

: print {(

   my_variable + " is here"

)}

Submitted (1 edit)

Adventuron's syntax is so inconsistent - It seems that :, = and , are all interchangeable. And then it starts getting object notation!

Thanks for the info!

Host

It has the illusion of inconsistency. Which I agree, is a problem.

  • {()} is expression form
  • All commands start with :
  • Attributes are allocation with =
Submitted

Where can I use the expression form?

Host

You can use expression form in string_dynamics. A dynamic string is a string that can be referenced from regular strings, but will recalculate every time referenced.

I purposefully chose not to document this in Adventuron Classroom for fear of putting beginners off.

BEGINNERS : Don't be put off please :-)

start_at = village

locations {
   village  : location "You are in the village. {linger_desc}" ;
}

strings {   
   linger_desc : string_dynamic {(
      "You have been hanging around for " + 
      linger () +
      " turns."
   )}
}

Submitted

Yes! I can see why this would be scary. This is using some really unusual code design patterns. Is Adventuron a child of one of the old text game engines?

Host(+1)

No, it's a new engine. None of the old 8 bit engines have these particular design quirks. The quirks are my own doing For worse or better.

BEGINNERS: Don't be scared. This kind of thing isn't required.

Submitted (1 edit)

Is there a better place for me to suggest code additions/tweaks than in the jam community?

Host

Maybe the reddit?

https://www.reddit.com/r/adventuron/

Submitted

Thanks! Full disclosure, I'm also making a textbased game engine (called IFFY) - mine is in JS and JSON. Part of taking on this jam was seeing the process from a different perspective.

Submitted

In the system messages, there's also (from memory) things like ${entity}, ${verb}, ${noun} and so on. Are these documented anywhere?

Host

You are right, not yet documented, but I think that's the extent of it, apart from ${entity2}. I'll check.

Submitted

Again from memory, I think there's ${noun2}. These can be pretty useful in the right circumstances. For example, I've noticed that when I GET ALL and one of the items is scenery, it says something like "You can't get that." followed by "You get the apple." I'd prefer it to say, "You can't get the tree." followed by "You get the apple." I think I might change the system message to say "You can't get ${entity}."

Submitted(+2)

You can also use :append instead of :print to avoid the new line that's automatically appended with :print.

Submitted

:O! Excellent!

Submitted (1 edit)

Sorry if Im asking something dumb but, I want to print a integer variable ( number) not a string and I try this 

         : print "^c^ {secrets} < / 3 secrets founded.>";

its the only way i found to not get the error warning. But still not work.  I searched in document but I'm not finding any HOW TO for it works. 

How can I do that? 

: print {("^c^" + secrets + " / 3 secrets found.")}

Submitted

god lord... I had tried everything dont know how i never tested this way -,-

Many Thanks AG o/