ID:1295014
 
(See the best response by Pirion.)
Code:
mob
verb
OpenCode(Code as file)
if(findtextEx("[Code]",".dm")==0)
alert(src,"You did not load a Code file.")
return

usr.CodeFile = "[Code]"
var/Z = "[html_encode(file2text(Code))]" //open it
winset(usr,"default.Codes","text='[Z]'") // THIS IS AN INPUT
src.UpdateBrowser()


Problem description:
In Make My Dream, the manual code editor is an input and everything is fine with it but it seems when i load a code file,and use html_encode to have it keep the same format as dm, it doesn't apply to my interface input. Any reason why it only works on browsers and not on inputs? Is this a bug?
Best response
The HTML follows web standards. I think in order to get the proper escaping (without doing it yourself) would be to put in a list and use list2params() to convert it.

mob
verb
OpenCode(Code as file)
if(findtextEx("[Code]",".dm")==0)
alert(src,"You did not load a Code file.")
return

usr.CodeFile = "[Code]"
var/Z = "[html_encode(file2text(Code))]" //open it
var/list/l = list("text" = file2text(Code))
winset(usr,"default.Codes",list2params(l)) // THIS IS AN INPUT
src.UpdateBrowser()


Would you give that a try, and let me know if it displays correctly?
Again...You're my hero!! =D

It worked! Well, I learned something new today. Thanks again!!! You deserve 2 stars, not 1! xD
Hmmm, I'm stuck with another problem...
Sorry if this is very noobish I, rarely used list2params.

            MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params)
if(over_control == "default.browser1")//Check if its being DROPPED over the browser
if(usr.CodeFile == "") return
var/list/SAVER = list("text" = winget(usr,"default.Codes","text"))
var/Z = file2text('Actions/Create_Turf.txt')
var/list/l = list("text" = file2text(Z))
winset(usr,"default.Codes","text='[addtext(list2params(SAVER),"\n","[list2params(l)]")]'")
usr.UpdateBrowser()


Basically when drag and dropping an action , it should copy the current text in the input and add more to it. This is what I get o.o:

text=var%2fFiles+%3d+list%28%0d%0a1+%3d+%27.%2fScripts%2fSkin.dmf%27%2c%0d%0a2+%3d+%27.%2fScripts%2fSkin.dmf%27%2c%0d%0a%29%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a%0d%0a
text
You want to use params2list to remove the encoding, update the list value, and then move it back to list2params.
Am i doing it wrong? It's still not working.
            MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params)
if(over_control == "default.browser1")//Check if its being DROPPED over the browser.
if(usr.CodeFile == "") return
var/list/OLD = params2list(winget(usr,"default.Codes","text"))
var/NEW = file2text('Actions/Create_Turf.txt')
var/list/l = list("text" = file2text(NEW))
winset(usr,"default.Codes","text='[addtext(list2params(OLD),"\n","[list2params(l)]")]'")
usr.UpdateBrowser()
I'm kind of confused why you're using params2list on that winget call. Since you only have one parameter to get, it will only return the text. One string.
If you just want to add the contents of create_turf.txt to the existing text, you probably just need to do this:

MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params)
if(over_control == "default.browser1")
if(!usr.CodeFile) return
var/OLD = winget(usr,"default.Codes","text")
var/NEW = file2text('Actions/Create_Turf.txt')

winset(usr,"default.Codes","text=[OLD]+\n+[NEW]")
usr.UpdateBrowser()


Alternatively, you could do this, to avoid winset shit:
    var/OLD = winget(usr,"largeinput","text")
var/NEW = file2text('1.txt')
usr << output("[OLD] \n[NEW]", "largeinput")


(in this example, I just used what I tested with, it works. freel free to replace your vars and whatever)
Because what I'm loading are dm files.
They aren't appearing correctly, they need to be encoded.
no.
they don't.
dm files are 100% text files.
Well, for some reasons this wasn't working with winset.
It does work with output though.
Thank you SSX.
I'd suggest changing your other code (from the first post) to use output() as well.

It's much simpler, and you don't have to deal with winset's quirkiness when it comes to large strings accidentally being parsed as parameters. (which I'm assuming is why Pirion suggest the param/text method).