Topic: Question regarding the "hide" command.

Hi.

I have been referring to the "API References" and the "Case studies" for quite some time now, and I have noticed the "hide command". In terms of it's trying to do to a certain object/item, I am entirely satisfied, and I wish to continue adding this feature to my level.

However, I do have a question concerning this command. Is it possible to hide or make an object/item invisible and have the events/states associated with it still happened? E.g. I wish to make the extra life box invisible, but when I approach the object hidden while spindashing, the event in gaining an extra life needs to happen.

This is a desperate request. Thank you for the taking the time to read this topic.

Kind regards,
Harmeet Heer

Re: Question regarding the "hide" command.

If I remember well, "hide" won't affect other events so you can use it as usual. For your example, I would do something like

object "extra_life"
{
        requires 0.2.0
        hide_unless_in_editor_mode

        state "main"
        {
                  set_animation "BOX_ANIMATION" //Necessary to stablish object's size. 
                  change_state "wait"
        }

         state "wait"
         {
                  on_player_attack "one_up"
         }

         state "one_up"
         {
                   add_lives "1"
                   destroy
         }
}

I have written up this code now, I haven't proved it. However it should work. Note that I've used "hide_unless_in_object_editor" instead of "hide". This is the same as hide, but if you want a permanent invisible object, this allows you to see them in the level editor, even if the sprite is also transparent.
You should use hide/show when you don't want a permanent invisibility, in my opinion.

Piece of cake...!

Re: Question regarding the "hide" command.

I see. Do I add this provided source code to a new ".obj" file? If so, how will I specifically define it, considering the already built-in item boxes (e.g. surge life box) in "Open Sonic" ver. 0.1.4?

Kind regards
Harmeet Heer

Re: Question regarding the "hide" command.

First of all, you should change to new 0.2.0 version, which is more flexible big_smile This is not going to be a problem with this object, but it has a lot of possibilities.

Second, this object I've written has nothing to do with the built-in item (this cannot be modified). This is a NEW custom object. And my code could have an error (as I've said, I've written it without checking). 
Read the code carefully and make sure you understand it. What I do is to create a new object. In the main state, I assign a sprite to the object (you might want to use the item box graphics to make sure it has the same size). After that, I change the state to a wait. The object will be in this state until is attacked (this is, jumped on or spindashed) by the player. If this happens, the state changes again. The "add_lives" command increases the life in 1, and then the object is destroyed so it's not usable anymore.
The "hidden_unless_in_editor_mode" makes the object invisible.

So this is not a life box. It is a custom object that acts like a life box, but it's invisible. And it has nothing to do with the built-in life box.

This code is really, really simple. If don't catch it, try to play more time with the API, the case studies until you're familiar with the scripting. Some things need time smile Once you catch it, you'll realize this is easy.
And feel free to ask any doubts.

PS. If you want to make it work in 0.1.4, change the "requires 0.2.0" to "requires 0.1.4". Also be sure that every script command you're using works in 0.1.4. In practice, you should change, as I've said, to 0.2.0.  You can port all yours 0.1.4 scripts to 0.2.0 simply by copy-paste. Same with Sonic sprites and other stuff

Piece of cake...!

Re: Question regarding the "hide" command.

I have thoroughly tested the code you have supplied in this topic in "Open Sonic" ver. 0.1.4, and despite the fact that it does hide the object unless you are in "Level Editor" mode, no event happens while it is invisible (e.g. provides 10 rings when destroyed). Do you have any further suggestions in this case?

Kind regards,
Harmeet Heer

Re: Question regarding the "hide" command.

I have proved it and it works perfect for me in 0.2.0.

The problem, if you look at the API reference, is this:

add_lives
Syntax: add_lives number_of_lives
Available since: 0.2.0
Adds number_of_lives to the number of lives of the player. number_of_lives may be positive or not.

You cannot add_lives in 0.1.4.  So in that version you cannot do the "invisible life box" since you cannot add lives to the player. Port your content to the 0.2.0 and everything will work fine.

Piece of cake...!

Re: Question regarding the "hide" command.

TheSeventhEmerald wrote:

You cannot add_lives in 0.1.4.  So in that version you cannot do the "invisible life box" since you cannot add lives to the player. Port your content to the 0.2.0 and everything will work fine.

well, you can add lives in 0.1.4 by adding 100 rings to the player: add_rings

however, as TheSeventhEmerald has suggested, using 0.2.0 is still recommended. smile