plug object in / plug in object

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

plug object in / plug in object

Post by Tdarcos »

NB: for the purposes of this article objects are entered in UPPER CASE even though the user doesn't have to type it that way.

Here's the problem. I want the user to be able to say "plug TV in" or "plug in TV" as well as the other responses.

Code: Select all

verb "plug","unplug","plugin","connect"
	*										DoVague

verb "plugin"
	* object								DoPlug
	
verb "plug","connect"	
	* object "in"							DoPlug
	* "in" object 							DoPlug
	* object "into"/"in" anything			DoPlug
	* object								DoPlug
plug in TV works, plug TV in socket also works (socket is the appropriate object and is there strictly for syntactic sugar.)

plug TV in returns Cannot plug anything into in

moving object "into"/"in" before object "in" in this list of responses does not change the result.

Ordering of verb commands? change in method?
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

loafingcoyote
Posts: 89
Joined: Wed Jan 04, 2012 2:57 pm
Location: Texas

Post by loafingcoyote »

It looks like Hugo is trying to use "in" as the xobject. Replacing PreParse can be very helpful when grammar can't be defined normally.

Code: Select all

replace PreParse
{
	if word[1] = "plug" and word[3] = "in"
	{
		local wordtwo

		wordtwo = word[2]

		word[2] = word[3]
		word[3] = wordtwo
	}
}
Here you're just switching the order of the second and third word when the above conditions apply. Then the parser takes over again and runs it as "plug in TV", as opposed to "plug TV in".

This solution works and I don't think it should cause any problems.

-lc

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

loafingcoyote wrote:

Code: Select all

replace PreParse
This solution works and I don't think it should cause any problems.
Bzzzzzt! Causes an excrement-load of errors. (Or for the PG version, it causes a shitload of errors). I put the replace routine in my tripkey.h file and the following happens.

\\buffalo\programming\zenith\tripkey\tripkey.h:536: Error: Syntax error: preparse
\\buffalo\programming\zenith\tripkey\tripkey.h:536: Error: Not an object or routine: preparse
\\buffalo\programming\zenith\tripkey\tripkey.h:537: Error: Unknown compiler directive: {
\\buffalo\programming\zenith\tripkey\tripkey.h:538: Error: Unknown compiler directive: if
\\buffalo\programming\zenith\tripkey\tripkey.h:539: Error: Unknown compiler directive: {
\\buffalo\programming\zenith\tripkey\tripkey.h:540: Error: Unknown compiler directive: local
\\buffalo\programming\zenith\tripkey\tripkey.h:542: Error: Unknown compiler directive: wordtwo
\\buffalo\programming\zenith\tripkey\tripkey.h:544: Error: Unknown compiler directive: word
\\buffalo\programming\zenith\tripkey\tripkey.h:545: Error: Unknown compiler directive: word
\\buffalo\programming\zenith\tripkey\tripkey.h:546: Error: Unknown compiler directive: }
\\buffalo\programming\zenith\tripkey\tripkey.h:547: Error: Unknown compiler directive: }

If I use "routine" instead of "replace" I get an error message that it's already defined. I think that Hugo has a problem with the "replace" directive, I've not been able to get it to work. I'm going to try something else to solve this.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Aw shit! I'm the one who's rejecting it!

The message is coming from the DoPlug routine. You're right, it's treating in as the xobject. So all I have to do is find out which one it is and include it as valid.

But it's funny I can't use "replace".
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Roody_Yogurt
Posts: 2179
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

Since you used the anything token, the xobject can be any known object in the game (not just within the player's scope). I'd look for objects with "in" used as a noun or adjective.

Turning HugoFix on and turning on parser monitoring should also show you what object is being passed onto the routine.

Also, replacing PreParse shouldn't have caused all those errors. Possibly you typo'd 'replace'?

loafingcoyote
Posts: 89
Joined: Wed Jan 04, 2012 2:57 pm
Location: Texas

Post by loafingcoyote »

Tdarcos wrote:But it's funny I can't use "replace".
Not being able to use "replace" with Hugo would be a real problem. Here's a thought. As an experiment, I tried including the replace preparse code before hugolib.h and got the exact error messages that you got above. I don't know if that's the solution, but it's an idea.

User avatar
Tdarcos
Posts: 9333
Joined: Fri May 16, 2008 9:25 am
Location: Arlington, Virginia
Contact:

Post by Tdarcos »

Roody_Yogurt wrote:Also, replacing PreParse shouldn't have caused all those errors. Possibly you typo'd 'replace'?
Not unless you did. I took your code and pasted it verbatim. I think the problem is that where it's located it's before hugolib.h, so it can't replace what isn't there yet, and it can't be a routine because then hugolib is trying to define a routine of the same name as something else.

Probably needs to be placed in a file after hugolib to get replace to work.

In any case, this does give me an understanding why it wasn't working. And I was able to avoid having to replace, at least this time. I'd like to be able to say that I got my entire program to work without having to change the system routines at all. I may not be able to get that level of perfection, but I can try.

I think I'll create a file called "patch" that is at the end of the includes, and can be used if I have to replace anything, so that it's always last.
Alan Francis wrote a book containing everything men understand about women. It consisted of 100 blank pages.

Post Reply