I'm trying to make a scripting language and interpreter for MZX (don't ask why, it's a strange story involving being inspired by something by asiekierka), but one of the commands, one that's supposed to move a robot, doesn't work for some reason.
When the interpreter is run it is supposed to write
"This is a NihilScript file test.
This is coloured text (in red)
This is another colour of text (in blue)
Script executed"
move a robot named "1" to 55 15, call it "test" and then move it north 10 steps. (In order to test the functions in the scripting language)
Using good old messagedom I've managed to trace the problem to a breakdown of communications between the interpreter robot and the mover robot. However, I can't see any obvious reason why.
Here's the contents of the script, the interpreter and the robot:
SCRIPT -------- #SPEAK* This is a NihilScript file test.* #SPEAKCOL* RED* This is coloured text.* #SPEAKCOL* BLUE* This is another colour of text.* #INSTROBOT* test* 1* 55* 15* #MOVEROBOT* test* 1* 10* -------- INTERPRETER -------- write overlay c0f "NihilistScript interpreter 0.1" at 0 0 set "$name" to "test.txt" write overlay c0f "Loading &$name&" at 0 1 set "&$name&" to "FREAD_OPEN" set "pos" to 3 : "loop" set "$read" to "FREAD" if "$read" = "" then "end" if "$read" = "#SPEAK" then "speak" if "$read" = "#SPEAKCOL" then "speakcol" if "$read" = "#INSTROBOT" then "instrobot" if "$read" = "#MOVEROBOT" then "moverobot" inc "fread_pos" by 2 goto "loop" : "speak" inc "FREAD_POS" by 2 set "$read" to "FREAD" write overlay c0f "&$read&" at 0 "pos" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "speakcol" inc "FREAD_POS" by 2 set "$read" to "FREAD" goto "&$read&" goto "loop" : "rem" inc "FREAD_POS" by 2 set "$read" to "FREAD" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "RED" inc "FREAD_POS" by 2 set "$read" to "FREAD" write overlay c0c "&$read&" at 0 "pos" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "BLUE" inc "FREAD_POS" by 2 set "$read" to "FREAD" write overlay c09 "&$read&" at 0 "pos" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "GREEN" inc "FREAD_POS" by 2 set "$read" to "FREAD" write overlay c0a "&$read&" at 0 "pos" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "YELLOW" inc "FREAD_POS" by 2 set "$read" to "FREAD" write overlay c0e "&$read&" at 0 "pos" inc "FREAD_POS" by 2 inc "pos" by 1 goto "loop" : "instrobot" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "$robotname" to "$read" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "robotid" to "$read" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "robotx" to "$read" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "roboty" to "$read" send "&robotid&" to "jump" inc "FREAD_POS" by 2 goto "loop" : "moverobot" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "$robotname" to "$read" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "dir" to "$read" inc "FREAD_POS" by 2 set "$read" to "FREAD" set "amount" to "$read" inc "FREAD_POS" by 2 send "&$robotname&" to "move" goto "loop" : "end" inc "pos" by 1 write overlay c0f "Script executed" at 0 "pos" -------- ROBOT (name is "1") -------- end : "jump" . "@&$robotname&" gotoxy "robotx" "roboty" end : "move" * "moving" <---- NOTE: when I test the game this message doesn't appear, which is why I believe it to be an error in the communications goto "&dir&" end : "1" go NORTH for "amount" end : "2" go EAST for "amount" end : "3" go SOUTH for "amount" end : "4" go WEST for "amount" end : "die" die
(In the script, the #MOVEROBOT and everything below it is the part that isn't working. It's supposed to move a robot created with #INSTROBOT called "test" north 10 steps)
This post has been edited by NihilistMatt: 12 November 2006 - 06:39 PM

Help






