Ultimate Noob Coding

@Loudbeat I read that but just wanted to make sure I understand it as I am new to coding.

@choicehacker So it seems to be no problem to *goto different scenes without returning to a gosub.

Thanks

2 Likes

No problem, I always try to reinforce my response with the documentation, not all out there know that it’s there.

2 Likes

Oh, no. I haven’t tried it myself, but that’s simply because I’m sure it’ll cause problem later down the line. Use *return for every *gosub you have.

If you were to have a *gosub but uses *goto instead to return to main passage, it’ll cause problem if you were to have a *return somewhere down the line. Your reader will be thrown back all the way to the initial *gosub line and all their stats will be reset back to that point in case of *gosub_scene.

In fact, a good coding practice would be to write down *return in pair-with every *gosub as you type and put your code in-between.


Rereading this, it’s theoretically no problem if you were to exclusively use *gosub only and *goto only in your code. However, I’m not even holding my breath to see if everything is going to be fine or not if I do such setup.

4 Likes

This is what I was thinking as well… but as I am new to coding I am not sure of how to fix it easily.

I have the MC meeting a character which can happen at different parts in the story, hence I made a *gosub to that section with a return in it which I thought would be easier then figuring out where the MC came from. But I also want to give the player the option to get out of this conversation at some point in the *gosub, so I made a *goto back to the ‘main menu’

I am trying to finalise all this and will get this part of the chapter up in the workshop, hoping to get some tips there, but if you see some easier solution it would be very helpful

2 Likes

I might understand the problem you’re facing which, if I am, might something that requires special treatment :tm: to see whether it’ll work in your story or not. Having the code (or the story) up for public testing might be the best; and from there, I can take a peek at how you structure your code and give some insights.

2 Likes

If the player decides to quit, instead of using a *goto, just use a *return. You can use more than one *return statement, but the player will hit only one. Just hide it inside an *if statement or a *choice body.

1 Like

Yeah, how I wrote it, I don’t want to player to return to that point anymore as he does not wants to interact with the met character. I think I just overcomplicated it all. I will follow @Szaal 's advice and finish what I have in the coming week and post it.

Thanks for helping :slight_smile:

2 Likes

Years later, I know, but thanks for typing this out: clear, concise–exactly what I needed. Cheers!

2 Likes

What’s the coding for money? i.e. A resource that’s shown in your inventory, which you can’t spend more of than you possess.

2 Likes

just set a variable and name it whatever you want. for an example of not spending more than what you have:

*fake_choice
   #Buy a dope fanny pack
      *if money > 10
         Nice! You got a new fanny pack! Pretty dope!
      *if money < 10
         Bummer dude.... no fanny pack for you! You need some money. 
    #Don't buy a dope fanny pack

just change out the values and text, that will work for most things

2 Likes

So. I made a highest_calc script, and want to see what everyone thinks. Please comment if you find arrors.

*if Highest_relationship_stat = 51
	*set Highest_relationship "t_relationship"
	*set Highest_relationship_stat t_relationship
*elseif friendship_stat =50
	*set friendship_stat "l_relationship"
	*set friendship_stat_stat l_relationship
*if t_relationship > Highest_relationship_stat
	*set Highest_relationship "t_relationship"
	*set Highest_relationship_stat t_relationship
*elseif ((t_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "t_relationship"
	*set friendship_stat_stat t_relationship
*if l_relationship > Highest_relationship_stat
	*set Highest_relationship "l_relationship"
	*set Highest_relationship_stat l_relationship
*elseif ((l_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "l_relationship"
	*set friendship_stat_stat l_relationship
*if n_relationship > Highest_relationship_stat
    *set Highest_relationship "n_relationship"
    *set Highest_relationship_stat n_relationship
*elseif ((n_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "n_relationship"
	*set friendship_stat_stat n_relationship
*if d_relationship > Highest_relationship_stat
    *set Highest_relationship "d_relationship"
    *set Highest_relationship_stat d_relationship
*elseif ((d_relationship >friendship_stat_stat and <highest_relationship_stat
	*set friendship_stat "d_relationship"
	*set friendship_stat_stat d_relationship
*return
*gosub_scene high_relationship_calc

*if Highest_relationship = "t_relationship"
    *goto_scene driver t_reaction_shoulder2
*elseif second_highest_relationship ="t_relationship"
	*goto_scene driver t_reaction_shoulder2

*if Highest_relationship = "l_relationship"
     *goto_scene driver l_reaction_shoulder2
*elseif second_highest_relationship ="l_relationship"
	*goto_scene driver l_reaction_shoulder2

*if Highest_relationship = "n_relationship"
     *goto_scene driver n_reaction_shoulder2
*elseif second_highest_relationship "n_relationship"
	*goto_scene driver n_reaction_shoulder2

*if Highest_relationship = "d_relationship"
     *goto_scene driver d_reaction_shoulder
*elseif second_highest_relationship ="d_relationship"
	*goto_scene driver d_reaction_shoulder2

So. Yeah.

2 Likes

Hi @ArchivistAlpha096 , congratulations for your effort. I had a look at it, but the code is very dense and rather hard to analyze. Where are the two constants 51 and 50 coming from?

For sorting, I always refer to @stainedofmind 's implementation, which is in my opinion the most elegant piece of CS ever written. You can find it here: Algorithm hall of fame and code examples: sorting, shuffling, dev tools

2 Likes

The 50 and51 come from the 2 relationship stats. Figured I should the “highest_relationship_stat” 1 above the “friendship_stat” just to keep things focused.
Yeah, it is. I didn’t bother double spaceing it, because it’s ment to be strictly backround code.

1 Like

Ok, I’m confused. I’m running my code on firefox. Also. Seems it wants you to uploade the entire folder now, which I don’t like utch. Anyway. I have this:

		*set k_gender "female"

I don’t know why it’s giveing me an arror, and am somewhat confused as to what’s going on here? So… Yeah…

1 Like

Time to resurrect this for a little help: how do you code does not equal into an *if? I think it was something with an equal sign and a backslash but I don’t know specifics.

3 Likes

It’s !=

6 Likes

Thanks!

2 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.

Hello, various and sundry coders. I was doing some playtesting for my game in the publication queue and realized the below subroutine code doesn’t cover if someone has more than one of these stats at an equal level; an epilogue chunk failed to trigger because it required one of the four to be in place. Any thoughts on how to force it to pick one if there are multiple at an equal level?

*if Highest_stat = 0
    *set Highest_stat_type "Intimidate"
    *set Highest_stat intimidate

*if Intimidate > Highest_stat
    *set Highest_stat_type "Intimidate"
    *set Highest_stat intimidate

*if Inspire > Highest_stat
    *set Highest_stat_type "Inspire"
    *set Highest_stat inspire

*if Motivate > Highest_stat
    *set Highest_stat_type "Motivate"
    *set Highest_stat motivate
    
*if Entertain > Highest_stat
    *set Highest_stat_type "Entertain"
    *set Highest_stat entertain
    
*return
1 Like