Jump to content

Photo

[Request] Item Counter script


  • Please log in to reply
3 replies to this topic

#1 Love For Fire

Love For Fire

    Adept

  • Members
  • Real Name:Chris
  • Location:Wherever this laptop takes me...

Posted 17 October 2017 - 07:02 PM

Hi everyone, read some of the tutorial and am quite unsure about what I need to be using (global or item?), or how to set up a custom counter.

 

So I would like a script that:

 

1. Sets up a counter that I can display as a subscreen element.

2. Attaches to various items so that when the item is picked up, the counter increases by one (This will be used for magic containers and heart pieces so I can't use a built in counter)

 

Thank you guys for looking. Maybe seeing something will help me learn how these work better.

 

 



#2 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 18 October 2017 - 04:40 AM

item script IncrementCounter{
    void run(){
        Game->Counter[CR_SCRIPT1]++;
    }
}

Attach this as a pickup script to every item you want to take into consideration,

 

You can then display script counter n°1 on your subscreen.


Edited by Jamian, 18 October 2017 - 04:41 AM.


#3 Love For Fire

Love For Fire

    Adept

  • Members
  • Real Name:Chris
  • Location:Wherever this laptop takes me...

Posted 18 October 2017 - 07:12 AM

Thank you, worked perfectly.



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 18 October 2017 - 08:41 AM

item script IncrementCounter{
    void run(){
        Game->Counter[CR_SCRIPT1]++;
    }
}

Attach this as a pickup script to every item you want to take into consideration,

 

You can then display script counter n°1 on your subscreen.

 

 

That is far from ideal. It will fail to track collectibles accurately, and level items; plus you might have script merging to do.

 

For what it is worth, I;m working on a complete package for this, because of the request.

 

This is what I have thus far:

 

Spoiler

 

That code is incomplete, but it might give you some ideas.


  • ShadowTiger likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users