ID:265029
 
Code:
//if kKey is = (equals)
addMacro(kKey as text, runProc as command_text, repeat, release, shift, alt, ctrl)
kKey += "+"
if(repeat) kKey += "REP+"
if(release) kKey += "UP+"
if(shift) kKey += "SHIFT+"
if(alt) kKey += "ALT+"
if(ctrl) kKey += "CTRL+"
winset(src,kKey,{"parent="Game";name=[kKey];command="[escape_text(runProc)]""})


Problem description:
Whenever the commented variable is set to the = symbol, it doesn't work. @_@
How do I get around this?


"text=\"[z]\""


Or
"text='[z]'"
In response to Nadrew (#1)
Using single quotes in winset() is not recommended if you are not referring to a file. The behavior will vary with certain paramaters. It's safest to always use double quotes for things that expect text.
In response to Lummox JR (#2)
I appreciate the help here, but unfortunately I had already solved the winset text= issue with the \"[value]\" method.
When I applied that, or anything else I could think of, to the addMacro() proc I had no luck.
In fact, the only difference I could make to it was stopping it from working for everything, not just =
In response to Saucepan Man (#3)
Uhh.. Are you actually using text=\"[kKey]\"? o.O
It should be name=\"[kKey]\".
In response to Jemai1 (#4)
Nah they were correcting another bit of code I had put up but have since edited away.
No one has yet discussed the code thats still there.
In response to Saucepan Man (#5)
Have you tried surrounding the [kKey] in winset with quotes?
In response to Warlord Fred (#6)
Yep, tried every combo I can think of in the winset(src,kKey,{"parent="Game";name=[kKey];command="[escape _text(runProc)]""}) line
In response to Saucepan Man (#7)
winset(src,kKey,"parent=[macroset];name=\"[kKey]\";command=\"[escape_text(runProc)]\"")

is supposed to work fine.
In response to Jemai1 (#8)
Uhhmm, no.
Your way isn't quite right. Close, though.
Here's the only way I can get it to work, for all but = key:
winset(src,kKey,{"parent=Game;name=[kKey];command=[escape_text(runProc)]"})


Here's the only way I can get it to work with the = (but nothing else).
winset(src,kKey,{"parent=Game;name=\"=\";command=[escape_text(runProc)]"})
Well, Lummox Jr. doesn't seem to know of a solution. And the thread has been here for three days with no credible reply... I'm left to conclude this is a BYOND bug.
I usually try to avoid posting there, because I'm not really qualified to discern bug from user-error.
Unless... someone can think up a solution?
In response to Saucepan Man (#10)
I assume this is a verb? Are you running it from an input control? What's the exact command you are using to run it? Are you sure the values it's receiving are what you're expecting? Are you sure the command_text argument isn't also picking up repeat/release/shift/ect?
In response to DarkCampainger (#11)
Uhhm...
I know all the variables in question are being received perfectly.
The excape_text proc is essentially redundant as far as this problem is concerned, just assume its the runProc by itself.
Which, is a cmd line string. (e.g. for a verb called "rest" it == "rest")
addMacro() is a client proc.
Here's how it goes:

* Player uses interface to set up what key and what cmd (i.e. setting up hotkeys
*they use the ACCEPT button (which is linked to a verb) to set the variables in place (key, command, repeat/release, alt,ctrl,shift)
*It's sent through a couple of procs before being called with src.client.addMacro(arguments here)


Every single one of the arguments is sent & received correctly for 100% of the way.
I've proved this by
1) it works PERFECTLY for everything except =
2) I've used world<<"" lines to output what each argument is.
In response to Saucepan Man (#9)
winset(src,kKey,"parent=Game;name=\"[kKey]\";command=\"[escape_text(runProc)]\"")

is supposed to work fine. Really. It works for = and other keys.

Edit: btw its equivalent is:
winset(src,kKey,{"parent=Game;name="[kKey]";command="[escape_text(runProc)]""})


Your first code won't work for = because it would have ...;name==;.... Quotes are important for it to treat = as text; not an assignment operator. i.e. ...;name="=";... The same applies to command.
In response to Saucepan Man (#10)
Saucepan Man wrote:
Well, Lummox Jr.

JR

doesn't seem to know of a solution. And the thread has been here for three days with no credible reply... I'm left to conclude this is a BYOND bug.

I was kind of busy have often been logged in on the test website so I didn't see your response.

The most universal solution for escaping text in winset() is to use list2params(), which will escape the character for you. Using name=%3d should do the trick I believe.
In response to Lummox JR (#14)
Ohh ._. Sorry no offence x2. Figured you didn't know about the other bit / didn't wanna clog bug posts up unnecessarily :)
Will give that a go!
In response to Jemai1 (#13)
Nope.
For some odd reason, using quotes around kKey stops this from working.
In response to Saucepan Man (#16)
As I have said earlier, it does work. I tried it myself. Mind posting your current addMacro plus the one calling it?
In response to Lummox JR (#14)
I wasn't quite sure how to utilise list2params() in this situation... So I didn't...
But using
if(kKey == "=") kKey = "%3d"
did the the trick.

If I encounter any other such frustrations, where can i go to look up what to replace it with? o_O
Is it some sort of ascii/hex/thing conversion?
In response to Jemai1 (#17)
Lummox JR solved the problem for me.
But I guess if your code works and mine doesn't, perhaps there's something fundamentally wrong with what I'm doing, and that's what's causing it...
client/proc
addMacro(kKey as text, runProc as command_text, repeat, release, shift, alt, ctrl)
if(kKey == "=") kKey = "%3d"
kKey += "+"
if(repeat) kKey += "REP+"
if(release) kKey += "UP+"
if(shift) kKey += "SHIFT+"
if(alt) kKey += "ALT+"
if(ctrl) kKey += "CTRL+"
winset(src,kKey,{"parent=Game;name=[kKey];command=[escape_text(runProc)]"})

mob/proc
onSwitch_SendBindInfo(obj/SKILL, N)
if(isnum(N)) N=num2text(N) //overkill safety check to stop me going bald over stupid stuff
src.slotCMD[N] = SKILL.cmdstring //each skill obj has a text string relating to it's verb (e.g. punch verb has cmdstring == "punch")

src.client.addMacro(src.slotKey[N], src.slotCMD[N], slotRepeat[N], slotRelease[N], slotShift[N], slotAlt[N], slotCtrl[N])
/*
N is the slot on the hotbar (1-13)
slotKey is the list of keys KEY (e.g. = button)
slotCMD is the list of cmds
...i think you get the idea
*/
Page: 1 2