dMZX Forums: Can't write to board/overlay/vlayer - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Can't write to board/overlay/vlayer

#1 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 13 January 2013 - 05:11 PM

I've been trying to figure out how to input a string and then print it to the vlayer for use in an options panel. I thought this might work:

% "~eChange controller type"

? "keyboard" "Keyboard"
? "xbox" "Xbox 360 controller"
? "custom" "Other game controller"
goto "waitforit"

: "custom"
input string "Name of controller"
set "$controller#20" to "input"
loop start
set "vch&('loopcount'+5)&,22" to "$controller.&loopcount&"
set "vco&('loopcount'+5)&,22" to 23
loop for 19
goto "waitforit"

I had hoped it would allow me to input a controller name then it would place that name in a section of the vlayer. But It doesn't work for a couple of reasons. First, I can't substitute the X coordinate in 'VCHx,y' with an expression. I can substitute it with a counter like loopcount inside of ampersands, &loopcount&. But when I try to make an expression, it comes out 0. Second, the second value (that VCHx,y is set to) has to be a number corresponding to the char set. counters evidently don't work here. It has to be '175' or something like that.

Am I making a rookie mistake? Am I missing something? Is there a way to print a player inputted string to the physical game board, overlay, or vlayer like i'm trying to do? Please help.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

#2 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,936
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 13 January 2013 - 05:48 PM

You want this:
set "vch('loopcount'+5),22" to "$controller.&loopcount&"
set "vco('loopcount'+5),22" to 23


Using ampersands AND parentheses results in two sets of interpolation, so it ends up working like this:

(let's say 'loopcount' is 0)
set "vch&('loopcount'+5)&,22" to "$controller.&loopcount&"

set "vch&(0+5)&,22" to "$controller.0"

set "vch&5&,22" to "$controller.0"

You can see the problem in the last line: it reads from the counter "5", which is probably 0 (because it's undefined)
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
1

#3 User is offline   Wervyn 

  • I can see you
  • Group: DigiStaff
  • Posts: 1,855
  • Joined: 24-December 00
  • Gender:Male
  • Location:Caras Galadhon

Posted 13 January 2013 - 05:50 PM

This looks like a simple rookie mistake, you're mixing ampersand interpolation and expressions together in a way that's giving you unexpected results. Basically, when you're doing "vch&('loopcount'+5)&", you're doing two nested interpolations. The ampersands are unnecessary here, you can embed an expression into a counter name just fine using parentheses by themselves. What this does instead, is first resolve ('loopcount'+5), which comes out to some number (say 10), and then try to resolve &10&, looking for a counter literally named "10", which probably doesn't exist. So you get 0, because MZX error handling is all but non-existent. This is one of the most common bugs in MZX coding, and it can be devilish hard to catch: when your expression is malformed (mismatched parens, too much nesting), you just get bad counter reference that resolves to a silent 0.

As for the right-hand value, what you're doing there should work just fine. You're correct that as far as vchX,Y goes, you're setting a byte that references the character set. But that's also what you should be getting out of the string.

Of course, the easiest way to get your string in might be to just write the overlay directly: "write overlay c0f "&INPUT&" X Y". Then you can copy that to the vlayer if you want, and avoid processing the string by hand.

"Wait, I should be judging."
To lie is to change the truth.
..Ignorance is to be unaware of the truth.
....Incompetence is to be unable to grasp the truth.
......And escape is to run away from the truth.
It is useless to run, since the truth is right next to you.

-Wervyn
1

#4 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 13 January 2013 - 10:10 PM

Ahh! Thanks guys! Big help. I should be able to get this program working like I wanted now. Thanks a lot.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users