Good evening,
I need help to find the mistakes in this ploscrit, the messages I recives while runing hamsterspeak/the editor were a bit confusing. Maybe I'm doing something fundamentally wrong with if-else-clauses. I don't know, so I ask for help.
This is the whole plotscript ...
include, plotscr.hsd
include, FoolsQuest.hsi
# Here all the scripts go, that are used in the game FooldQuest (against the All-Seeing-Eye)
# ~marionline
#Tutorial
# run by NPCs to check what they say.
#checks the follwing tags
#4,tag:have bag
#5,tag:have coat
#6,tag:have bottle
#7,tag:have Kerli
#15,tag:Donowell in team
plotscript, bag, begin
if (checktag (4) == 1) then,
show text box (11) # Great! Now, let's get the red bottle. It's a potion, use it to recover HP.
else then
show text box (15) # That's not the thing I'm looking for right now...
end # end of plotscript
plotscript, coat, begin
if (checktag (4) == 1) then,
show text box (15) # That's not the thing I'm looking for right now...
else if (checktag (5) == 1)
show text box (15) # That's not the thing I'm looking for right now...
else then
show text box (15) # That's not the thing I'm looking for right now...
end # end of plotscript
plotscript, bottle, begin
if (checktag (6) == 1) then, begin
show text box (12) # Eh? Where is my marionette?
end
else if (check tag (4) == 1)
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end if the else-clause
else if (check tag (5) == 1)
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end if the else-clause
else then
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end the else-clause
end # end of plotscript
plotscript, bird,begin
else if (check tag (7) == 1)
begin
show text box (13) #fight bird
if (checktag check tag (6) == 1) then,
beginn
show text box (15) # That's not the thing I'm looking for right now...
end # of the if-clause
else if ( check tag (4) == 1)
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end if the else-clause
else if ( check tag (5) == 1)
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end if the else-clause
else then
begin
show text box (15) # That's not the thing I'm looking for right now...
end #end the else-clause
end # end of plotscript
plotscript, NPC Kobold, begin
# if Do-no-Well is team leader:
if (checktag check tag (15) == 1) then,
begin
show text box (86)
end #end if the if-clause
end # end of plotscript
Last edited by marionline on Wed Jul 03, 2013 9:41 pm, edited 1 time in total.
Every if, then, or else needs a ( immediately after it, and a ) at the end of everything inside that if/then/else command (so each separate if/then/else branch is surrounded by its own set of parentheses.)
If you have another if/then/else inside of a then or else, those need their own set of parentheses too, like these:
You can actually combine 'else' and 'if' into 'else if', but there's no such keyword as 'else then'. Aside from that, you are missing lots of begins and ends, or equivalently, ('s and )'s. Each 'then' and each 'else' must be followed either by ( or by ", begin". (If the begin is on a different line, then the comma is optional. Otherwise you need to use a command to separate keywords like 'then' and 'begin'.) Here's the corrected version of your 'coat' script:
plotscript, coat, begin
if (checktag (tag:have bag)) then (
show text box (15) # That's not the thing I'm looking for right now...
) else if (checktag (tag:have coat)) then (
show text box (15) # That's not the thing I'm looking for right now...
) else (
show text box (15) # That's not the thing I'm looking for right now...
)
end
Also, notice that it's easier to use constants like "tag:have bag" directly instead of the ID numbers.
Last edited by TMC on Thu Jul 04, 2013 4:39 am, edited 1 time in total.
Thanks a lot!
I corrected the script with yiur help and expainations, and now I can continue working on my game's scripts and plot.
I just realised that I can not set tag by using an NPC (only by using Textboxes) ... so the whole scripts are rather useless. >_<
So, I'll have to think of other ways to mange the whole textbox-reaction- things neatly then...
Do you have any ideas? :/
Last edited by marionline on Fri Jul 05, 2013 1:57 pm, edited 1 time in total.
marionline wrote:Thanks a lot!
I corrected the script with yiur help and expainations, and now I can continue working on my game's scripts and plot.
I just realised that I can not set tag by using an NPC (only by using Textboxes) ... so the whole scripts are rather useless. >_<
So, I'll have to think of other ways to mange the whole textbox-reaction- things neatly then...
Do you have any ideas? :/
While you can't set a tag by using an NPC in CUSTOM, just create a simple script and change the Run Script option in Edit NPC.