Post new topic    
Page 1, 2  »
Red Slime
Send private message
Script doing weird things 
 PostTue May 17, 2011 11:53 am
Send private message Reply with quote
Hello, I'm having some trouble with a script.

The script is supposed to be a Final Fantasy Mystic Quest-style overworld, used to represent train travel between cities. Here's where bugs appear...

Quote:
plotscript, worldmapnewposeto, begin

#Arrows and all that
write map block (24, 27, 162, 3)
write map block (24, 27, 210, 4)
write map block (24, 31, 170, 3)
write map block (24, 31, 218, 4)
wait (1)

#Key input
if (key is pressed (01), or, key is pressed (56)), then, traintravelquit
if (key is pressed (72)), then, worldmapnpfs
if (key is pressed (28), or, key is pressed (29), or, key is pressed (57)), then, worldmapnpnp
end


The if (key is pressed (blah)) lines occur automatically, every single one, which causes a bunch of hash to spit out. But, if I add a begin and end after the then, nothing happens at all. It just sits there on the world map, arrows blinking.

What am I doing wrong?
Metal Slime
Send private message
 
 PostTue May 17, 2011 1:19 pm
Send private message Reply with quote
Try this for the keypress clauses:

Code:
if (key is pressed (01), or, key is pressed (56)) then(traintravelquit)
if (key is pressed (72)) then(worldmapnpfs)
if (key is pressed (28), or, key is pressed (29), or, key is pressed (57)) then(worldmapnpnp)


the syntax is if(conditional) then(do this)
or
if(conditional) then, begin
__do this
end
Metal Slime
Send private message
 
 PostTue May 17, 2011 1:32 pm
Send private message Reply with quote
RMSephy's syntax is correct, but this needs a lot more work. You need to wait for the player to press the key before checking what key he pressed. But since the player is free to press the wrong key before finally pressing the correct one, this is probably not the best way to do this. More likely, you ought to put all of your keypress statements in a separate, keypress script, and set that script as the on-keypress script for that map, as opposed to the map autorun script.
I am Srime
Red Slime
Send private message
 
 PostTue May 17, 2011 1:46 pm
Send private message Reply with quote
@RMSephy: I put them in parentheses, and now nothing happens once the map loads.

@msw188: How do I do that? Would the on-keypress script allow for different actions, depending on what area of the map the player has selected, in-game?
Metal Slime
Send private message
 
 PostTue May 17, 2011 3:31 pm
Send private message Reply with quote
You know what, thinking about all of this, I take back my suggestion. An on-keypress script WOULD work, but it would require just as much trickery as what I'm about to suggest, because it would have to make sure the player's keypresses don't interrupt an already occuring action. So let's do this instead:

The problem with your script is that if(key is pressed(whatever)), alone, does not wait for the key to be pressed. It just checks whether or not the player has pressed the key at the very moment the script is running (in this case, as soon as the player enters the map). We will need to have the script wait for the player to press a key, THEN check what key was pressed. To do this, we need:
Code:
wait for key
#all the if(key is pressed) stuff you already have, with parentheses as indicated


HOWEVER with only this in the script, if the player presses a key like "j" for fun, the script will wait until he presses "j", then check to see if "j" is any of those keys you indicated, and if not, it will simply move on. We need it to re-wait and re-check until the player pushes a 'correct' key, I'd say. We'll do it with a while loop:
Code:
variable(still_waiting) #this will be the indicator of when to move on
still_waiting:=true #right now, the player hasn't pressed a correct key yet
while ( still_waiting == true ), do
 begin
  wait for key
  if((key is pressed (01), or, key is pressed (56)), then,
   begin
    traintravelquit
    still_waiting:=false
   end
  #same setup for all your other key-checks
 end #an extra end for the end of the while loop


I don't know how familiar you are with plotscripting, or programming, or whatever. If any of this doesn't make sense, please don't hesitate to ask more questions!
I am Srime
Red Slime
Send private message
 
 PostTue May 17, 2011 10:38 pm
Send private message Reply with quote
I don't have any experience with plotscripting, or coding, or any of that... which is probably why the compiler is now refusing to accept the script file, at all.
Liquid Metal King Slime
Send private message
 
 PostTue May 17, 2011 10:41 pm
Send private message Reply with quote
English Ivy wrote:
I don't have any experience with plotscripting, or coding, or any of that... which is probably why the compiler is now refusing to accept the script file, at all.


is it giving you an error message?
Red Slime
Send private message
 
 PostTue May 17, 2011 10:56 pm
Send private message Reply with quote
Yep.

Quote:
#Key input
variable(still_waiting) #this will be the indicator of when to move on
still_waiting:=true #right now, the player hasn't pressed a correct key yet
while ( still_waiting == true ), do
begin
wait for key
if((key is pressed (01), or, key is pressed (56)), then,
begin
traintravelquit
still_waiting:=false
end
if (key is pressed (72)), then,
begin
worldmapnpfs
still_waiting:=false
end
if (key is pressed (28), or, key is pressed (29), or, key is pressed (57)), then,
begin
worldmapnpnp
still_waiting:=false
end
end
end
end


gives

Quote:
If statement has 6 conditions. It should only have one. Use and and or for complex conditions
Liquid Metal King Slime
Send private message
 
 PostTue May 17, 2011 11:09 pm
Send private message Reply with quote
When you post a script on the forum, you can use the Code tag to make sure the indentation doesn't get lost

Anyway, you had a misplaced parenthesis in this line:
Code:
if((key is pressed (01), or, key is pressed (56)), then,


and there was an extra "end" at the end.

I cleaned it up a bit:

Code:

  variable(still_waiting) #this will be the indicator of when to move on
  still_waiting:=true #right now, the player hasn't pressed a correct key yet
  while ( still_waiting == true ) do(
    wait for key
    if (key is pressed (01) || key is pressed (56)) then(
      traintravelquit
      still_waiting:=false
    )
    if (key is pressed (72)) then(
        worldmapnpfs
        still_waiting:=false
    )
    if (key is pressed (28) || key is pressed (29) || key is pressed (57)) then(
      worldmapnpnp
      still_waiting:=false
    )
  )


note that "begin" is just the long way of saying "(" and "end" is just the long way of saying ")"

Also, using || is better than "or" because you don't need the awkward commas. Same with using && instead of "and"

I really need to dig through all the demos in the wiki and examples in the documentation and replace all the ands and ors with &&'s and ||'s (except where bitwise operations are needed of course)
Red Slime
Send private message
 
 PostTue May 17, 2011 11:38 pm
Send private message Reply with quote
It works! Thanks!
Metal Slime
Send private message
 
 PostWed May 18, 2011 1:28 am
Send private message Reply with quote
Oops, that was my mistake when I typed up that original draft on how to arrange all this. Sorry about that! Glad you've got it worked out now though.
I am Srime
Red Slime
Send private message
 
 PostWed Jun 01, 2011 12:04 am
Send private message Reply with quote
...I don't suppose there's a quick way to replace begin and end with ( and ), is there?
Liquid Metal King Slime
Send private message
 
 PostWed Jun 01, 2011 12:26 am
Send private message Reply with quote
English Ivy wrote:
...I don't suppose there's a quick way to replace begin and end with ( and ), is there?


I am not sure which text editor you are using to write your script. Most text editors have a search/replace tool. (HamsterWhisper does not unfortunately, but you could open the script in nodepad temporarily and do the find/replace there)
Red Slime
Send private message
 
 PostWed Jun 01, 2011 12:39 am
Send private message Reply with quote
Oh, right.
Red Slime
Send private message
 
 PostWed Jun 01, 2011 1:01 am
Send private message Reply with quote
So it appears that cleaning up the code isn't fixing bugs that are popping up. Sigh.

What's happening is that, upon going to a new town, the string at the bottom left corner is still popping up, and it's making menu noises. Moving up and down "selects" other towns, and hitting enter will bring you to them. Also, cancelling sometimes makes the camera swoosh down, and spit out hash.

Obviously, this is not supposed to happen.

Code:
plotscript, worldmapnewposeto, begin

#Arrows and all that
write map block    (24, 27, 162, 3)
write map block    (24, 27, 210, 4)
write map block    (24, 31, 170, 3)
write map block    (24, 31, 218, 4)
$str:townname="New Poseto"
show string        (str:townname)
wait               (1)

#Key input
  variable(still_waiting) #this will be the indicator of when to move on
  still_waiting:=true #right now, the player hasn't pressed a correct key yet
  while ( still_waiting == true ) do(
    wait for key
    if (key is pressed (01) || key is pressed (56)) then(
      traintravelquit
      still_waiting:=false
    )
    if (key is pressed (72)) then(
        worldmapnpfs
        still_waiting:=false
    )
    if (key is pressed (28) || key is pressed (29) || key is pressed (57)) then(
      worldmapnpnp
      still_waiting:=false
    )
  )
end


plotscript, worldmapfaust, begin

#Arrows and all that
write map block    (24, 22, 162, 3)
write map block    (24, 22, 210, 4)
write map block    (24, 26, 166, 3)
write map block    (24, 26, 214, 4)
write map block    (22, 24, 170, 3)
write map block    (22, 24, 218, 4)
write map block    (26, 24, 170, 3)
write map block    (26, 24, 218, 4)
$str:townname="Faust"
show string        (str:townname)
wait               (1)

#Key input
  variable(still_waiting) #this will be the indicator of when to move on
  still_waiting:=true #right now, the player hasn't pressed a correct key yet
  while ( still_waiting == true ) do(
    wait for key
    if (key is pressed (01) || key is pressed (56)) then(
      traintravelquit
      still_waiting:=false
    )
    if (key is pressed (72)) then(
        worldmapfsws
        still_waiting:=false
    )
    if (key is pressed (80)) then(
        worldmapfsnp
        still_waiting:=false
    )
    if (key is pressed (28) || key is pressed (29) || key is pressed (57)) then(
      worldmapfsfs
      still_waiting:=false
    )
  )
end


plotscript, worldmapwhitesands, begin

#Arrows and all that
write map block    (26, 23, 166, 3)
write map block    (26, 23, 214, 4)
$str:townname="White Sands"
show string        (str:townname)
wait               (1)

#Key input
  variable(still_waiting) #this will be the indicator of when to move on
  still_waiting:=true #right now, the player hasn't pressed a correct key yet
  while ( still_waiting == true ) do(
    wait for key
    if (key is pressed (01) || key is pressed (56)) then(
      traintravelquit
      still_waiting:=false
    )
    if (key is pressed (80)) then(
        worldmapwsfs
        still_waiting:=false
    )
    if (key is pressed (28) || key is pressed (29) || key is pressed (57)) then(
      worldmapwsws
      still_waiting:=false
    )
  )
end


plotscript, worldmapnpfs, begin

#Moving from New Poseto to Faust
show no value
play sound         (1)
write map block    (24, 29, 0, 1)
write map block    (24, 29, 0, 2)
write map block    (24, 27, 0, 3)
write map block    (24, 27, 0, 4)
write map block    (24, 31, 0, 3)
write map block    (24, 31, 0, 4)
write map block    (24, 24, 160, 1)
write map block    (24, 24, 208, 2)
wait               (1)
focus camera       (24, 24, 10)
wait for camera
worldmapfaust
wait
end


plotscript, worldmapfsnp, begin

#Moving from Faust to New Poseto
show no value
play sound         (1)
write map block    (24, 24, 0, 1)
write map block    (24, 24, 0, 2)
write map block    (24, 22, 0, 3)
write map block    (24, 22, 0, 4)
write map block    (24, 26, 0, 3)
write map block    (24, 26, 0, 4)
write map block    (22, 24, 0, 3)
write map block    (22, 24, 0, 4)
write map block    (26, 24, 0, 3)
write map block    (26, 24, 0, 4)
write map block    (24, 29, 160, 1)
write map block    (24, 29, 208, 2)
wait               (1)
focus camera       (24, 29, 10)
wait for camera
worldmapnewposeto
wait
end


plotscript, worldmapfsws, begin

#Moving from Faust to White Sands
show no value
play sound         (1)
write map block    (24, 24, 0, 1)
write map block    (24, 24, 0, 2)
write map block    (24, 22, 0, 3)
write map block    (24, 22, 0, 4)
write map block    (24, 26, 0, 3)
write map block    (24, 26, 0, 4)
write map block    (22, 24, 0, 3)
write map block    (22, 24, 0, 4)
write map block    (26, 24, 0, 3)
write map block    (26, 24, 0, 4)
write map block    (26, 21, 160, 1)
write map block    (26, 21, 208, 2)
wait               (1)
focus camera       (26, 21, 10)
wait for camera
worldmapwhitesands
wait
end


plotscript, worldmapwsfs, begin

#Moving from White Sands to Faust
show no value
play sound         (1)
write map block    (26, 21, 0, 1)
write map block    (26, 21, 0, 2)
write map block    (26, 23, 0, 3)
write map block    (26, 23, 0, 4)
write map block    (24, 24, 160, 1)
write map block    (24, 24, 208, 2)
wait               (1)
focus camera       (24, 24, 10)
wait for camera
worldmapfaust
wait
end


plotscript, worldmapnpnp, begin

#Entering New Poseto
if                  (check tag (12)) then (
   traintravelquit
   )
show no value
set tag             (13, off)
set tag             (14, off)
play sound          (50)
wait                (1)
fade screen out
wait                (1)
teleport to map     (1, 25, 9)
camera follows hero
wait                (1)
fade screen in
wait                (1)
resume player
resume npcs
end


plotscript, worldmapfsfs, begin

#Entering Emperor Alexi IV Terminal
if                  (check tag (13)) then (
   traintravelquit
   )
show no value
set tag             (12, off)
set tag             (14, off)
play sound          (50)
wait                (1)
fade screen out
wait                (1)
teleport to map     (16, 1, 1)
camera follows hero
wait                (1)
fade screen in
wait                (1)
resume player
resume npcs
end


plotscript, worldmapwsws, begin

#Entering White Sands Terminal
if                  (check tag (14)) then (
   traintravelquit
   )
show no value
set tag             (12, off)
set tag             (13, off)
play sound          (50)
wait                (1)
fade screen out
wait                (1)
teleport to map     (17, 1, 1)
camera follows hero
wait                (1)
fade screen in
wait                (1)
resume player
resume npcs
end


plotscript, traintravel, begin

#Check to see what map player is in
suspend player
suspend npcs
wait               (1)
if                 (check tag (12)) then (

   #Mode 7 in New Poseto
   load tileset       (15)
   wait               (2)
   load tileset       (16)
   wait               (2)
   load tileset       (17)
   wait               (2)
   load tileset       (18)
   wait               (2)
   load tileset       (19)
   wait               (2)
   show backdrop      (1)
   wait               (1)

   #Mode 7 in world map (New Poseto)
   teleport to map    (14, 0, 16)
   wait               (1)
   load tileset       (14)
   put camera         (330, 490)
   wait               (1)
   show map
   wait               (2)
   load tileset       (13)
   wait               (2)
   load tileset       (12)
   wait               (2)
   load tileset       (11)
   wait               (2)
   load tileset       (10)
   wait               (2)
   load tileset
   wait               (1)
   write map block    (24, 29, 160, 1)
   write map block    (24, 29, 208, 2)
   write map block    (24, 29, 172, 3)
   write map block    (24, 29, 220, 4)
   show text box      (211)
   wait for text box
   play sound         (1)
   wait               (3)
   worldmapnewposeto
   )
if           (check tag (13)) then (

   #Mode 7 in Faust

   #Mode 7 in world map (Faust)
   teleport to map    (14, 0, 16)
   wait               (1)
   load tileset       (14)
   put camera         (330, 390)
   wait               (1)
   show map
   wait               (2)
   load tileset       (13)
   wait               (2)
   load tileset       (12)
   wait               (2)
   load tileset       (11)
   wait               (2)
   load tileset       (10)
   wait               (2)
   load tileset
   wait               (2)
   write map block    (24, 24, 160, 1)
   write map block    (24, 24, 208, 2)
   write map block    (24, 24, 172, 3)
   write map block    (24, 24, 220, 4)
   show text box      (211)
   wait for text box
   play sound         (1)
   worldmapfaust
   )
if           (check tag (14)) then (

   #Mode 7 in White Sands

   #Mode 7 in world map (White Sands)
   teleport to map    (14, 0, 16)
   wait               (1)
   load tileset       (14)
   put camera         (370, 330)
   wait               (1)
   show map
   wait               (2)
   load tileset       (13)
   wait               (2)
   load tileset       (12)
   wait               (2)
   load tileset       (11)
   wait               (2)
   load tileset       (10)
   wait               (2)
   load tileset
   wait               (2)
   write map block    (26, 21, 160, 1)
   write map block    (26, 21, 208, 2)
   write map block    (26, 21, 172, 3)
   write map block    (26, 21, 220, 4)
   show text box      (211)
   wait for text box
   play sound         (1)
   worldmapwhitesands
   )
end


plotscript, traintravelquit, begin

#Undoing the blinkies
show no value
play sound          (7)
wait                (1)
write map block    (24, 29, 0, 1)
write map block    (24, 29, 0, 2)
write map block    (24, 29, 0, 3)
write map block    (24, 29, 0, 4)
write map block    (24, 24, 0, 1)
write map block    (24, 24, 0, 2)
write map block    (24, 24, 0, 3)
write map block    (24, 24, 0, 4)
write map block    (26, 21, 0, 1)
write map block    (26, 21, 0, 2)
write map block    (26, 21, 0, 3)
write map block    (26, 21, 0, 4)
write map block    (24, 27, 0, 3)
write map block    (24, 27, 0, 4)
write map block    (24, 31, 0, 3)
write map block    (24, 31, 0, 4)
write map block    (24, 22, 0, 3)
write map block    (24, 22, 0, 4)
write map block    (24, 26, 0, 3)
write map block    (24, 26, 0, 4)
write map block    (22, 24, 0, 3)
write map block    (22, 24, 0, 4)
write map block    (26, 24, 0, 3)
write map block    (26, 24, 0, 4)
write map block    (26, 23, 0, 3)
write map block    (26, 23, 0, 4)

#Mode 7ing out

wait                (1)
load tileset        (10)
wait                (2)
load tileset        (11)
wait                (2)
load tileset        (12)
wait                (2)
load tileset        (13)
wait                (2)
load tileset        (14)
wait                (2)
show backdrop       (1)
wait                (1)
if                  (check tag (12)) then (

   #Mode 7ing into New Poseto
   set tag             (12, off)
   teleport to map     (1, 25, 9)
   camera follows hero
   load tileset        (19)
   wait                (1)
   show map
   wait                (2)
   load tileset        (18)
   wait                (2)
   load tileset        (17)
   wait                (2)
   load tileset        (16)
   wait                (2)
   load tileset        (15)
   wait                (2)
   load tileset
   wait                (2)
   resume player
   resume NPCs
   )
if       (check tag (13)) then (

   #Mode 7ing into Faust
   set tag             (13, off)
   #Add graphics in, you lazy person
   wait                (1)
   teleport to map     (16, 1, 1)
   camera follows hero
   wait                (1)
   show map
   wait                (1)
   resume player
   resume npcs
   )
if       (check tag (14)) then (

   #Mode 7ing into White Sands
   set tag             (14, off)
   #Lazy person!
   wait                (1)
   teleport to map     (17, 1, 1)
   camera follows hero
   wait                (1)
   show map
   wait                (1)
   resume player
   resume npcs
   )
end


Where is the screw up?
Display posts from previous:
Page 1, 2  »