This probably won't make much sense, but...

Greetings humans and fellow Forum-Wanderers.

I recently found my old Minecraft Alpha save file and started playing on it.

Pretty soon after that I was building a randomgen, Minecraft-esque game.

I recently ended up running into a problem.
So, there are 24 'slots' (that's what I am calling the individual variables groups that make up the map), each with a random type.

Currently, the game's biomes are only beach, forest, desert, mountain, and prairie. I intend to keep it that way until beta testing.

However, the random variable system will mean that I may have to use a massive list of if-then-else coding. I'm trying to minimise clutter to reduce loading times.

If there is any problem with anything I am doing, or if anyone works out how to do what I'm trying to do without a massive list of if-then variables, please tell me.

Here's the full code if you want it (be aware I'm only about 10% through, I still have to add the crafting, inventory, base building, hunger, thirst, food, mining, building, etc, etc):


    squiffy.getRndInteger = function(min,max){
        return Math.floor(Math.random()*max)+min;
    };
    set("pos_0", squiffy.getRndInteger(0,5));
    set("pos_1", squiffy.getRndInteger(0,5));
    set("pos_2", squiffy.getRndInteger(0,5));
    set("pos_5", squiffy.getRndInteger(0,5));
    set("pos_4", squiffy.getRndInteger(0,5));
    set("pos_5", squiffy.getRndInteger(0,5));
    set("pos_6", squiffy.getRndInteger(0,5));
    set("pos_7", squiffy.getRndInteger(0,5));
    set("pos_8", squiffy.getRndInteger(0,5));
    set("pos_9", squiffy.getRndInteger(0,5));
    set("pos_10", squiffy.getRndInteger(0,5));
    set("pos_11", squiffy.getRndInteger(0,5));
    set("pos_12", squiffy.getRndInteger(0,5));
    set("pos_13", squiffy.getRndInteger(0,5));
    set("pos_14", squiffy.getRndInteger(0,5));
    set("pos_15", squiffy.getRndInteger(0,5));
    set("pos_16", squiffy.getRndInteger(0,5));
    set("pos_17", squiffy.getRndInteger(0,5));
    set("pos_18", squiffy.getRndInteger(0,5));
    set("pos_19", squiffy.getRndInteger(0,5));
    set("pos_20", squiffy.getRndInteger(0,5));
    set("pos_21", squiffy.getRndInteger(0,5));
    set("pos_22", squiffy.getRndInteger(0,5));
    set("pos_23", squiffy.getRndInteger(0,5));
    set("pos_24", squiffy.getRndInteger(0,5));
    
<!--Item Setup-->
@set pos_item_0 =0
@set amount_item_0 =0
@set type_item_0 =0

<!--Item List-->
<!--0, Sand-->

<!--Pos Setup-->
@set player_pos =0
@set player_up =0
@set player_side =0

<!--Pos Type Setup-->
@set pos_type_0 =beach
@set pos_type_1 =forest
@set pos_type_2 =mountain
@set pos_type_3 =desert
@set pos_type_4 =prairie
{if pos_0=0:{@pos_0_type=@pos_type_0}}
{if pos_0=1:{@pos_0_type=@pos_type_1}}
{if pos_0=2:{@pos_0_type=@pos_type_2}}
{if pos_0=3:{@pos_0_type=@pos_type_3}}
{if pos_0=4:{@pos_0_type=@pos_type_4}}
<!--Full GUI Setup-->
@set player_hp_current =5
@set player_hp_max =5
@set player_thirst_current =0
@set player_hunger_current =0

{if player_pos=0:{@player_pos_type=@pos_0_type}}
{if player_pos=1:{@player_pos_type=@pos_1_type}}
{if player_pos=2:{@player_pos_type=@pos_2_type}}
{if player_pos=3:{@player_pos_type=@pos_3_type}}
{if player_pos=4:{@player_pos_type=@pos_4_type}}
{if player_pos=5:{@player_pos_type=@pos_5_type}}
{if player_pos=6:{@player_pos_type=@pos_6_type}}
{if player_pos=7:{@player_pos_type=@pos_7_type}}
{if player_pos=8:{@player_pos_type=@pos_8_type}}
{if player_pos=9:{@player_pos_type=@pos_9_type}}
{if player_pos=10:{@player_pos_type=@pos_10_type}}
{if player_pos=11:{@player_pos_type=@pos_11_type}}
{if player_pos=12:{@player_pos_type=@pos_12_type}}

Welcome to Survival!

An incredibly immersive adventure game with a randomgen system.

[Begin]

[Begin]:

@clear
You wake up, alone. You can't remember how you got here.

You are {if pos_0=0:on}{if pos_0=1:in}{if pos_0=2:on}{if pos_0=3:in}{if pos_0=4:on} a {pos_0_type}.

[Continue]

[Continue]:
@clear
HP: {player_hp_current}/{player_hp_max}<br>
Hunger: {player_hunger_current}%<br>
Thirst: {player_thirst_current}%<br><br>

[Crafting]<br>
[Inventory]<br>
<pre>
   {if player_up=0:^}{else:[^]}
{if player_side=0:<}{else:[<]}     {if player_side=-5:>}{else:[>]}
   {if player_up=-5:v}{else:[v]}
</pre>
 
[^]:
@inc player_up 1
@clear
HP: {player_hp_current}/{player_hp_max}<br>
Hunger: {player_hunger_current}%<br>
Thirst: {player_thirst_current}%<br><br>

[Crafting]<br>
[Inventory]<br>
<pre>
   {if player_up=0:^}{else:[^]}
{if player_side=0:<}{else:[<]}     {if player_side=-5:>}{else:[>]}
   {if player_up=-5:v}{else:[v]}
</pre>
 
[<]:
@inc player_side 1
@clear
HP: {player_hp_current}/{player_hp_max}<br>
Hunger: {player_hunger_current}%<br>
Thirst: {player_thirst_current}%<br><br>

[Crafting]<br>
[Inventory]<br>
<pre>
   {if player_up=0:^}{else:[^]}
{if player_side=0:<}{else:[<]}     {if player_side=-5:>}{else:[>]}
   {if player_up=-5:v}{else:[v]}
</pre>
 
[>]:
@dec player_side 1
@clear
HP: {player_hp_current}/{player_hp_max}<br>
Hunger: {player_hunger_current}%<br>
Thirst: {player_thirst_current}%<br><br>

[Crafting]<br>
[Inventory]<br>
<pre>
   {if player_up=0:^}{else:[^]}
{if player_side=0:<}{else:[<]}     {if player_side=-5:>}{else:[>]}
   {if player_up=-5:v}{else:[v]}
</pre>
 
[v]:
@dec player_up 1
@clear
HP: {player_hp_current}/{player_hp_max}<br>
Hunger: {player_hunger_current}%<br>
Thirst: {player_thirst_current}%<br><br>

[Crafting]<br>
[Inventory]<br>
<pre>
   {if player_up=0:^}{else:[^]}
{if player_side=0:<}{else:[<]}     {if player_side=-5:>}{else:[>]}
   {if player_up=-5:v}{else:[v]}
</pre>
 
[Crafting]:
 
[Inventory]:

[]:
{if player_up=0:{if player_side=0:{@player_pos=0}}}```

I'm curious, too. One place squiffy is weak is in loops and massive amounts of data. Curious if there is an elegant solution to this...


Why not use Quest's Text Adventure option???
It has all the commands you need, no need to try and force something to work...
And the programming isn't that much harder.


DarkLizerd, I though about using quest but decided not to use it for two reasons.

One, quest requires you to be logged in to save your game, and since most of the people that play my games (my friends) don't have an account, so they wouldn't be able to save their game (and they're stubborn, so they won't make an account!)

Two, I have much more experience with squiffy and so I would rather build games on it, even if it means testing the boundaries of squiffy coding.


Hello.

I can probably help a little, if you don't mind using JS in place of Squiffy code in a few places.

For example, I would change the beginning of your existing code:

    squiffy.getRndInteger = function(min,max){
        return Math.floor(Math.random()*max)+min;
    };
    set("pos_0", squiffy.getRndInteger(0,5));
    set("pos_1", squiffy.getRndInteger(0,5));
    set("pos_2", squiffy.getRndInteger(0,5));
    set("pos_5", squiffy.getRndInteger(0,5));
    set("pos_4", squiffy.getRndInteger(0,5));
    set("pos_5", squiffy.getRndInteger(0,5));
    set("pos_6", squiffy.getRndInteger(0,5));
    set("pos_7", squiffy.getRndInteger(0,5));
    set("pos_8", squiffy.getRndInteger(0,5));
    set("pos_9", squiffy.getRndInteger(0,5));
    set("pos_10", squiffy.getRndInteger(0,5));
    set("pos_11", squiffy.getRndInteger(0,5));
    set("pos_12", squiffy.getRndInteger(0,5));
    set("pos_13", squiffy.getRndInteger(0,5));
    set("pos_14", squiffy.getRndInteger(0,5));
    set("pos_15", squiffy.getRndInteger(0,5));
    set("pos_16", squiffy.getRndInteger(0,5));
    set("pos_17", squiffy.getRndInteger(0,5));
    set("pos_18", squiffy.getRndInteger(0,5));
    set("pos_19", squiffy.getRndInteger(0,5));
    set("pos_20", squiffy.getRndInteger(0,5));
    set("pos_21", squiffy.getRndInteger(0,5));
    set("pos_22", squiffy.getRndInteger(0,5));
    set("pos_23", squiffy.getRndInteger(0,5));
    set("pos_24", squiffy.getRndInteger(0,5));
    
<!--Item Setup-->
@set pos_item_0 =0
@set amount_item_0 =0
@set type_item_0 =0

<!--Item List-->
<!--0, Sand-->

<!--Pos Setup-->
@set player_pos =0
@set player_up =0
@set player_side =0

<!--Pos Type Setup-->
@set pos_type_0 =beach
@set pos_type_1 =forest
@set pos_type_2 =mountain
@set pos_type_3 =desert
@set pos_type_4 =prairie
{if pos_0=0:{@pos_0_type=@pos_type_0}}
{if pos_0=1:{@pos_0_type=@pos_type_1}}
{if pos_0=2:{@pos_0_type=@pos_type_2}}
{if pos_0=3:{@pos_0_type=@pos_type_3}}
{if pos_0=4:{@pos_0_type=@pos_type_4}}
<!--Full GUI Setup-->
@set player_hp_current =5
@set player_hp_max =5
@set player_thirst_current =0
@set player_hunger_current =0

{if player_pos=0:{@player_pos_type=@pos_0_type}}
{if player_pos=1:{@player_pos_type=@pos_1_type}}
{if player_pos=2:{@player_pos_type=@pos_2_type}}
{if player_pos=3:{@player_pos_type=@pos_3_type}}
{if player_pos=4:{@player_pos_type=@pos_4_type}}
{if player_pos=5:{@player_pos_type=@pos_5_type}}
{if player_pos=6:{@player_pos_type=@pos_6_type}}
{if player_pos=7:{@player_pos_type=@pos_7_type}}
{if player_pos=8:{@player_pos_type=@pos_8_type}}
{if player_pos=9:{@player_pos_type=@pos_9_type}}
{if player_pos=10:{@player_pos_type=@pos_10_type}}
{if player_pos=11:{@player_pos_type=@pos_11_type}}
{if player_pos=12:{@player_pos_type=@pos_12_type}}

Welcome to Survival!

...to this:


    squiffy.getRndInteger = function(min,max){
        return Math.floor(Math.random()*max)+min;
    };
    var i = 0;
    while (i<25){
        set ("pos_"+i, squiffy.getRndInteger(0,5));
        i++;
    }
    /* <! -- Item Setup --> */
    set ("pos_item_0", 0);
    set ("amount_item_0", 0);
    set ("type_item_0", 0);
    /* <!--Item List--> */
    /* <!--0, Sand--> */

    /* <!--Pos Setup--> */
    set ("player_pos", 0);
    set ("player_up", 0);
    set ("player_side", 0);

    /* <!--Pos Type Setup--> */
    set ("pos_type_0","beach");
    set ("pos_type_1", "forest");
    set ("pos_type_2", "mountain");
    set ("pos_type_3", "desert");
    set ("pos_type_4", "prairie");
    set ("pos_0_type", get ("pos_type_"+get("pos_0")));



    /* <!--Full GUI Setup--> */
    set ("player_hp_current", 5);
    set ("player_hp_max", 5);
    set ("player_thirst_current", 0);
    set ("player_hunger_current", 0);
    set ("player_pos_type", get ("pos_"+get("player_pos")+"_type"));


Welcome to Survival!

That seems to work on my end, and it takes that bit of code from 74 lines to 39 lines.

I am more of a Quest guy than a Squiffy guy, too. So, you'll most definitely want to test this out in a copy of your game before you make any permanent changes.


EDIT

I had an error in Pos Type Setup when originally posted (9 minutes ago). This has been fixed. (I had accidentally skipped the Desert bit. Sorry about that!)


Thanks Richard

Will definitely try this out in a backup.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums