FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Assigning array elements

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Fri Aug 26, 2011 4:25 am    Post subject: Assigning array elements Reply with quote

Arrays are one programming construct that I never understood very well in either Hugo or Inform. Right now, I'm trying to make two scenery objects with blank noun and adjective properties, and then to assign dictionary words at a point in the game so that the player will be able to refer to these objects at the right time but not before. I can't simply move the objects to the location when I need them, because they both span two or more rooms, using the found_in property. So, I leave them alone but don't mention them or give them any keywords until I'm ready to set them up.

I saved the lists of keywords that I want to end up as nouns/adjectives for the objects into four arrays -- one for each object's noun and adjective properties. I tried making the noun and adjective properties routines that would return the arrays if the right condition was met or would return false otherwise. Then I tried leaving the noun and adjective properties completely empty (nothing but a new line after the word "noun" in the code) and assigning their values to the arrays in a different routine somewhere.

Looking to the Hugo Book, I saw where it says that "entire arrays passed as arguments" are illegal. Then, I tried setting each keyword one at a time in the routine that makes the changes to the game state when the two scenery objects become available to the player. I left blank "slots" in the noun/adjective property definitions, like this:
Code:
noun 0, 0, 0, 0

Then I tried setting them with something like this:
Code:
object.noun[0] = "sky": object.noun[1] = "sun": object.noun[2] = "clouds"

That still didn't work. It doesn't even give any different results at all then my previous attempts did.

Thank you, and sorry for being so long-winded. I'm being a little ambiguous about the content of my project because I'm holding out for a slim hope of entering it in the IF Comp if I get done in time.
Back to top
View user's profile Send private message
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Sun Aug 28, 2011 4:12 am    Post subject: Reply with quote

Yeah, no, you're getting properties confused with arrays (which is understandable since they are kind of similar looking and there are problems you could solve using either approach).

First off, read this: http://hugo.gerynarsabode.org/index.php?title=Properties#Defining_your_own_properties

Basically, the syntax you'll be wanting to use is:
Code:

object.noun #1 = "sky": object.noun #2 = "sun"
object.noun #3 = "clouds"


Sorry for the delay on this. I have been moving my files over to a new computer the last couple days.
Back to top
View user's profile Send private message AIM Address
Bainespal



Joined: 09 Jul 2010
Posts: 151

PostPosted: Sun Aug 28, 2011 4:54 pm    Post subject: Reply with quote

I never questioned my assumption that the noun property contained an array as its value. I think I just understood arrays as far as being lists of values. Or maybe I was remembering Inform 6 -- I vaguely remember seeing examples in the Inform Designer's Manual about manipulating object keywords as array entries, I think.

Anyways, it works now -- which is totally awesome! By the way, that HxE article is very informative; properties in Hugo are more flexible than I thought they were. It turns out this was all simpler than I'd imagined. :)

Roody_Yogurt wrote:
Sorry for the delay on this. I have been moving my files over to a new computer the last couple days.

No, I'm sorry for bothering you again. You really don't have to help me, you know, but I appreciate it. Anyways, I still have a little more of the initial implementation to do; I knocked off another NPC in the meantime.
Back to top
View user's profile Send private message
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Sun Aug 28, 2011 5:16 pm    Post subject: Reply with quote

Yeah, properties are pretty flexible. It is interesting to look at other people's code to see how they like to handle things. ICJ handles a lof of his problems with arrays while Kent Tessman does a lot of stuff with properties resulting in weirdly-specific property-manipulating routines like PropertyList that I doubt anyone else has yet used (although I'm still trying to think of situations where I'd need it).

Both ways show that you can often write a routine to sort and deal with your property or array however you like.

Anyhow, no worries about the trouble. It is good to know that other people are working on Hugo code, and I am happy to help out, especially as you try to meet the comp deadline.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended