Simple Script Problem

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Simple Script Problem

Post by Meatballsub »

I'm trying to get myself back into plotscripting and not having much luck so far.

I never have done really complicated scripts, but the ones used in my two games, especially Mikey T, made me proud.

Sadly, I haven't scripted in over a year, and don't remember jack crap. Even the simplest things seem tough. Here's my script:

Code: Select all

include, plotscr.hsd
include, scancode.hsi

global variable,begin
	1, health	
end

define constant,begin
	1, string:health
end



plotscript,game,begin
		health := 10
	$1="Health: "
	show string at (1,20,10)
	append number (string:health, health)
	show string at (string:health,30,10)
	wait for all
end

plotscript,collision,begin
	health -= 1
	wait (10)
	clear string (string:health)
		append number (string:health, health)
	if (health == 0) then (game over)
end
I know this is probably the most hillbilly way to set a health bar and update it, but it is the only way in over an hour's time that I've figured out how to do it.

The problem is that when I clear the string, it erases the other string on the screen as well, not just the actual representation of health.

Any help on this would be much appreciated. Again, I know it is an easy fix, but I can't wrap my head around scripting anymore.

Which leads me to another thing; we've had many good plotscripting articles over the years. Unfortunately though, many of them were made for specific things in mind (the side-scrolling ones come to mind). I was thinking it would be pretty sweet if someone were to make a general tutorial on plotscripting. Something that is a bit more advanced than this.

Maybe it's just me, but I think such an article would be really beneficial to folks looking for a refresher on plotscripting altogether.[/url]
User avatar
Newbie Newtype
Reigning Smash Champion
Posts: 1873
Joined: Mon Oct 15, 2007 9:44 pm

Post by Newbie Newtype »

When you're clearing the string in the collision, you're forgetting to add another

$1 = "Health: "

after it before appending the number to it.
<TheGiz> oh hai doggy, oh no that's the straw that broke tjhe came baclsb
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Post by Meatballsub »

Thanks for the help. That did the trick.

Now I am having a problem with a "knockback" idea. I intended for it to read the position of the hero, check where the npc was in reference to the hero, and push him back a tile, direction depending on the location of the npc. It doesn't seem to be working at all though:

Code: Select all

plotscript,collision,begin
	variable &#40;posx&#41;
	variable &#40;posy&#41;
	posx &#58;= hero X &#40;0&#41;
	posy &#58;= hero Y &#40;0&#41;
	if &#40;npc at spot &#40;&#40;posx&#41; - 1&#41;&#41; then &#40;
	walk hero &#40;0,right,1&#41;
	wait for hero &#40;0&#41;&#41;
	if &#40;npc at spot &#40;&#40;posy&#41; - 1&#41;&#41; then &#40;
	walk hero &#40;0,down,1&#41;
	wait for hero &#40;0&#41;&#41;
	if &#40;npc at spot &#40;&#40;posy&#41; + 1&#41;&#41; then &#40;
	walk hero &#40;0,up,1&#41;
	wait for hero &#40;0&#41;&#41;
	if &#40;npc at spot &#40;&#40;posx&#41; + 1&#41;&#41; then &#40;
	walk hero &#40;0,left,1&#41;
	wait for hero &#40;0&#41;&#41;
	health -= 1
	wait &#40;10&#41;
	clear string &#40;string&#58;health&#41;
		$1="Health&#58; "
		append number &#40;string&#58;health, health&#41;
	if &#40;health == 0&#41; then &#40;game over&#41;
end
User avatar
Meatballsub
Liquid Metal Slime
Posts: 996
Joined: Mon Oct 15, 2007 6:39 pm
Location: Northwest Georgia
Contact:

Post by Meatballsub »

Figured that part out. Didn't declare the second coordinate for npc at spot so it wasn't working properly.
Post Reply