scripting troubles again.
Moderators: Bob the Hamster, marionline, SDHawk
scripting troubles again.
After J_Taylor decided to settled down south we gave up scripting any game at least till this one. Now we forgot much of what we knew. So here the mess. In time we want to add between each "advance text box" scripts but left these out just to see if it would work and it doesn't. So what missing? Thank you for the help.
Here's the code:
include, plotscr.hsd
include, Mikaels Dudgeon.hsi
define script (1, first scene, none)
define script (2, Tagtrouble, none)
define script (2, TagtroubleII, none)
Plotscript, first scene, begin
suspend player
suspend box advance
set hero position (hero:me, right)
show text box (18)
wait (45)
advance text box
wait (45)
advance text box # "won't"
wait (45)
advance text box # "Most believe"
wait (45)
advance text box # "really how long can we stay?"
wait (45)
advance text box # Try one
wait (90) # eats sandwich
advance text box # It's bland
wait (45)
advance text box # can hunt
wait (45) #gives matches ??
advance text box # store
wait (45)
advance text box #store?
wait (45)
advance text box # of course
wait (45)
advance text box # where store
NPC at spot (NPC:1, right)
wait (45)
NPC at spot (NPC:1, left)
wait (45)
advance text #32 locked?
wait (45)
advance text # 33
wait (45)
advance text # 34
Plotscript, Tagtrouble begin
if (check tag(2)==ON) then begin
Show box 35
wait (45)
show box (36)
wait (45)
NPC at spot (NPC:1, down)
wait (45)
NPC at spot (NPC:1, left)
Show box 37
wait (45)
destroy NPC (NPC:1)
end
if (check tag(3)==ON) then, begin
Show text box (38) #MOney
Wait (45)
Advance text box #39
Plotscript, TagtroubleII begin
if (check tag(2)==ON) then begin
Show box 35
wait (45)
show box (36)
wait (45)
NPC at spot (NPC:1, down)
wait (45)
NPC at spot (NPC:1, left)
Show box 37
wait (45)
destroy NPC (NPC:1)
end
if (check tag(3)==ON) then, begin
Show text box (41)
end
end
end
end
end
Here's the code:
include, plotscr.hsd
include, Mikaels Dudgeon.hsi
define script (1, first scene, none)
define script (2, Tagtrouble, none)
define script (2, TagtroubleII, none)
Plotscript, first scene, begin
suspend player
suspend box advance
set hero position (hero:me, right)
show text box (18)
wait (45)
advance text box
wait (45)
advance text box # "won't"
wait (45)
advance text box # "Most believe"
wait (45)
advance text box # "really how long can we stay?"
wait (45)
advance text box # Try one
wait (90) # eats sandwich
advance text box # It's bland
wait (45)
advance text box # can hunt
wait (45) #gives matches ??
advance text box # store
wait (45)
advance text box #store?
wait (45)
advance text box # of course
wait (45)
advance text box # where store
NPC at spot (NPC:1, right)
wait (45)
NPC at spot (NPC:1, left)
wait (45)
advance text #32 locked?
wait (45)
advance text # 33
wait (45)
advance text # 34
Plotscript, Tagtrouble begin
if (check tag(2)==ON) then begin
Show box 35
wait (45)
show box (36)
wait (45)
NPC at spot (NPC:1, down)
wait (45)
NPC at spot (NPC:1, left)
Show box 37
wait (45)
destroy NPC (NPC:1)
end
if (check tag(3)==ON) then, begin
Show text box (38) #MOney
Wait (45)
Advance text box #39
Plotscript, TagtroubleII begin
if (check tag(2)==ON) then begin
Show box 35
wait (45)
show box (36)
wait (45)
NPC at spot (NPC:1, down)
wait (45)
NPC at spot (NPC:1, left)
Show box 37
wait (45)
destroy NPC (NPC:1)
end
if (check tag(3)==ON) then, begin
Show text box (41)
end
end
end
end
end
The high and mighty confused queen of the thirteenth tile on the bathroom floor
- Meowskivich
- Blubber Bloat
- Posts: 2199
- Joined: Tue Mar 06, 2012 12:38 am
- Location: Earth
- Contact:
Yes, your end's are quite misplaced. You cannot start typing a new plotscript before having your final "end" in your old plotscript. As a very simple illustration of this point, your plotscript "Tagtrouble" has 3 'begins' by my count, but only 1 'end' before you try to start the new plotscript "TagtroubleII".
You can't cluster all of your 'ends' at the end of your file. You need your 'ends' to match your 'begins' more carefully than that. You seem to have this worked out for this:
The above code is correct. Notice how you 'begin' the stuff that depends on tag2, then 'end' it as soon as you are done, rather than waiting to type that 'end' at the bottom of the file. ALL instances where you type the word 'begin' should work like this. So when you type the word 'begin' at the start of a plotscript like "firstscene", the word 'end' should appear at the conclusion of that particular plotscript, NOT at the conclusion of the text file.
EDIT:
Oops, well, the code above isn't all good. You're missing some parentheses for some of your 'show box' commands, which I'm assuming are a shortcut for some kind of textbox-showing script. And the NPC at Spot commands probably aren't doing what you want them to be doing (that command is supposed to take the x,y coordinates of the NPC you're looking for, and it doesn't make said NPC do anything). You probably want "set NPC direction" there. And if 1 is the ID number of the npc, you should have just "1" instead of "NPC:1". But I'm not sure what all this code is trying to accomplish. I was mostly focused on the begin/end problem first, so we can at least get it to compile.
You can't cluster all of your 'ends' at the end of your file. You need your 'ends' to match your 'begins' more carefully than that. You seem to have this worked out for this:
Code: Select all
if (check tag(2)==ON) then begin
Show box 35
wait (45)
show box (36)
wait (45)
NPC at spot (NPC:1, down)
wait (45)
NPC at spot (NPC:1, left)
Show box 37
wait (45)
destroy NPC (NPC:1)
end EDIT:
Oops, well, the code above isn't all good. You're missing some parentheses for some of your 'show box' commands, which I'm assuming are a shortcut for some kind of textbox-showing script. And the NPC at Spot commands probably aren't doing what you want them to be doing (that command is supposed to take the x,y coordinates of the NPC you're looking for, and it doesn't make said NPC do anything). You probably want "set NPC direction" there. And if 1 is the ID number of the npc, you should have just "1" instead of "NPC:1". But I'm not sure what all this code is trying to accomplish. I was mostly focused on the begin/end problem first, so we can at least get it to compile.
Last edited by msw188 on Wed Aug 29, 2012 2:01 am, edited 1 time in total.
I am Srime
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
This has a lot of problems. Missing and misplaced 'ends,' missing parentheses, spelling errors, and improper usage of commands, if not just made up commands. I don't think "show box" is a real command. I also have know idea what you're trying to do with "set hero position (me, right)" perhaps you mean "set hero direction"?
And later:
"NPC at spot (NPC:1, right)"
I don't even know what you're expecting that to do?
I'd recommend going through the tutorials and coding carefully--keep your syntax consistent and learn how/when to indent. Pay attention to not only the commands James or TMC use when they help someone on the forum, but also their formatting.
And later:
"NPC at spot (NPC:1, right)"
I don't even know what you're expecting that to do?
I'd recommend going through the tutorials and coding carefully--keep your syntax consistent and learn how/when to indent. Pay attention to not only the commands James or TMC use when they help someone on the forum, but also their formatting.
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
- Bob the Hamster
- Liquid Metal King Slime
- Posts: 7460
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
Thanks
Thanks everyone, you are kinder than my son. Still he helped me clean things up and I did remove the Define scripts and caught the missing ends. Still though I'm having a problem that you might be able to clear up.
We want the mage Androve to disappear when the initial dialog is finished. The player though can ask more questions so we can't just program the NPC to disappear at the end or he disappears too soon. This has to be scripted and we though we had but then it stops working whenever we add another script! Also even when it was working he still be there when we came back to the map. So here is the fixed up script. Can anyone see why these things are happening?
include, plotscr.hsd
include, Mikaels Dudgeon.hsi
Plotscript, firstscene, begin
create NPC (1, 2 , 4, left)
set hero direction (me,right)
show text box(18)
end
Plotscript, AndrovePoint, begin
Variable (Androve)
Androve:=NPC reference(1,0)
set NPC direction(Androve, right)
wait(15)
set NPC direction(Androve, left)
show text box(34)
set tag(2,off)
set tag(3,off)
end
Plotscript, gone, begin
Variable (Androve)
Androve:= NPC reference (1,0)
destroy NPC (Androve)
end
Thanks again for all your constructive criticism and help.
We want the mage Androve to disappear when the initial dialog is finished. The player though can ask more questions so we can't just program the NPC to disappear at the end or he disappears too soon. This has to be scripted and we though we had but then it stops working whenever we add another script! Also even when it was working he still be there when we came back to the map. So here is the fixed up script. Can anyone see why these things are happening?
include, plotscr.hsd
include, Mikaels Dudgeon.hsi
Plotscript, firstscene, begin
create NPC (1, 2 , 4, left)
set hero direction (me,right)
show text box(18)
end
Plotscript, AndrovePoint, begin
Variable (Androve)
Androve:=NPC reference(1,0)
set NPC direction(Androve, right)
wait(15)
set NPC direction(Androve, left)
show text box(34)
set tag(2,off)
set tag(3,off)
end
Plotscript, gone, begin
Variable (Androve)
Androve:= NPC reference (1,0)
destroy NPC (Androve)
end
Thanks again for all your constructive criticism and help.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
I don't understand what you mean by "whenever we add another script". Could you give an example or post the script?
"destroy npc" has a temporary effect, unless the NPC was created with "create npc". (You can make it last when you leave and reenter a map by selecting "NPC Data: Remember state when leaving" in the General Map Settings menu, but it still won't be saved in saved games! The normal way to permanently delete an NPC is to give it an "Appear only if tag #=ON/OFF" setting, and then turn the tag off/on.)
But in this case it looks like you really are creating the NPC with "create npc". So check the following:
Did you also place a copy of NPC 1 on the map in Custom? If so, "destroy npc" might destroy the wrong one.
Do you call "firstscene" just once, or every time you enter the map?
"destroy npc" has a temporary effect, unless the NPC was created with "create npc". (You can make it last when you leave and reenter a map by selecting "NPC Data: Remember state when leaving" in the General Map Settings menu, but it still won't be saved in saved games! The normal way to permanently delete an NPC is to give it an "Appear only if tag #=ON/OFF" setting, and then turn the tag off/on.)
But in this case it looks like you really are creating the NPC with "create npc". So check the following:
Did you also place a copy of NPC 1 on the map in Custom? If so, "destroy npc" might destroy the wrong one.
Do you call "firstscene" just once, or every time you enter the map?
Last edited by TMC on Wed Sep 05, 2012 10:13 am, edited 1 time in total.
Thank TMC,
I'll try that. As for what I was trying to add this is an example:
Plotscript, skellybones, begin
If(check tag(4)==ON) then, begin
Variable (skelly)
skelly:= NPC reference (6, 0)
create NPC (Skelly, 14, 3)
end
end
When I put this in the previous script stopped working.
I'll try that. As for what I was trying to add this is an example:
Plotscript, skellybones, begin
If(check tag(4)==ON) then, begin
Variable (skelly)
skelly:= NPC reference (6, 0)
create NPC (Skelly, 14, 3)
end
end
When I put this in the previous script stopped working.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
That's bizarre. Make sure you are putting this in at the VERY end of your text file (not before any already existing end's). The following is not allowed:
Code: Select all
plotscript,GOODSTUFF,begin
#do good stuff
#do good stuff
#do good stuff involving correctly placed begins and ends
#still doing good stuff, haven't yet 'ended' the good stuff
plotscript,OTHERSTUFF,begin
#do other stuff
#keep doing other stuff, even though I never told you that you were done doing the good stuff
end #signifying the end of other stuff
end#signifying the end of good stuffI am Srime
The first argument of "create NPC" should be an NPC ID number, not an NPC reference. That won't work. That's because it acting on any existing NPC; it's creating a new one. Write just
As you wrote it, your script will actually either do nothing at all if there is already a copy of NPC 6 on the map, or create a copy of NPC 0 if there is one! I hope that helps figure out what is going on.
Code: Select all
create NPC (6, 14, 3)