Post new topic    
Liquid Metal Slime
Send private message
Simple Script Problem 
 PostWed Dec 30, 2009 6:16 am
Send private message Reply with quote
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:
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]
Cornbread Chemist
Reigning Smash Champion
Send private message
 
 PostWed Dec 30, 2009 6:19 am
Send private message Reply with quote
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
Liquid Metal Slime
Send private message
 
 PostWed Dec 30, 2009 2:59 pm
Send private message Reply with quote
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:
plotscript,collision,begin
   variable (posx)
   variable (posy)
   posx := hero X (0)
   posy := hero Y (0)
   if (npc at spot ((posx) - 1)) then (
   walk hero (0,right,1)
   wait for hero (0))
   if (npc at spot ((posy) - 1)) then (
   walk hero (0,down,1)
   wait for hero (0))
   if (npc at spot ((posy) + 1)) then (
   walk hero (0,up,1)
   wait for hero (0))
   if (npc at spot ((posx) + 1)) then (
   walk hero (0,left,1)
   wait for hero (0))
   health -= 1
   wait (10)
   clear string (string:health)
      $1="Health: "
      append number (string:health, health)
   if (health == 0) then (game over)
end

Cornbread Chemist
Liquid Metal Slime
Send private message
 
 PostWed Dec 30, 2009 4:36 pm
Send private message Reply with quote
Figured that part out. Didn't declare the second coordinate for npc at spot so it wasn't working properly.
Cornbread Chemist
Display posts from previous: