Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How do I do simple arithmetic?

A topic by Garry Francis created Sep 06, 2019 Views: 138 Replies: 10
Viewing posts 1 to 5
Submitted(+1)

Why is everything in Adventuron so friggin' complicated? All I want to do is increase the score by (say) 5 points when I complete a task. I can increment it, I can test it, I can print it, I can set it to a fixed value, but how on earth do I say: score = score + 5?

: add var ="score" value = "5";

(One way of doing it)

Submitted

That works. You're a champion Gareth. How do you find these things out? It's not in the doco.

I've now got scoring working and the score shows in the header. This wasn't intentional, but it's starting to look a little bit Infocom-ish, except that it's got that old-school retro look. Love it.

:-) This will be my fifth Adventuron-powered game, so I've used a fair amount of this stuff before... or pestered Chris to tell me how to do a lot of this stuff before.

There's code like that in the Scout's Honour example code, linked to in the sticky post. It has some interesting examples in it, but I wouldn't code an Adventuron game like that these days as it doesn't really make good use of a lot of Adventuron's strengths and special features... I was basically coding like I would've done on a Spectrum with PAWs... so I did a lot of stuff with booleans, where I'd now do them a lot simpler with Adventuron's own checks like has_not_created. (I'm not 100% sure that was even in Adventuron when I first wrote the game)

Host

Garry, are you not using the CONTROL + SPACE command to find out the available commands. You are right that ": add" it wasn't listed in the reference guide (it is now), but common commands are easy to discover using the CONTROL + SPACE technique (or ALT + SPACE on Chromebooks).

In the animation shown below, add is very visible. I wonder if you are using the CONTROL + SPACE / ALT + SPACE method?


Submitted

Is there a way to unlock the autocomplete for all the commands? The autocomplete is mostly how I learned Adventuron!

Submitted

Yes, I use Ctrl+Space. "add" wasn't there when I tried. I just tried it again and see that "add" has been added, as well as "append" and one or two others. For example, I just discovered "refresh_header" (which I needed to refresh the score in the header prior to "end_game"), but "set_string" is still not there. I worked this one out by trial and error.

Note that Ctrl+Space is very dicky. For me, it mostly only works on a new line, it doesn't work when you've got a syntax error and the hint suggestions (as shown in your tutorial videos) don't work for me at all.

Is there a master list of all the commands anywhere? At one point I had a syntax error and when I hovered over the error icon in the left margin, the tool tip showed hundreds of suggestions - so many, in fact, that they wouldn't all fit on the screen.

Host

Control + Space will almost always work on a new line, but yes, not if there is a serious syntax error (like a missing } or ;).

If Control + Space does not work, try pressing Control + S (Save) first, to see if there is a serious syntax error.

As far as a master list of commands, no, there is not that right now, but I hear the call, and I'll try to put something together.

There was (and is) a reason why a lot of commands are omitted. set_string is obscured because I don't think it is required for simple adventure games.

It's a slippery slope really when you start down the path of what's useful to intermediate users. I think that a lot of people here are moving way beyond the simple use-cases and into intermediate / advanced use cases.

I did have a separate version of Adventuron planned for that, without the "classroom" monikor. 

I will reveal set_string to the autocomplete in the next release, but I believe "add" has always been there, from day one of classroom. I certainly added "append" to the list of revealed commands.

Submitted

I don't need this at the moment, but is there a command similar to :add for :subtract, :multiply and :divide?

Host
  • // Use expression form to calculate an integer result
  • // Floating point not supported by Adventuron, only integer mathematics
  • // The statement below sets c to be the value of "a" multiplied by the value of "b"

 : set_integer var = "c"  {(a * b)}