Jump to content

Photo

can I use a for loop in a item script?


  • Please log in to reply
6 replies to this topic

#1 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 05 January 2017 - 06:46 PM

can I use a for loop in a item script to execute it?

I don't know if the script quits after the button press so I was just wondering

 

if that's the case then that would make sense why people use global script for items and a item script to execute it



#2 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 05 January 2017 - 07:02 PM

You can. You can use any kind of loop you wish so long as the loop is executed on a single frame.

Item scripts only run for 1 frame so calling any kind of waitframe is the same as calling quit.

#3 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 05 January 2017 - 07:14 PM

dang I guess I will switch to a global script then thankyou



#4 SUCCESSOR

SUCCESSOR

    Apprentice

  • Banned
  • Real Name:TJ

Posted 05 January 2017 - 07:44 PM

Using an item script to launch an ffc script that handles the custom item's behavior is one of the best methods for scripting items that need more than a frame. You should grab ffcscript.zh



#5 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 05 January 2017 - 08:11 PM

@SUCCESSOR

how so? I wanted to make a gb sword script as well but I don't know how to spawn a hitbox

 

however right now I'm having trouble with the shovel rapid firing

I want it to work when I press the item button, not when I hold it down



#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 January 2017 - 04:42 AM

@SUCCESSOR

how so? I wanted to make a gb sword script as well but I don't know how to spawn a hitbox

 

however right now I'm having trouble with the shovel rapid firing

I want it to work when I press the item button, not when I hold it down

 

Wait... I thought that you were already using stdWeapons.zh?

 

That comes with​ a sword script...

 

Using ffcs to control weapons is a pretty basic model. Essentially, when you use an item, the item script;

 

finds a free (unused) ffc.

Loads an ffc script into that free slot.

The ffc controls the weapon generated by the item script.

 

This permits extending the effects of an item script beyond one frame, by piggybacking an ffc onto it. You can also do the same with the global active script, which is preferred in some instances. Remember, there are at most 32 running ffcs at any given time, and up to 255 weapons, plus up to 255 npcs. If you use ffcs for nothing else​, you can quickly run out if you use ghosted npcs and ffc-attached weapons, so care is required.



#7 Shadowblitz16

Shadowblitz16

    Illustrious

  • Members

Posted 06 January 2017 - 04:17 PM

hmm ok well right now it uses a global script however I am currently still working on it since I don't have a sound system to test the sound effects

hopefully my parents will bring back a usb sound system today 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users