Community

SCI Programming => SCI Syntax Help => Topic started by: L@Zar0 on November 16, 2024, 10:16:54 AM

Title: A bit confused with : and ? symbols in scripts after Props
Post by: L@Zar0 on November 16, 2024, 10:16:54 AM
Hi,

I'm very begginner with SCI, so, sorry if I ask very silly things. xD
I searched the wiki tutorials, and AFAIK a Prop with ':' or '?', the difference (as I understood) is for assign or read respectively.
But I don't know if from the point of view of SCI Compiler 3.0.1.7 is the same. For example, KQ5 CD Talkie version has (when decompiling):

Code: [Select]
(if (not (gTheIconBar curInvIcon?))
(gTheIconBar enable: (gTheIconBar useIconItem?))

This means that is reading the variable, right? If I use here ':', it would work the same way?

Thanks in advance.
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: Kawa on November 16, 2024, 10:32:01 AM
Quick test indicates you're right.

Code: [Select]
; Identical
(Printf "picture is %d" (self picture?))
(Printf "picture is %d" (self picture:))

; Opposite is invalid
(self picture? 101)

Using '?' to request a property's value is good for readability.
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: L@Zar0 on November 16, 2024, 12:05:12 PM
Ok, thanks. This was going crazy for me. I'm looking the sci-scripts of sluicebox (I want to compare them with the decompiled part of the original game), and sluicebox scripts has not '?' (or at least I have not found any). So, I was not sure if they would work as they are.

In any case, I'm not sure if SCI Companion is outputting '?' when it wants to assign some value.

BTW, I assume you are the creator of updated kawa version of  SCI Companion 3.2.5, am I right? I tried to use that version with KQ5 CD, but when compiling some scripts the game breaks. I can use also 3.1.0.x version that other person did time ago.
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: Kawa on November 16, 2024, 12:13:45 PM
You can't assign with ?, and no decompiler should emit such. But since requesting a value with : is valid, Sluicebox' decompiler is free to do so.
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: L@Zar0 on November 16, 2024, 01:02:01 PM
So, definitely, we can avoid '?' because ':' can be used for both things, can't we?
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: Kawa on November 16, 2024, 01:24:01 PM
But you shouldn't because ? makes the intent of asking an object for a property's value more readable and clear.
Title: Re: A bit confused with : and ? symbols in scripts after Props
Post by: L@Zar0 on November 16, 2024, 01:31:16 PM
Ok, I understand. Thanks a lot. I will try to understand the KQ5 CD sci code. I will try to check the viability to put text subtitles.
Maybe I have more questions in the future. I tried to do the intro speech+text (spanish), and this is the result but I can not put here links.

But I'm not sure if I did well the code and the most problematic was synchronizing the texts with the audio.
And it is a lot of work do all this, so I'm not sure yet if i will be able to continue.

Anyway, thanks again.