Post new topic    
Red Slime
Send private message
scripting troubles again. 
 PostTue Aug 28, 2012 10:38 pm
Send private message Reply with quote
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
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Blubber Bloat
Send private message
 
 PostWed Aug 29, 2012 12:57 am
Send private message Reply with quote
I'm not seeing an "end" after the "firstscene" script.
dOn'T MiNd mE! i'M jUsT CoNtAgIoUs!!!
Play Orbs CCG: http://orbsccg.com/r/4r6x V
Metal Slime
Send private message
 
 PostWed Aug 29, 2012 1:57 am
Send private message Reply with quote
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:
Code:
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

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.
I am Srime
Liquid Metal King Slime
Send private message
 
 PostWed Aug 29, 2012 2:41 am
Send private message Reply with quote
Also, delete the "define script" commands entirely. Those are only for old-style scripts and you haven't needed them since 2005.

If you find any example scripts on the wiki or anywhere else that use the old-style "define script" let me know so I can fix them.
Slime Knight
Send private message
 
 PostWed Aug 29, 2012 2:52 am
Send private message Reply with quote
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.
Liquid Metal King Slime
Send private message
 
 PostWed Aug 29, 2012 1:59 pm
Send private message Reply with quote
Yes, indenting is super helpful! It makes it so much easier to spot missing/incorrect parenthesis and "end"s
Metal King Slime
Send private message
 
 PostWed Aug 29, 2012 5:31 pm
Send private message Reply with quote
I would make HSpeak guess where ends are missing from if I could, but as far as I know it's actually impossible to tell.
Liquid Metal King Slime
Send private message
 
 PostWed Aug 29, 2012 7:53 pm
Send private message Reply with quote
Oh! And another thing about the "define script" commands that I didn't notice before. You have two of them with the same ID number, and that definitely is a problem. All the more reason not to use define script at all.
Red Slime
Send private message
Thanks 
 PostTue Sep 04, 2012 11:03 pm
Send private message Reply with quote
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.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Metal King Slime
Send private message
 
 PostWed Sep 05, 2012 10:06 am
Send private message Reply with quote
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?
Red Slime
Send private message
 
 PostWed Sep 12, 2012 5:53 pm
Send private message Reply with quote
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.
The high and mighty confused queen of the thirteenth tile on the bathroom floor
Metal Slime
Send private message
 
 PostWed Sep 12, 2012 10:52 pm
Send private message Reply with quote
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:
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 stuff

I am Srime
Metal King Slime
Send private message
 
 PostThu Sep 13, 2012 1:06 pm
Send private message Reply with quote
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

Code:
create NPC (6, 14, 3)


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.
Display posts from previous: