So, say you wanted to use the 10’s value from a number, but not the 1’s or any remainders after it, you can extract it as a single value using this function. In this article, variable manipulation uses the Advanced Variable Box Op.
For the purposes of this article, and to see it in action, the first step is to create a variable to generate a random number.
- Use the Random Number command in the Advanced Variables to generate a random number range. The regular Variable Box will just add a random number to the existing number. However, we want to generate a new random number each time.
- Assign a variable with a random number between 0 and 999.
Units or 1’s
To calculate the units, the formula is:
Number % 10
Which simply divides the number by 10 and outputs the remainder.
- Store the random number variable into another variable for the 1’s.
- Add another Advanced Variable Box to modify the 1’s variable to a fixed value of 10, and set the Substitute divided remainder as the operation.
Tens or 10’s
For caluclating the tens, the modulus operation is:
(Number % 100) / 10
- Once again, set a variable for the 10’s to the same as the random number.
- Substitute the remainder with a fixed value of 100.
- And divide the result by 10.
At this point, you may start to see a pattern emerging. This is a surefire way of calculating and outputting much larger numbers…
Hundreds or 100’s
The formula for the hundreds is:
(Number % 1000) / 100
- So, as with the tens, a variable is created, this time for the 100’s, and set to the same as the random number.
- The remainder is set.
- And divide the result by 100.
Thousands or 1000’s
If you’re going to use higher numbers in HUDs, such as for stats, you’ll also need thousands as well.
The modulo operation to calculate this is:
(Number % 10000) / 1000
This is set up in the same way as the previous numbers using the variable to store the 1000’s.
The final product will look like this:
Each time the random number updates, it’ll separate the value into its component parts, returning an integer for the thousands, hundreds, tens and units so that they, in turn, can be used to update graphics referencing the number.
You can check to see if it’s running properly by pressing F5 during playtesting and monitor each variable.
Notes About HUDs
I doubt you’ll need more than the 1000’s for creating HUDs because if numbers exceed the maximums, they won’t go above that. The only exceptions are probably experience and gold. If you’re determined on using these in a HUD, then following the same pattern by adding zeros to numbers (as seen above).
I won’t go into actually creating HUDs here, as that would take an entire tutorial – perhaps more than one – to cover fully. However, perhaps I will some time in the future.
There are a number of issues with HUDs, notably when numbers refresh on the map. They tend to flicker on-screen, which is distracting and annoying. This is primarily due to the way that SGB uses and synchronizes auto-running events. It cycles through each one until conditions are true, but removes and then replaces the graphical numbers according to those conditions.
Additionally, each true condition overrides the previous ones, so another anomaly occurs with trailing zeroes. As an example, if your value is three digits long, the output on-screen should be 000. However, if the number is 7, the preceding zeros are displayed as blanks.
There is, of course, a workaround for this, but it isn’t reliable or efficient. I’ll put that in another tutorial some time in the future when, hopefully, I’ll have a proper fix for it.
This week’s Smile Game Builder tutorial, #35: Customizing Graphics ("Hidden" System), delves into customizing graphics, specifically some of the "hidden" graphics, i.e., those not directly importable via Add Assets. They are the Game Over image, equipment items (status screen) and message wait cursor (animated).
The music snippet featured in this video is one of my creations, Regrets, which was originally a game-exclusive melody for Otherworld (and it probably still is).
This is a simple fix for the oversight bug from the Skyrim Styled Book-Reading tutorial, which I only noticed after the video was uploaded.
The bug occurs where pages of the first book in the multiple book choices showed right before transitioning to the second book.
I was going to put this in another video, but since it’s so short I figured it didn’t merit one, so here’s the fix:
In the Check Cancel Reset event, simply add the following event command:
Add Variable box #33 Book # = 0.
The final result should look like this:
And that’s it! Whichever book you choose now displays the pages correctly.
This week’s Smile Game Builder tutorial, #34: Skyrim Styled Book-Reading, is online.
I show how to create a Skyrim styled book-reading system, where you can press the left and right keys to flip through the pages, and the cancel key to close the book.
There is a glitch – more an oversight – in this video where the pages of the first book shows before the second book’s pages show.
The solution is here.
The schedule for the next few tutorials is continuing the Crafting System with either mining or fishing (probably the latter). And then another Tips & Tricks video. I’d like to try and alternate the Crafting System, where every other weekend is a different part of crafting, evolving it into a comprehensive system.
The following bugs have been fixed in Version 18.104.22.168 (taken from SGB’s Announcements page on Steam):
- We’ve fixed an error; when you overwrite 3D characters from importing, the overwrite processes sometimes don’t work properly.
- We’ve fixed an error on Monster Tab; when you double click the option after select "Escape" of monster’s action, it gives you an error.
- We’ve fixed an error of "Teleport Event" panel; after you erase the teleporting target event on the map, an error message will appear when you start editing the event including the "Teleport Event" panel. This event cannot be edited anymore.
- We’ve adjusted the button of "Continue" on the top screen.
- We’ve fixed an error; when you use the 3D battle background "Fortress", the characters are placed in the ground during the battle.
- \Variable[x], represent a variable content with in the sentence, can be used on "Display Ticker Test" panel.
- We’ve fixed an error on an event panel, “Advanced Variable Box Option”; if assigned characters or items were deleted from "Edit Game Data", these events might not be able to edit.
- We’ve fixed the priority usage of system images; use placed materials within the game such as "Game Over" image.
- We’ve fixed an error; when you change the configuration from the top screen, it doesn’t reflect it for the game.
This is just a short post to show an experimental technique I’ve been working on, a Skyrim styled book-reading routine I recently put on Facebook.
The idea is to flip through the pages using the LEFT and RIGHT arrows to read the book’s contents, and then close the book with the CANCEL key.
There are two styles you can use:
- Single Book – Read a single book and flip through its pages.
- Multiple Books – Select the book you want to read and cycle through the pages of each.
The tutorial for this will be uploaded some time this month!
This week’s tutorial revisits the previous Cooking Tutorial (#24), adding a Cooking Level and Cooking XP.
This system is flexible so that it can be adapted for other crafting areas (or other systems) as well.
I’ll continue with the Crafting System for a while, unless inspiration dictates otherwise, so next week’s will likely either be mining or fishing.
This tutorial is just a short and simple technique to add animated images to Smile Game Builder.
You could use these for a variety of things and effects, including titles and short cut scenes.
Notes on Animation Sequencing in SGB
Smile Game Builder has no feature for playing in-game movies or GIFs. However, by using basic animation frame sequencing, it’s possible to emulate them. SGB is really good at running multiple parallel events without affecting performance. This includes animated images.
Each frame runs in sequence, with an appropriate amount of time between frames. Although any number of images in the sequence is possible, I’d recommend a limit of in between 12 and 15 (20 at a push). If you have several images, this can have a notable impact on overall file size. Although nowadays file sizes are no longer such an issue.
These links are mentioned in the video: