Jump to content

Photo

Script Help


  • Please log in to reply
48 replies to this topic

#31 justin

justin

    Adept

  • Members

Posted 17 May 2015 - 02:37 PM

That sounds like a good idea/solution, but I don't know how to use string control codes, and I'd like to stick to my original method, if possible. (Sorry if I sound rude or disrespectful, I don't mean to at all.) What I need is a script to get the ID of the special item on the screen and give it to Link.


The special item if using the special item room type will be
Screen->RoomData

But this seems like a hackish method when you've been given better ones.

#32 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 18 May 2015 - 05:01 PM

Of course, you are free to use whatever method that you decide. It's just that using the string control codes is easier than scripting really.
 

 

I can't agree with that. It's purely different, and requires more esoteric, arcane memorisation. I often feel that SCCs are more 'hackish' as justin puts it, than scripting; but that's me. I think it's relative, to what we feel at ease doing.

 

If ZC had a nice, external string editor, that'd be fantastic, but we've discussed that in the past: It doesn't exist.

 

I think my own reluctance in using SCCs, is that I hardcode my important strings, so using control codes inside ZScript just isn't productive, when I can use expressions, and arguments that have names, or constants to do most of the same. They don't permit the same level of refinement either, and I don't believe you can do anything with SCCs that you cannot also do in ZScript.

 

People who've used ZQuest for many years, are probably used to SCCs, because they were mandatory to do these special effects in earlier builds of ZC, but now, they're primarily there for backward-compatibility.

 

I rarely use anything other than text speed, and colour; and when I completely shift to Tango, I'll need to use Tango's special formatting codes for that too.



#33 ywkls

ywkls

    Master

  • Members

Posted 18 May 2015 - 10:37 PM

I can't agree with that. It's purely different, and requires more esoteric, arcane memorisation. I often feel that SCCs are more 'hackish' as justin puts it, than scripting; but that's me. I think it's relative, to what we feel at ease doing.

 

I think that you misunderstood me. What I mean was that for me, using the control codes is easier than trying to script something from scratch. Given the amount of lines of code needed to give Link an item via script and the lines need to do the same thing via String Control Codes, the control codes are an easy winner since you only need to type 5 characters.

 

Of course, once you're fluent enough in Zscript to create scripts (as I've gotten over the past few months) it easily outstrips the capabilities of string control codes. Just looking at what Tango.zh can do shows that. However, that in itself requires learning another form of coding, which is input directly into the string editor. So it's more like 6 of one, half a dozen of the other.

 

I'm not saying that anyone has to use (or learn) string control codes, but neither do they have to learn scripting. Both are tools that can be used to accomplished a number of things. And with that I'm going to drop this subject, since it isn't relevant to the request and I've already posted code that does what was asked for.



#34 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 19 May 2015 - 05:06 AM

Regarding the shovel, I'm willing to share the script I wrote for Promised Lands and The Forbidden City. I held out for a bit so it wouldn't ruin the novelty factor, but both quests have been out for a while now so I don't mind.

 

However, I first need to clean it up and make it more plug-and-play, because I have a habit of hardcoding my scripts for my specific needs.



#35 ywkls

ywkls

    Master

  • Members

Posted 19 May 2015 - 08:46 AM

Regarding the shovel, I'm willing to share the script I wrote for Promised Lands and The Forbidden City. I held out for a bit so it wouldn't ruin the novelty factor, but both quests have been out for a while now so I don't mind.

 

However, I first need to clean it up and make it more plug-and-play, because I have a habit of hardcoding my scripts for my specific needs.

 

Question? Do you intend to post that here in this forum or just send it to Rocks4Free via PM? Because although I don't have any plans to use it in my current game, that doesn't mean I won't ever want to.

 

And if you ever decide to let other people use the script that runs the Ocarina in The Forbidden City, I would love to use that for my next quest.



#36 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 19 May 2015 - 09:55 AM

Yes, I'll post the shovel script for anyone to use. I'll make it as plug-and-play as I can, but you may have to mess with the script yourself a little bit to make it do exactly what you want.


Edited by Jamian, 19 May 2015 - 09:59 AM.

  • Frocks7Snee and ywkls like this

#37 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 20 May 2015 - 12:04 PM

I think that you misunderstood me. What I mean was that for me, using the control codes is easier than trying to script something from scratch. Given the amount of lines of code needed to give Link an item via script and the lines need to do the same thing via String Control Codes, the control codes are an easy winner since you only need to type 5 characters.

 

Of course, once you're fluent enough in Zscript to create scripts (as I've gotten over the past few months) it easily outstrips the capabilities of string control codes. Just looking at what Tango.zh can do shows that. However, that in itself requires learning another form of coding, which is input directly into the string editor. So it's more like 6 of one, half a dozen of the other.

 

I'm not saying that anyone has to use (or learn) string control codes, but neither do they have to learn scripting. Both are tools that can be used to accomplished a number of things. And with that I'm going to drop this subject, since it isn't relevant to the request and I've already posted code that does what was asked for.

 

Ah, I did indeed misunderstand your remark.

 

You do know that you can put your strings directly in whatever you're coding; right? You never need the string editor, and using that with Tango will only slow you up.

 

 

Yes, I'll post the shovel script for anyone to use. I'll make it as plug-and-play as I can, but you may have to mess with the script yourself a little bit to make it do exactly what you want.

 

Knowing that you plan to do that, I'll not bother adapting mine. The main thing, is to ensure that a user can set it up by using constants for anything that needs a variable input. My own rendition uses tables of combo-IDs, and never uses a script flag; so it's less simple to set up than what the average person needs, which is in part, why I didn't add it to the database. (It also relies on an external, beta header, that I do not control, which is not ideal for that sort of thing.)



#38 ywkls

ywkls

    Master

  • Members

Posted 20 May 2015 - 02:23 PM

Ah, I did indeed misunderstand your remark.

 

You do know that you can put your strings directly in whatever you're coding; right? You never need the string editor, and using that with Tango will only slow you up.

 

No, I didn't know that. Thanks for sharing. However, I don't think I'm quite ready to tackle the complexities of Tango just yet. I'm only just now getting to the point where I can create scripts on my own that occasionally do what I want without getting somebody to help.

 

I do appreciate any advice I can get on using scripts and I know from perusing the forums that you've both had a lot of success with scripting complex things on your own and giving good advice to those interested in doing things via script. That being said, i wouldn't presume to ask you to script something for me unless you wanted to. I'd rather do like the creator of this thread did and post my request and see what response I get.

 

Lately I seem to be getting fairly quick responses from the same few members, or none at all. But since I rarely need brand new scripts to do stuff any more, that's just fine with me.

 

If you ever want to see some of my ideas for things that could be scripted and apparently haven't been (and I have no idea how they could be done), I created a thread a while back called Script Wishlist. While not everything I'd like to see done is on there, many of them are somewhat challenging ideas nobody seems to have tried. (And no, I don't mean Z3 scrolling I have no real interest in that.)



#39 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 07 June 2015 - 09:22 AM

I managed to sort everything out, but now I have another problem.

 

I slightly modified the signpost script I'm using to only give link a certain item if he doesn't already have it, as shown here:

But now, Link can only read the sign once every time he visits the screen, insted of always being able to read this. Not sure why this happens.


Edited by Rocks4Free, 07 June 2015 - 09:24 AM.


#40 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 June 2015 - 09:56 AM

Because your while loop is based purely on Link's location, among other problems...

ffc script sign {
    void run(int m, int ItemToGive) {
        bool close;
        while(true){
            if ( Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && Link->Dir == DIR_UP ){
                close = true;
            }
            if ( Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || Link->Dir != DIR_UP ) {
                close = false;
            }
            if ( Link->PressA && close ) {
                Screen->Message(m);
                if ( !Link->Item[ItemToGive] == false) Link->Item[ItemToGive] = true;
            }
            //Screen->Message(0); //Why do we have a hardcoded message here?
            Waitframe();
        }
    }
}
 

I didn't test that yet. if it gives you problems, let me know, and I'll debug it tomorrow.

 

P.S. Alternate version that allows using an arg to set the 'read' button:

ffc script sign {
    void run(int m, int ItemToGive, int button) {
        bool close;
        while(true){
            if ( Link->X >= this->X - 8 && Link->X <= this->X + 24 && Link->Y >= this->Y && Link->Y <= this->Y + 24 && Link->Dir == DIR_UP ){
                close = true;
            }
            if ( Link->X < this->X - 8 || Link->X > this->X + 24 || Link->Y < this->Y || Link->Y > this->Y + 24 || Link->Dir != DIR_UP ) {
                close = false;
            }
            if ( close ) {
                if ( ( button == 0 && Link->PressA ) || ( button == 1 && Link->PressB ) || ( button == 2 && Link->PressL )
                    || ( button == 3 && Link->PressR ) || ( button == 4 && Link->PressEx1 )
                    || ( button == 5 && Link->PressEx2 ) || ( button == 6 && Link->PressEx3 )
                    || ( button == 7 && Link->PressEx4 ) ) {
                    
                    Screen->Message(m);
                    if ( !Link->Item[ItemToGive] == false) Link->Item[ItemToGive] = true;
                }
            }
            //Screen->Message(0); //Why do we have a hardcoded message here?
            Waitframe();
        }
    }
}

Defaults input to 'A', if D2 is '0', but allows you to define the button for reading (arg D2) to any action button.

 

P.S. I don't know what you want Screen->Message(0) to do here, so I commented it out. It seems superfluous.


Edited by ZoriaRPG, 07 June 2015 - 10:11 AM.


#41 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 07 June 2015 - 10:05 AM

It works fine, thanks! You forgot a parenthesis in the second if statement, but other than that, it's perfect. :D


Edited by Rocks4Free, 07 June 2015 - 11:26 AM.


#42 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 June 2015 - 10:10 AM

It works fine, thanks! You forgot a parenthesis in the second if statement, but other than that, it's perfect. :D

 

Sorry about that. Fixed above.

 

Glad it works, as I just typed it out of my head.


Edited by ZoriaRPG, 07 June 2015 - 10:11 AM.


#43 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 07 June 2015 - 11:27 AM

Actually, nevermind. For some reason Link isn't recieving the item from the sign. I thought it was just the item not doing what it was supposed to, but now I see that Link isn't even receiving the item at all. Is there a certain condition for an item to be given by a script, like being an equipment item? (As in, not being a counter but not having "equipment item" checked in the item editor) 



#44 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 07 June 2015 - 12:55 PM

yeah, to use that method, you need it to be an equipment item, and if the item has any pickup scripts, they won't run. You probably want to generate the item on top of Link's position, rather than setting Link->Item[ItemToGive] to true. Try changing 

if ( Link->Item[ItemToGive] == false) Link->Item[ItemToGive] = true;

to

if ( Link->Item[ItemToGive] == false)
{
item GiveItem= Screen->CreateItem(ItemToGive);
GiveItem->X = Link->X;
GiveItem->Y = Link->Y; 
GiveItem->Z = Link->Z;
}

Took that from a snippet that ZoriaRPG gave me about 2 years ago.


Edited by Binx, 07 June 2015 - 03:17 PM.


#45 Frocks7Snee

Frocks7Snee

    Illustrious

  • Members

Posted 07 June 2015 - 12:59 PM

Okay, that sounds like a good idea. Can I still use the same method for checking if Link has the item?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users