Post new topic    
Metal Slime
Send private message
need help with plotscripting 
 PostSat Aug 27, 2011 3:03 pm
Send private message Reply with quote
Hello,
I decidet to take a deeper look on plotscripting for improving my game.
I have some questions:

1) Why aren't theese scripts working?

The NPCs 17 and 18 do give the items to the player, but they aren't moving. Sad

Quote:

#-----------------------------------------------------
#This script gives presents (5 Berrys, 2 Sticks, 3 Stones)
#and makes NPC 17 walk out of the way:

plotscript, Geschenke1,begin
get item (15,5)
get item (19,2)
get item (20,3)

suspend player
walk NPC (17,north,3)
wait for NPC (0)
walk NPC (17,west,2)
wait for NPC (0)
walk NPC (17,west,1)
resume player


end


#-----------------------------------------------------
# This script gives presents: (2 Berrys, and 5 Musrooms of each type)
# and makes NPC 18 walk out of the way:

plotscript, Geschenke2,begin
get item (15,2)
get item (16,5)
get item (17,5)
get item (18,5)

suspend player
walk NPC (18,west,1)
wait for NPC (18)
resume player
end

---


2. Is ist possible to make falling snow by using plotscripts and layers? Would this be very difficult?


3. Did I forget something? Does this look as if could work? Do you have other ideas?

I have never written a plotscript using global variables before. Surprised

Introduction:
Something was stolen, the player has to find 4 thives and talk to them. After winning agains the first one, the second thive appears on the map and the player gets one of the the stolen items back, and he gets a hint where to find the him. The Item and hint the player recives I planed to handle by using textboxes.
But for the rest I'd like to use this poltscripts.

Do I have to run the script on other situations as well?
(All the thives are on the same map.)

Quote:
global variable „Diebstahl“ should be cheked in the after-battle-script of the thives (( that makes the next thive appear)), then the room starts (onley the map on whitch the thieves are placed), and then it is activaetd the first time!

if (variable Diebstahl < 5)
then, begin
always set tag Diebstah = on/ture
{
case variable Diebstahl = 1
{
#make thive 1 appear ; tag ww1 = ture
set tag (ww1,ture)
}
case variable = 2
{
#make thive 2 appear ;ww2
}
case variable = 3 ;
{
#make thive 3 appear ;
set tag (ww3,true)
}
case variable = 4
{
#make thive 4 appear;
set tag (ww4,true)
}
if (variable Diebstahl = 5)
#{then make all thives dissappear! }
end
King Slime
Send private message
 
 PostSat Aug 27, 2011 3:18 pm
Send private message Reply with quote
1. Did you give the NPC's any speed?
2. Yes. And no, it is not difficult. You can use tile animations to make the snow appear like it's falling.
3. It looks like it could work.

Also, for your other script, you keep mispelling true. It is not T-U-R-E.
Slime Knight
Send private message
 
 PostSat Aug 27, 2011 4:04 pm
Send private message Reply with quote
Hey, your plotscript isn't working because you put wait for NPC(0) instead of the NPC you want to wait for. Well, Master K has a point too. At first I used to forget to set my NPC speed so they'd never move so check that for sure as well. Also, the last NPC on the first half of your script isn't being waited for, make sure to wait for every one!

Basically, change the
walk NPC (17,north,3)
wait for NPC (0)
walk NPC (17,west,2)
wait for NPC (0)
walk NPC (17,west,1)

to:
walk NPC (17,north,3)
wait for NPC (17) <----------- CHANGE 0 to 17
walk NPC (17,west,2)
wait for NPC (17)<------------ CHANGE 0 to 17
walk NPC (17,west,1)
wait for NPC(17)<--------- ADD THIS LINE

hope this helped!
You can't fix stupidity.
Metal Slime
Send private message
 
 PostSat Aug 27, 2011 6:06 pm
Send private message Reply with quote
Thank you! Smile
Now the NPCs are moving! I'm happy. Smile

I didn't set their speed. lol

I'll try out the other script.
And than i'll try animation falling snowflakes with tile animation.

edit:

An other Question:
How do i declare a global variable? Confused

I try this:
Quote:
plotscript, setting Diebstahl, begin
# setzt die Variable Diebstahl! Wichtig!
global variable(1,Diebstahl)
end
#----------------------------------------


And I get that Error:
Quote:

Error: in line 171 of script (...)

global variable(1,Diebstahl)
declaration globalvariable is not permitted in a script. Perhaps setting Diebstahl has an extra begin or (
Metal King Slime
Send private message
 
 PostSat Aug 27, 2011 9:26 pm
Send private message Reply with quote
Global variables have to be declared outside of any script. It doesn't matter where you put them, as long as they're outside. Like this:
Code:
global variable(1,Diebstahl)

plotscript, setting Diebstahl, begin


Now, as for your thieves. It's possible to do this without scripting, by giving each thief NPC a textbox which turns on the tag for the next thief to appear. But here is how you write the script you were trying to:

Code:

if (Diebstahl << 5) then, begin
  set tag (tag:Diebstah, on)
  switch (Diebstahl) do, begin
    case (1) do (set tag (tag:ww1, on))
    case (2) do (set tag (tag:ww2, on))
    case (3) do (set tag (tag:ww3, on))
    case (4) do (set tag (tag:ww4, on))
  end
end
if (Diebstahl == 5) then, begin
  set tag (tag:ww1, off)
  set tag (tag:ww2, off)
  set tag (tag:ww3, off)
  set tag (tag:ww4, off)
end


(You can use "true" and "false" instead of "on" and "off" as well)

To set Diebstahl to some value (say, 1), write "Diebstahl := 1". Also, to increase Diebstahl by 1 you can write "Diebstahl += 1".

Don't forget: you have to export an HSI file from your game to refer to your tags like "tag:X".
Metal Slime
Send private message
 
 PostSun Aug 28, 2011 9:08 am
Send private message Reply with quote
Thank you for your help! Grin
The script you wrote lookes a lot easier to read than mine.

I did use textboxes, and it worked, but later I changed something and the thief-quest didn't work anymore. And I didn't understand the way the text boxes worked (there where to many of them), so i thought a script would be esier. Just one look, and you can see who does what and when. Smile

Do i have to declare tags as tags aswell? Confused
How do i do this?
Then i tryed to compile the script with hspeak.
Quote:

#setzt die Variable Diebstahl! Wichtig!
global variable(1,Diebstahl)

plotscript, Diebstahlscript,begin
switch (Diebstahl) do, begin
case (0) do (Diebstahl += 1 )
case (1) do (set tag (ww1, on))
case (2) do (set tag (ww2, on))
case (3) do (set tag (ww3, on))
case (4) do (set tag (ww4, on))
end

if (Diebstahl == 5) then, begin
set tag (ww1, off)
set tag (ww2, off)
set tag (ww3, off)
set tag (ww4, off)
end
end


I get an error, saying that ww1 (I guess this goes for al ww-tags)
Quote:
'needs to be defines as script, constant, variable or anything else.'
Metal King Slime
Send private message
 
 PostSun Aug 28, 2011 9:21 am
Send private message Reply with quote
Notice that I wrote "tag:ww1" instead of "ww1" in my script. I don't know why you changed it back to "ww1". I assume that you have tags named ww1, ww2, etc, in your game. Go to the Script Management menu in Custom and "Export HSI File". It'll create an .hsi file in the same directory as your game which contains constant definitions such as "tag:ww1". Then at the top of your scripts file, add
Code:
include, mygame.hsi

changing "mygame" to whatever the name of your game/file is.

Also, if this script if run after every thief you defeat, I think you probably want to put "Diebstahl += 1" at the top of your script so that happens every time.
Metal Slime
Send private message
 
 PostSun Aug 28, 2011 10:35 am
Send private message Reply with quote
Thanks! Grin
Now it did compile the script! Smile *happy*

I wrote "Diebstahl += 1" at the top of the script, and now i 'll test how it works. Grin
Display posts from previous: