Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Equal Variables

18 years ago
In Devil West, I have MAXHP and HP. MAXHP is basically the most HP your character can have at the time, and HP is his current health. So far it'll look like this:

Vitality: %%HP%%/%%MAXHP%%

You see, as you go further into the game, your MAXHP can become higher, meaning your HP can go higher. When the character rests, I want the HP to be able to reset itself equal to the current MAXHP.

Is there a Variable Tweak that can do this, or must I use scripting. I'd appreciate it if somebody could tell me how to accomplish this.

Equal Variables

18 years ago
Well scripting or more then one page.

Equal Variables

18 years ago
If doing this on one page isn't possible, then I'd rather do it on more than one page over scripting.

Equal Variables

18 years ago

This can be achieved mainly through scripting. So when your character is at rest, on the pages link that takes you to the rest stop, put this in the scripting options of the link:

%HP := %MAXHP

 

So basically, whenever a player hits a link with that coded, then the hp resets itself to the value of the maxhp. Simple, eh?

Equal Variables

18 years ago
Dude thats great :D

Equal Variables

18 years ago
I already guessed that.. I was just looking for an alternative to scripting. Thankyou anyways, Solo.

Equal Variables

18 years ago
As in, I may as well use scripting.

Equal Variables

18 years ago
A little more advanced, I may not use this method. You might only regain about 20 or something HP, and that might not be as high as your MAXHP, but it might be.. How do you say that your HP cannot go over your MAXHP? Is there a script that can do that?

Equal Variables

18 years ago

No problem at all October, i kind of figured that you knew what to do, but what the heck, it was one line of code... anyways, put the following in the global link script, it will not allow your HP to go over MAXHP

IF %HP > %MAXHP THEN
%HP := %MAXHP

Basically, if the variable %%HP%% is greater than the variable %%MAXHP%%, then reassign the value of %%HP%% to the value of the variable %%MAXHP%%. Simple, right?

What will actually happen is, let us say that MAXHP is 20, and your HP is at 19, and HP is increased by 2, from whatever, could be a life restore, whatever, this would make HP go to 21, so in the meanwhile, what will happen is %%HP%% will have a value greater than MAXHP, however, after the next link is pressed, it will be restored back to 20.  What you can also do to prevent this from happening is putting the same above line of code into "items" that affect health. So if you have an apple that regenerates health, put that code in.

Hope that helps :)

Equal Variables

18 years ago
Thanks Solo. Saved me from another failed attempt to figure out scripting. I think actually using examples like you've done there that I understand are actually helping me.

Equal Variables

18 years ago
Solo, I've been scripting like a maniac, but always on links. How does the link at the top of every page work and when does it fire? I couldn't make anything happen by putting a script in there.

Equal Variables

18 years ago

You must mean "page scripts". A page script can be accessed in the following way: through the global page script, and the individual script links at the top of the edit page box, right next to the title.

Link (please note, i said, link, not page) scripts are executed after the player clicks the link(s). A page (note that i said page, not link) script is executed before the page loads. So for example, in a link script, you can have the variable %LIFE increase by 1. In a page script, you cannot do this, because, well, thats how it is. Page scripts are used to, at the most basic level, alter the description and title of the page. So, put this in a page script and see what you get:

IF %NUMBEROFBOOKS = 1 THEN
$PAGETEXT := "You have 1 book"

Basically, if the variable, NUMBEROFBOOKS is 1, then erase everything that was previously entered in the page's descirption box, and replace it with "You have 1 book". This can come in handy in too many different situations to actually list, however, lets say you liked or wanted what you had in teh page description BUT you wanted to add, for example, a text blurb that said the user is at a certain level. The following will go in a global page script:

IF %LEVEL = 1 THEN
$PAGETEXT := $PAGETEXT + "You are at level 1!"

What this does is, it first determines if %LEVEL is equal to 1, then it if that is true, it keeps the current page descirption AND adds the blurb "You are at level 1!" .  This is on EVERY page because it is in a global page script, if you wanted it only one page or NOT every page, you need to put them in individual page scripts.

If you wanted to display more levels, there are three ways of doing this:

The first way is checking off the "Display on every page" checkbox in the variable options for the variable, in this case %LEVEL, that you want to have on each page. It will be displayed as "LEVEL is #"

Or:

IF %LEVEL = 1 THEN
$PAGETEXT := $PAGETEXT + "You are at level 1!"

IF %LEVEL = 2 THEN
$PAGETEXT := $PAGETEXT + "You are at level 2!"

IF %LEVEL = 3 THEN
$PAGETEXT := $PAGETEXT + "You are at level 3!"

But that means that for every level there is, you need to make a two-line code for it. An easier way that can be done is this, and i have not passed it through the script engine, so it may need correction in terms of syntax, if you get an error, let me know and i will fix it:

$PAGETEXT := $PAGETEXT + "You are at level " + %LEVEL

What this should do, as i said it has not been checked for erros, is as you know, add to the current page text, "You are at level " and then the value of %LEVEL is included.

Equal Variables

18 years ago
Dude thast amazing!

Equal Variables

18 years ago
i know i am :P lol

Equal Variables

18 years ago
Hrm cool. Yeah, I tried using it to modify stats on the fly and it doesn't work, which is weird. Obviously link scripts work fine. Let's say I wanted to use a page script to write a huge paragraph. Would it work as long as I put it in quotes? Nevermind. I'll just script it and see what happens. Thanks for the answer though, very thorough.