-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converter issue for variables/objects/rooms with spaces in their name. #102
Comments
I remember @ThePix saying there was no work-around for this quite a few times, when he was just trying to make it work for the sake of seeing if he could make it work. Quest 5 will allow spaces in object names1, so he was trying to get things to work as similarly as possible (to an extent). JavaScript simply won't allow this, though, and the code we use to create QuestJS games is pure JS. Footnotes
|
Well I guess I should look into at how Quest 5 handles that, we could probably copy their solution. |
I was completely mistaken. JavaScript will allow spaces in object names. I think Pixie maybe disallowed spaces due to things like hyper-links(?). Anyway, I commented out this one line, and it let me create an object with spaces in the name. I can type to interact with it, but the link in the menu doesn't work. function createObject(name, listOfHashes) {
if (world.isCreated && !settings.saveDisabled) return errormsg("Attempting to use createObject with `" + name + "` after set up. To ensure games save properly you should use cloneObject to create ites during play.")
//if (/\W/.test(name)) return errormsg("Attempting to use the prohibited name `" + name + "`; a name can only include letters and digits - no spaces or accented characters. Use the 'alias' attribute to give an item a name with other characters.")
if (w[name]) return errormsg("Attempting to use the name `" + name + "` when there is already an item with that name in the world.")
if (typeof listOfHashes.unshift !== 'function') return errormsg("The list of hashes for `" + name + "` is not what I was expecting. Maybe you meant to use createItem or createRoom?") Here is the code from the button: <p class="item" onclick="io.clickItem('Fred Fred Burger')">Fred Fred Burger</p> There is another object in the game with no spaces in its name, and here is its button: <p class="item" onclick="io.clickItem('Bob')">Bob</p> So, it looks like Let's find the code. Lines 1404 to 1428 in f9680fb
This bit specifically will have issues with spaces: Line 1419 in f9680fb
That would make JS look for HTML elements with the class That would create 2 classes in actuality: So, how could this be handled in a way that would work across the board for most authors? It seems the most efficient approach would be to disallow spaces in names, but allow spaces in the alias. createItem("Fred_Fred_Burger", {
loc:"lounge",
alias: "Fred Fred Burger",
synonyms:['fred'],
examine: "He looks a little nervous."
}) That works, and the one simple naming rule is: Any other solution would involve altering the name to replace the spaces with some other character to be removed again during other functions. So, if we were to replace spaces with So, I bet the ThePix foresaw all of this and just declared no spaces or accented characters. Use an |
I got lost in finding out why no spaces were allowed in QuestJS and lost track... You are talking about converting games with names with spaces. Sorry about that, haha. I was still mostly on-topic, though. I just dropped the ball at the end. I need to look at the converter's code, but I'd think it could simply change object names' spaces into But what if that overwrote an actual existing alias? This is another thing I bet ThePix already pondered, and that's why the converter isn't considered fully functional. Hmm... I don't know... I guess it could:
|
Yeah that was what I was thinking. I might take a crack at it tbh. But I've never contributed to OSS before so idk how hard it's going to be. |
I have to admit I wrote this first-and-foremost for my own benefit, and I never gave Quest objects names with spaces, but to a coder it just looks wrong. So not allow names with spaces was not a problem. "But what if that overwrote an actual existing alias?" I would suggest a check at the end of the process, and if there are two objects with the same name, just give a warning. It will be hassle for the user to sort out, but not that much, and it will be exceptional cases. |
I think we should add a link in the converter page to the wiki page on the converter, it talks about things like this so it would probably clear up a lot of confusion. |
Now this is basically entirely my fault for daring to use spaces in my variable/object names, but the current converter doesn't work with these sorts of variables.
The text was updated successfully, but these errors were encountered: