Coding issue which originally worked but now is throwing up an error?

I’ve spent the past hour writing a code for my Bond system, and it works exactly how it should in my test demo, but for some reason, when I’ve transferred it to the actual game, it now longer works and comes up with an error when I run quickest.

For reference, this is the original code from the test demo;

Original Code that works
*label bond_check
*temp name1 "bond_"&target
*temp name2 target&"_bond"
*temp name3 target&"_flirt"
*temp name4 "flirt_"&target
*if {name1} = 10
    *goto merry_men
*if {name3} = 5
    *goto merry_men
*if (flirt)
    *set {name3} +1
*if not (flirt)
    *set {name1} +1
*if ({name1} = 0)
    *set {name2} "✧✧✧✧✧✧✧✧✧✧"
*if ({name1} = 1)
    *set {name2} "✦✧✧✧✧✧✧✧✧✧"
*if ({name1} = 2)
    *set {name2} "✦✦✧✧✧✧✧✧✧✧"
*if ({name1} = 3)
    *set {name2} "✦✦✦✧✧✧✧✧✧✧"
*if ({name1} = 4)
    *set {name2} "✦✦✦✦✧✧✧✧✧✧"
*if ({name1} = 5)
    *set {name2} "✦✦✦✦✦✧✧✧✧✧"
*if ({name1} = 6)
    *set {name2} "✦✦✦✦✦✦✧✧✧✧"
*if ({name1} = 7)
    *set {name2} "✦✦✦✦✦✦✦✦✧✧✧"
*if ({name1} = 8)
    *set {name2} "✦✦✦✦✦✦✦✦✧✧"
*if ({name1} = 9)
    *set {name2} "✦✦✦✦✦✦✦✦✦✧"
*if ({name1} = 10)
    *set {name2} "✦✦✦✦✦✦✦✦✦✦"
*if ({name3} = 0)
    *set {name4} "♡♡♡♡♡"
*if ({name3} = 1)
    *set {name4} "♥♡♡♡♡"
*if ({name3} = 2)
    *set {name4} "♥♥♡♡♡"
*if ({name3} = 3)
    *set {name4} "♥♥♥♡♡"
*if ({name3} = 4)
    *set {name4} "♥♥♥♥♡"
*if ({name3} = 5)
    *set {name4} "♥♥♥♥♥"
*return

*finish

And here is the code I’ve added to the actual game.

New code that doesn't work
*label bond_check
*temp name1 "bond_"&target
*temp name2 target&"_bond"
*temp name3 target&"_flirt"
*temp name4 "flirt_"&target
*if ({name1} = 10)
    *goto merry_men
*if ({name3} = 5)
    *goto merry_men
*if (flirt)
    *set {name3} +1
*if not (flirt)
    *set {name1} +1
*if ({name1} = 0)
    *set {name2} "✧✧✧✧✧✧✧✧✧✧"
*if ({name1} = 1)
    *set {name2} "✦✧✧✧✧✧✧✧✧✧"
*if ({name1} = 2)
    *set {name2} "✦✦✧✧✧✧✧✧✧✧"
*if ({name1} = 3)
    *set {name2} "✦✦✦✧✧✧✧✧✧✧"
*if ({name1} = 4)
    *set {name2} "✦✦✦✦✧✧✧✧✧✧"
*if ({name1} = 5)
    *set {name2} "✦✦✦✦✦✧✧✧✧✧"
*if ({name1} = 6)
    *set {name2} "✦✦✦✦✦✦✧✧✧✧"
*if ({name1} = 7)
    *set {name2} "✦✦✦✦✦✦✦✦✧✧✧"
*if ({name1} = 8)
    *set {name2} "✦✦✦✦✦✦✦✦✧✧"
*if ({name1} = 9)
    *set {name2} "✦✦✦✦✦✦✦✦✦✧"
*if ({name1} = 10)
    *set {name2} "✦✦✦✦✦✦✦✦✦✦"
*if ({name3} = 0)
    *set {name4} "♡♡♡♡♡"
*if ({name3} = 1)
    *set {name4} "♥♡♡♡♡"
*if ({name3} = 2)
    *set {name4} "♥♥♡♡♡"
*if ({name3} = 3)
    *set {name4} "♥♥♥♡♡"
*if ({name3} = 4)
    *set {name4} "♥♥♥♥♡"
*if ({name3} = 5)
    *set {name4} "♥♥♥♥♥"
*return

The reported error says;

Error: bonds line 6: Non-existent variable ‘bond_’

I’ve made a mistake somewhere, but for the life of me I can’t see what I’ve done any different that would cause it to error?

The difference is the difference between

*if {name1} = 10 and *if ({name1} = 10) I would assume.

I’m not 100% sure what you’re going for there with the parentheses, but it looks like Choicescript is understanding the whole of ({name1} = 10) as a discrete variable? Maybe? Just a guess.

Also, I didn’t know you can concatenate a string in a *temp declaration. I’m used to that being in a *set. Can you indeed do that? If so, that’s interesting.

I’ve done that and still get the same error.

It’s really strange the first code works and doesn’t cause an error. I’ve even copy and pasted it over but it gets an error. It’s very strange.

I’ve even copy and pasted it over but it gets an error

Hmm, if old code gets the same error, maybe check to see if target is empty when you call the pasted code? Maybe it’s trying to concatenate “bond_” with “” and getting “bond_”?

1 Like

I believe it’s what @dora said, target is empty.

The original code works and gets no error. But when I copy and paste it into the games actual files it doesn’t work.

Right, but are you setting “target” somewhere in the actual game code?

Yes. It gets set whenever you get sent to the scene with the code. I’ll double check just in case I missed something.

Try to print target first thing in the subroutine just to see if it is correctly set?

Okay. I’ve figured it out. It was to do with target but also to do with quicktest itself.

Playing through the game it IS set at the three points the code hits *gosub_scene bonds so playing the game would work fine.

What I was forgetting is that quicktest tests the files separately. So it tests bonds with the initial setting of target which is of course “” which is what causes the test to fail. I set it as “john” and it passed the test.

Face palm

2 Likes

Ah, classic Quicktest quirk! Since Quicktest runs files separately, it doesn’t always recognize variables set elsewhere in the game. A quick fix would be to initialize bond_ in the same file or use a default value before calling it. Glad you figured it out.

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