Jump to content

Photo

My Script Wishlist and Your Script Ideas


  • Please log in to reply
242 replies to this topic

#166 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 05 September 2015 - 03:33 AM

Forward: For whatever reason, Firefox didn't refresh, so my reply is very late.

 

 

[ ... ]

However, there are a still a few things I haven't been able to find on my own.
 
Misc Room Script Flags- I know that they exist and even that there are 5 types. Here's the only one I know of.

Screen->Flags[SF_MISC]&0x008;//Screen flag Script 2
So, what are the other four? How can they be used most effectively?

 

 
From my custom std.zh v2.50.2

//Misc. Screen flags. OR (|) these together to use (Read-Only).
const int SF_MISC_ALLOW_LADDER        = 0x0001; //Toggle 'Allow Ladder'
const int SF_MISC_NO_DIVING        = 0x0002; //Toggle 'No Diving'
const int SF_MISC_SCRIPT1        = 0x0004; //General use 1 (Scripts)
const int SF_MISC_SCRIPT2        = 0x0008; //General use 2 (Scripts)
const int SF_MISC_SCRIPT3        = 0x0010; //General use 3 (Scripts)
const int SF_MISC_SCRIPT1        = 0x0020; //General use 4 (Scripts)
const int SF_MISC_SCRIPT1        = 0x0040; //General use 5 (Scripts)

 
IIRC, all these are read-only. You can determine if one of them is ticked in the Screen Data editor pane, but you can;t modify it. It's useful for global scripts, where you want effects to run, without using Screen->D.
 
Use if statements to check for one, or more (or a combination of) these flags being enabled, or disabled. You can set up to 32 combinations, and make functions that use them unique per DMap.
 
 

Mysterious Script Crashes- Some times, for no apparent reason; scripts activate when they shouldn't. At others, they don't work when they should (and have up to that point). When no change has been made to the scripts in the meantime, how can the source of these errors be discovered?


 

Edit: Please pardon my lingering reply here.

 

What types of scripts? Do you have an example?

 

Usually, this happens when you pass args that are illegal, such as trying to put a pixel down outside of the screen area, or perform a Sqrt() of a negative value, because the input to a function is passed by a variable that generates an illegal instruction, or scripts that create infinite loops if a condition is/is not met.
 
I'd need some examples of scripts that cause you trouble, for more technical feedback on why they seem to crash at random, however, random crashing is almost always due to an if/else problem, or more likely, an argument passed to a function, that ZScript can't execute. The latter is almost exclusively caused by passing that arg based on a variable.
 

int vx;
int vy;
Screen->PutPixel(6, vx, vy, 17, 0, 0, 0, 128);

 
This looks fine on the surface, but if vx or vy is a negative value, ZC (2.50.0) will crash.
 
The way to prevent this, is with if statements, or Clamp() instructions.
 

int vx;
int vy;
if ( vx >=0 && vy >= 0 ) Screen->PutPixel(6, vx, vy, 17, 0, 0, 0, 128);

 
 

Other Movement Patterns- I'm familiar enough with the various Ghost.zh commands to figure out how to use each one. However, other movement patterns have been suggested; for example a sine wave or an infinity loop.  Another pattern I don't know how to mimic is that of the common Wizzrobe. So how can these be done? And what are some other movement patterns?

 
I'd advise reading the ghost.zh topic from stem to stern; and looking at ghost scripts with those movement patterns.
 
There is a Sine Wave Enemy in this topic.
 
If you want more details on movement, please be more detailed in your request.
 
 

Detecting If All Switches/FFCS Have Been Activated- One script that I had provided for me does this. I'm trying to refine another (the one utilized by the script you'll see in the Multiple Songs/Ocarinas topic) where when all of the ffcs running that script are activated; then other secrets, triggers, ffcs or whatever is activated as well.

 
Multiple FFCs activated: You essentially need a global condition for that. Each FFC on the screen should add +1 to a variable, and if the value of that variable is >= the number of FFCs on the screen that you need to trigger, then you trigger the effect.
 
Likewise, you can trigger FFCs with global vars. I suggest using arrays to hold these conditional vars, else you'll quickly expend your global registers.

 

This script is probably one of my most revolutionary designs, since It easily allows you to create up to 8 secrets on screen that can be triggered permanently and 15 others that can be set off temporarily; opens up extra secret flags; bypasses the whole secret combo setup routine and generally allows a greater amount of variety in the puzzle setup available to the player. So, naturally I want it to be the best it can be.



Time to Tango- I'm going to begin delving into Tango.zh soon. I've looked over the example quest and I've noted the following details. The commands are prefaced by the @ symbol. Syntax seems to be similar to other functions (if, else if, else, append, delay, rand, playsfx, etcetera...)


You can change the token from @ to something else, if you so desire.
 
 

So the big question is... what are the commands that this uses just with the global script and creating no custom functions of your own? What do commands like @a0 do? What are the codes for the various letters? (Example, @256 is used in the example quest to create an A with a circle around it.) How do you set up the background for the various strings?
 
Obviously, this isn't a conundrum that will solve itself overnight. But I'm ready to start learning.

 
The Tango tokens direct the special interface (Tango) to perform tango-specific routines. There is a list of them in Tango_usage.txt.  Again, reading the Tango thread will be useful there. Unless I'm horribly mistaken, a raw numeral as an instruction produces a specific character from a tile font. In that case, in the font used, char 256 is a circumscribed 'A', and @256 instructs Tango to draw that symbol.

 

My custom string.zh has constants for the normal, and extended ASCII characters, to simplify making tile fonts. I also created a Katakana font, that I'll eventually distribute.
 
Backgrounds are established either with drawing functions, of with 'Window Styles'. I have a custom Tango build with (annotated) example scripts available, should you wish to review it. Window styles are established in there, with tiles; but should you need an example quest file, I'll upload one.

 

 


In this case, the script that I was referring to was the one I'm using for the Pegasus Boots. I've have more than one problem with it occur. One time, it seemed to activate before I got the item. (I've never been able to reproduce that, so I don't have a clue why it happened.) Currently, they just seem to have stopped working entirely. I reload my script file, loaded everything back into slots again; but the game ignored it.

 

I'd suspect...

  • Placement in your global script;
  • not meeting an if/else condition (failed evaluation);
  • old save files.

 

 


Basically, the original script allowed you to permanently set screen secrets. But the adjusted version doesn't seem to want to carryover the correct value. Is this because I have the order of the arguments wrong? One explanation I read suggested that it should be Game->SetDMapScreenD(Dmap, screen, Screen->D[D], D).

 

 

You are using the wrong syntax, entirely.

 

If you want to set Screen->D[2], to a value of 5, on DMap 1, Screen 14:

Game->SetDMapScreenD(1, 14, 2, 5);

You have the option to enter screen IDs in hex format, rather than decimal, by preceding the value with 0x:

Game->SetDMapScreenD(1, 0x0E, 2, 5);

Technically, you can also use the binary equivalent; and in fact, you can use decimal, hex, or binary values any time that you need to give a numeric value:

14; //Fourteen, decimal.
0x0E; //Fourteen, hexidecimal.
b1110; //Fourteen binary.
 
int x = 14;
int y = 0x0E;
int z = b1110;
 
//Sets x, y, and z to 'fourteen'.

Edited by ZoriaRPG, 05 September 2015 - 03:56 AM.


#167 ywkls

ywkls

    Master

  • Members

Posted 05 September 2015 - 11:48 AM

Forward: For whatever reason, Firefox didn't refresh, so my reply is very late.

 
Is that why I didn't see this reply until after some of these issues have already been resolved?  As always, thanks for your input. Thanks to your contributions to this topic, it went from being dead for three months to being in the top three in the number of replies in Scripting Discussion and having over two thousand views. Not to mention all of the scripts that have been generated as a result of this topic.
 
 

What types of scripts? Do you have an example?
 
Usually, this happens when you pass args that are illegal, such as trying to put a pixel down outside of the screen area, or perform a Sqrt() of a negative value, because the input to a function is passed by a variable that generates an illegal instruction, or scripts that create infinite loops if a condition is/is not met.
 
I'd need some examples of scripts that cause you trouble, for more technical feedback on why they seem to crash at random, however, random crashing is almost always due to an if/else problem, or more likely, an argument passed to a function, that ZScript can't execute. The latter is almost exclusively caused by passing that arg based on a variable.

 
In the case of the example provided (the Day/Night Script) this bug has shown up once again albeit in a playthrough where I got to the end without having it stop working. It is almost as if for some reason it is not reading the value of the current DMap as being the right one in the array.
 
On Dmaps 0-3; everything works fine. But for Dmaps 4-7 and 32-35; the value of the int TS_CurrentState is being changed but I'm not warping at all. Nor is the time period reset by the script FFC_TS_WarpReturnCheck(I know this because if I go from Dmap 4-7 or Dmap 32-35 to Dmap 0-3 by any normal method, the scripts that set the time period work.)
 
Since this error occurred at two different points in my playthrough, I don't know what other script might be causing this problem or if is my save data being corrupted.
 
 

int vx;
int vy;
Screen->PutPixel(6, vx, vy, 17, 0, 0, 0, 128);
 
This looks fine on the surface, but if vx or vy is a negative value, ZC (2.50.0) will crash.
 
The way to prevent this, is with if statements, or Clamp() instructions.
 
int vx;
int vy;
if ( vx >=0 && vy >= 0 ) Screen->PutPixel(6, vx, vy, 17, 0, 0, 0, 128);

 
 
Very good to know.
 
 

Multiple FFCs activated: You essentially need a global condition for that. Each FFC on the screen should add +1 to a variable, and if the value of that variable is >= the number of FFCs on the screen that you need to trigger, then you trigger the effect.
 
Likewise, you can trigger FFCs with global vars. I suggest using arrays to hold these conditional vars, else you'll quickly expend your global registers.

 
Sounds like something I can experiment with.
 
The other issues you addressed have been dealt with.
 
Now, here's the latest version of the Wood Warden. It does some of the things I want it to, but not all of them.

Wood Warden

 
The way this is supposed to work is that after each version dies, the new one comes to life. However, the bool PlaceSet is never being set to false.(I learned that with TraceB()).


Edited by ywkls, 06 September 2015 - 09:49 PM.


#168 ywkls

ywkls

    Master

  • Members

Posted 05 September 2015 - 04:50 PM

Somehow, I got the Wood Warden to work! I went ahead and submitted it even though it lacks some features I think would make it better.

 

1. Make it immobile until Link gets close enough.

2. Make the combo different until Link gets close enough.

3. Make each of the bosses explode.

 

Here's the current version of the script which does the following-

 

1. Creates four fake Wood Wardens.

2. Randomly selects which order the main boss takes the place of the fakes.

3. Brings each to life after the previous one dies.

4. Once all 4 are dead, kills the boss.

Wood Warden

 

I can honestly say that this is the most complex script I've yet created.


Edited by ywkls, 06 September 2015 - 09:49 PM.


#169 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 September 2015 - 03:51 PM

Is that why I didn't see this reply until after some of these issues have already been resolved?  As always, thanks for your input. Thanks to your contributions to this topic, it went from being dead for three months to being in the top three in the number of replies in Scripting Discussion and having over two thousand views. Not to mention all of the scripts that have been generated as a result of this topic.

 

Indeed, that is why. It was sitting there, pending, and I clicked refresh, only to see three posts between the quoted post, and my reply.

I did cross out a few things, and clip it in the edit, but I left in some pointers, and those constants for SF_Misc, as Lejes only gave you part of the flags list, whereas what I use in std_constants.zh has all of them*; and my advice was slightly different, in particular, when I detailed how to use the flags.

*I'll be posting my model for std.zh 2.50.2 at some point soon, and it has a good deal of very useful material that should be a default package, IMO.
 

In the case of the example provided (the Day/Night Script) this bug has shown up once again albeit in a playthrough where I got to the end without having it stop working. It is almost as if for some reason it is not reading the value of the current DMap as being the right one in the array.
 
On Dmaps 0-3; everything works fine. But for Dmaps 4-7 and 32-35; the value of the int TS_CurrentState is being changed but I'm not warping at all. Nor is the time period reset by the script FFC_TS_WarpReturnCheck(I know this because if I go from Dmap 4-7 or Dmap 32-35 to Dmap 0-3 by any normal method, the scripts that set the time period work.)
 
Since this error occurred at two different points in my playthrough, I don't know what other script might be causing this problem or if is my save data being corrupted.

 


What size is your array? It could simply be that you didn't make it large enough, to handle enough DMaps. I have no idea what code, or method you are using at this point. If you want to upload your codebase, I can look at it, once I finish a few other things. Rather, you should probably just discuss it with me over Skype, if you want it to have any kind of priority other than 'pure random'. I have more requests to finish than I can track--quite literally, as I forget more than half of them, if people don;t remind me.

 

To be honest, this thread has become a big mess that is hard to follow, and it'd be better to split off new script topics into their own threads, as few people will read through this, beginning to end, because of its size. I'd honestly rather see one topic, per script, so that people can notice the new scripts, and search for them later. (Find them in a search, with tags.)

 

Very good to know.
 
 
 
Sounds like something I can experiment with.
 
The other issues you addressed have been dealt with.
 
Now, here's the latest version of the Wood Warden. It does some of the things I want it to, but not all of them.

 

I'll be honest here, you post scripts like this with no commenting, and no description of the intent of each. That makes them very tedious for anyone else to follow, much less to debug, or expand. Variable names like 'second' aren't useful enough, without code comments, to determine the intent of the if/else blocks. If you want to share code, and have other people work on it with you, adding comments is a must, and you might want to consider more self-descriptive var names too.

 

 

Var names like ;'first', 'second', 'third' are pretty generic, as an example. An average user reading that would be entirely lost, and I really can;t spend time decoding something to figure out what someone wants it to do, before debugging it. The intent must be obvious, one way, or another.

 

Using self-descriptive, detailed variable, and constant names, is extremely helpful at speeding up the process of digesting this sort of thing, and code comments for the sections, and phases, would be ideal. Pretty much, detail what each section is intended to do, and it'll make it far easier to follow. I would also add the name of the script (a descriptive title), and its version number as comment to the top, each time you revise it, and thus post the code with versions, so that people know what version they are examining.

 

I have absolutely no idea what a 'Wood Warden' is, and can't tell what it's supposed to do without code analysis. (That shouldn't be required for this...)

 

In a thread this long, and with so many variations on similar scripts, it can be extremely tedious to keep track of what's what, without that.

 

Adding a block like this, to the top, would be ideal:

 

//Wood Warden by ywkls
//An enemy that (insert description of what it is)
//v #.##
//Date

 

I also suggest marking the script with your name, so that in the future, people know the origin of the script, and can properly reference it. Without that in the script itself, the ID of the creator often becomes lost information. I know factually, that there are several scripts that I have used, for which the name of the author is unknown, and a few on the forum that are ambiguous; so it's wise to note that in a comment.

 

P.S. Placing long code in [ hidden ] tags would also improve thread readability, especially with double-posts. That also makes quoted posts less messy.  :shrug:



#170 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 06 September 2015 - 05:26 PM

I'll be honest here, you post scripts like this with no commenting, and no description of the intent of each. That makes them very tedious for anyone else to follow, much less to debug, or expand. Variable names like 'second' aren't useful enough, without code comments, to determine the intent of the if/else blocks. If you want to share code, and have other people work on it with you, adding comments is a must, and you might want to consider more self-descriptive var names too.

 

 

Var names like ;'first', 'second', 'third' are pretty generic, as an example. An average user reading that would be entirely lost, and I really can;t spend time decoding something to figure out what someone wants it to do, before debugging it. The intent must be obvious, one way, or another.

 

Using self-descriptive, detailed variable, and constant names, is extremely helpful at speeding up the process of digesting this sort of thing, and code comments for the sections, and phases, would be ideal. Pretty much, detail what each section is intended to do, and it'll make it far easier to follow. I would also add the name of the script (a descriptive title), and its version number as comment to the top, each time you revise it, and thus post the code with versions, so that people know what version they are examining.

 

 

I have to agree with this. Mostly I've been examining your code, ywkls, and figuring out the flow and what all the variables are doing throughout myself, but as you write more and more complex things, this gets less feasible. It's why I haven't taken more than a cursory look at your day/night thing, for example. For bug testing a larger script like that, I recommend looking at allegro.log first, even if you aren't using any trace functions. If your issue is an attempt to access outside an array's bounds, for example, it'll be immediately reflected there. I also think DrawInteger is very useful for looking at variables in real time, and can often be more useful than just traces alone.



#171 ywkls

ywkls

    Master

  • Members

Posted 06 September 2015 - 08:17 PM

To be honest, the day/night script isn't mine. It was created for me by justin a while back. The original thread for that can be found here.
 
Modified Day/Night Script

 

I think a project I'll do over the next several days is to go back to all of the scripts I've created here and comment basically everything. (Maybe even change the variable names to something a little less obscure.) Using Notepad++ has made even basic scripts a much simpler task.

 

 

What size is your array? It could simply be that you didn't make it large enough, to handle enough DMaps. I have no idea what code, or method you are using at this point. If you want to upload your codebase, I can look at it, once I finish a few other things. Rather, you should probably just discuss it with me over Skype, if you want it to have any kind of priority other than 'pure random'. I have more requests to finish than I can track--quite literally, as I forget more than half of them, if people don;t remind me.

 

I'm willing to send you a copy of my whole script file. (I posted the whole thing online for a while until I gave up and just restarted my game the last time this happened.) I'll probably hold off on that until I get everything commented properly.

 

 

 

To be honest, this thread has become a big mess that is hard to follow, and it'd be better to split off new script topics into their own threads, as few people will read through this, beginning to end, because of its size. I'd honestly rather see one topic, per script, so that people can notice the new scripts, and search for them later. (Find them in a search, with tags.)

 

When I started this thread, I was hoping that other people would make suggestions on scripts be they for enemies, items or effects which they'd never seen done. For the most part, you and Lejes have been the only ones to regularly reply to this. I don't know if it is practical at this point to create a new topic for each script except when it is in the development phase.

 

I suppose I could create a topic entitled 'Scripts I've Created' and put all of them in there with the appropriate explanation, but I'll probably reserve that for scripts that haven't been uploaded to the database for one reason or another.

 

However, it has helped me to grasp a lot of things which I was murky on before; though some still defy me. (Arrays, anyone?)

 

 

I'll be honest here, you post scripts like this with no commenting, and no description of the intent of each. That makes them very tedious for anyone else to follow, much less to debug, or expand. Variable names like 'second' aren't useful enough, without code comments, to determine the intent of the if/else blocks. If you want to share code, and have other people work on it with you, adding comments is a must, and you might want to consider more self-descriptive var names too.

 

 

Var names like ;'first', 'second', 'third' are pretty generic, as an example. An average user reading that would be entirely lost, and I really can;t spend time decoding something to figure out what someone wants it to do, before debugging it. The intent must be obvious, one way, or another.

 

Using self-descriptive, detailed variable, and constant names, is extremely helpful at speeding up the process of digesting this sort of thing, and code comments for the sections, and phases, would be ideal. Pretty much, detail what each section is intended to do, and it'll make it far easier to follow. I would also add the name of the script (a descriptive title), and its version number as comment to the top, each time you revise it, and thus post the code with versions, so that people know what version they are examining.

 

Sorry about that. You're not the first to have trouble with my bad habits in that area. When I make a script, I know what I intend and unless I'm having trouble getting it to work; I don't always think about how it might look to other people. Modifying this is easier now than it used to be. Adding a version number is a good idea, though I'll probably only do this for future scripts. (For past scripts, I'll put a label like Version- Final on one I don't think that I can improve.)

 

 

P.S. Placing long code in [ hidden ] tags would also improve thread readability, especially with double-posts. That also makes quoted posts less messy.  :shrug:

 

I'll make those adjustments too. So, it looks like I'm going to be busy for a while...


Edited by ywkls, 06 September 2015 - 10:31 PM.


#172 ywkls

ywkls

    Master

  • Members

Posted 07 September 2015 - 09:29 AM

Created a separate topic as a reference to this topic and other topics I've either created, contributed or think would be useful. Also added any that I suggested be made and were created by others. Added a link to it in my signature.


Edited by ywkls, 07 September 2015 - 10:00 AM.


#173 ywkls

ywkls

    Master

  • Members

Posted 13 September 2015 - 08:44 PM

I'm fairly certain that the issue with the day/night script is somehow associated with the Pegasus Boots script, since I just had it randomly activate for no reason and afterward; Link's HP apparently dropped to zero yet he was still alive.

 

@ZoriaRPG- I've finished commenting everything to the best of my ability and I'm going to send you my full script file via Skype. It is over 300 K, but it is also broken down into labeled sections. The scripts are organized as follows- global, item-related, room effects, enemy, puzzle and other libraries. (ghost.zh, laser.zh-since my script won't work properly unless they're in my main script file.) If the script has arguments, I try to explain them before hand. However, I'm a little sketchy on the details sometimes when it comes to other people's scripts.



#174 ywkls

ywkls

    Master

  • Members

Posted 15 September 2015 - 09:20 AM

Okay, this is just a theory but it's the only thing I remember doing every time my script for the day/night mechanic has messed up(and it it something I did in my previous game where I had the Pegasus Boots before it messed up). The only I action I remember doing on 3 of the 4 occasions when something weird occurred was quit the game without saving at a save point, dying and selecting one of the options that come up then or hitting F6 and selecting one of those options. Instead I either pressed escape or clicked the mouse button to pull up the menu and shut down the Zelda Classic program. I haven't been able to confirm this, probably because I don't know for certain what conditions need to be met in order for the glitch to occur.

 

So my question is, what happens to code that runs in the game (such as in the global while loop) when you do this? Is there a chance that it might disrupt the functionality of some scripts? I should also note that on each of the 3 occasions when this occurred; I wasn't on the DMaps where the day/night script is supposed to work but on a different DMap.

 

So far, that's the only thing that I've come up with which I did each time the script glitched and I'm not familiar enough with how the game stores data whenever you stop playing in this way to say whether it could be connected. I just wanted to see whether this theory sounds logical to those who know more than I do.



#175 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 September 2015 - 09:43 AM

The global active script starts anew every time you load the save file or continue. Closing ZC from the menu instead of saving and quitting shouldn't affect this. The issue you posted about earlier, with the Pegasus Boots randomly activating, sounds like an issue with new global variables being declared. They only get properly initialized when you create a new save, and strange effects like this can happen if you add global variables to your script file without starting a new save. I think you should write a quick function that just displays all the relevant variables on the screen with DrawInteger so you can see what they're doing in real time.

 

The other possibility I can think of is that you're using the onExit global script to change important variables, and that's not running when you close out through the menu.



#176 ywkls

ywkls

    Master

  • Members

Posted 15 September 2015 - 09:55 AM

The global active script starts anew every time you load the save file or continue. Closing ZC from the menu instead of saving and quitting shouldn't affect this. The issue you posted about earlier, with the Pegasus Boots randomly activating, sounds like an issue with new global variables being declared. They only get properly initialized when you create a new save, and strange effects like this can happen if you add global variables to your script file without starting a new save. I think you should write a quick function that just displays all the relevant variables on the screen with DrawInteger so you can see what they're doing in real time.

 

The other possibility I can think of is that you're using the onExit global script to change important variables, and that's not running when you close out through the menu.

 

Not running an onExit or onContinue script although I think it is possible that I might need one. One of the reasons I think that the two are connected is because 3 of the four times I got odd behavior; the same thing happened when I loaded the game.

 

That is, Link's current HP either dropped to zero or to his starting HP no matter what my current HP happened to be. (Yet Link didn't die.) Since I don't have the day/night script in the old game and I do have it in the new one and since (for some reason) part of it involves temporarily storing Link's HP in a variable, that's the only common feature I know of.

 

The first time I had the day/night thing mess up, I had recently saved a copy of the file over the original and then loaded my game afterward. I don't think that I had changed any global variables that should have had any effect on it; but it is remotely possible.

 

The second time, I had got to the end of my game where instead of a Zelda flag I just quit the game from the menu. When I reloaded it, the script had stopped working. Again, it is possible that I changed a global variable in the meantime; but not one connected with this script. (In fact, I've left that script alone most of the time I've been working on this quest.)

 

When you say that I should display all of the relevant variables onscreen, do you mean every variable that is declared globally or just the ones associated with the scripts that aren't functioning? Because I deleted the file where they were messed up and have no clue how to reproduce the glitch.



#177 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 15 September 2015 - 10:57 AM

The second time, I had got to the end of my game where instead of a Zelda flag I just quit the game from the menu. When I reloaded it, the script had stopped working. Again, it is possible that I changed a global variable in the meantime; but not one connected with this script. (In fact, I've left that script alone most of the time I've been working on this quest.)


It doesn't matter if the new variable isn't directly connected to the original script. It can still produce strange effects. A good rule of thumb is that if you declare any new global variable whatsoever, you should start a new save file to be safe.

 

When you say that I should display all of the relevant variables onscreen, do you mean every variable that is declared globally or just the ones associated with the scripts that aren't functioning? Because I deleted the file where they were messed up and have no clue how to reproduce the glitch.


Anything associated with what's messed up. For example, if the Pegasus Boots are misbehaving, you could track the global bool or whatever the script actually uses by drawing 1 in the top left when it's true. Then you can see what it's doing and when. It may be helpful to repeatedly press F4 for frame advance also, in case the problem pops up in a tiny frame window. It's a very useful feature for debugging and not a lot of people know about it.
  • ywkls likes this

#178 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 17 September 2015 - 09:48 PM

The global active script starts anew every time you load the save file or continue. Closing ZC from the menu instead of saving and quitting shouldn't affect this. The issue you posted about earlier, with the Pegasus Boots randomly activating, sounds like an issue with new global variables being declared. They only get properly initialized when you create a new save, and strange effects like this can happen if you add global variables to your script file without starting a new save. I think you should write a quick function that just displays all the relevant variables on the screen with DrawInteger so you can see what they're doing in real time.

 

The other possibility I can think of is that you're using the onExit global script to change important variables, and that's not running when you close out through the menu.

 

If you have an OnExit script, copy its functions into your custom SaveAndQuit() and QuitWithoutSaving() functions (obvious, generic names there). The easiest way to do that, is to make all of your OnExit script run inside one container function, and call that container function both in OnExit, and in your menu functions.



#179 ywkls

ywkls

    Master

  • Members

Posted 05 October 2015 - 11:17 AM

I've never written a script for the OnExit and OnContinue slots. Would these work?

global script OnExit{
	void run(){
		StoreHP = Link->MaxHP;
	}
}

global script OnContinue{
	void run(){
		StoreHP = Link->MaxHP;
	}
}

The purpose is to set this variable (used by the Pegasus Boots) to Link's Max HP to keep from having the glitch where whenever you start the game, his HP is drained.

 

Edit: I have now tested this out in a game where the HP-draining bug occurred and it fixed it right up! I don't know if the bug with the Day/Night script was related or not still, since I didn't bother to test it during the period when the first bug occurred and after patching that gap; the Day/Night script is still working. At least that is one problem I won't have to worry about anymore.


Edited by ywkls, 05 October 2015 - 04:25 PM.


#180 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 05 October 2015 - 06:20 PM

What's the purpose of StoreHP? If it's to detect a change in Link's HP as a proxy for detecting when the player gets hit, Link's actual HP shouldn't ever be getting set to it.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users