Jump to content

Photo

Script1-counter


  • Please log in to reply
8 replies to this topic

#1 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 13 February 2018 - 11:02 AM

Heyho :)

 

I can't get the script1-counter to work.

 

I tried to create an item that inceases the script1-counter by 1, but it won't increase. When I change the "Counter Reference" (item editor) from "script1" to "bombs", it works with the bombs, so I didn't set the item up wrong.

 

After failing this way, I tried to make an itemscript (pickup). It compiles, but it doesn't work.

item script MagicOrb{
    void run(int m){
	Game->Counter[CR_SCRIPT1]++;
        Screen->Message(m);
    }
}

Where did I go wrong?



#2 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 13 February 2018 - 11:33 AM

i'm sorry i don't know very well in scripting ^^' however i think you did wanted post it in scripting discussion instead right ?



#3 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 13 February 2018 - 11:51 AM

I wanted to post it here, because it isn't a problem with a script. It's a problem with a counter.

If I don't get an answer here, I will post this in the scripting area.

 

But thx for the advice. :)



#4 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 13 February 2018 - 11:56 AM

no problem ;) i think i'll go outside someone got a Bone picked up on me. and got a Skele-ton things to do too



#5 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 13 February 2018 - 01:14 PM

Probably the max counter for script 1 is 0.


  • Rastael likes this

#6 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 13 February 2018 - 03:03 PM

Yes, I'm pretty sure that's the issue. It can be confusing. All scripted counters start with a max counter of 0, so you can't increase them until you increase the max.

 

Have Game->MCounter[CR_SCRIPT1] = n; somewhere, before you attempt to increase the counter. For example, at the start of your active script if you have one.


  • Rastael likes this

#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 13 February 2018 - 04:03 PM

You can increase the counter max from the item editor, on the item itself.

Increase Counter [ ] but not above [ ].

To set counter maximum values by script at the start of a game, you want the global Init script, not the active script. The latter could easily cause bugs if you don't sanity check the assign.

...anyway, you do not need scripts for this.

In 2.54, I have renamed the 'script' counters to 'Custom Counter n', as the 'Script' naming convention is misleading.
  • Rastael likes this

#8 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 14 February 2018 - 10:28 AM

could have like this

Game->MCounter[CR_SCRIPT1] = 50;
Game->MCounter[CR_SCRIPT2] = 50;

  • Rastael likes this

#9 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Location:Austria

Posted 14 February 2018 - 10:29 AM

Oh, it's THAT easy? Thx a lot! :D

 

I increased the max-counter in the item-editor. ^^


Edited by Rastael, 14 February 2018 - 10:29 AM.

  • judasrising likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users