player.parent

I am trying to create a function that will print every time the screen clears a room description for each room , according to specific room attributes which vary from room to room.

Can I not just use if (player.parent.attribute = ) {
msg("")
}
? I need it to change according to the room it's in.

Or do I have to write a room description script for each specific room? And then I would put msg (+player.parent.description+) into the timer? Or do I need to add the word room somewhere in that,? Or is that not even close? Is there a way to do it?


I don't really understand what you're asking here.

player.parent.description is valid; but unless your game is very simple, be aware that a room's description could be a string, a script, or null. Assuming that it's always a string (for example) may lead to some intractable problems later in development.

As an aside, it's better to refer to the player as game.pov in your code, rather than player. Just a good habit to get into.

If you're just trying to display the room description, it might be simpler to use the function:

ShowRoomDescription()

I am trying to run a script of some kind like this
If (game.pov.somesttribute = 1) {
msg ("We are in the woods')
If (game.pov.someother attribute = 4) {
msg ("There is a path here with flowers beside it")
}
}
I have it in a function and want it to check every room1 , room 2, room3 etc., for room1.someattribute and room1.someotherattribute or room2.someattribute and room2.someotherattribute, depending on which room the player is in when the timer goes off.
The timer will clear screen and update things like the clock and the room object list, and should reprint the room description.
I can do it one room at a time and have the funct8on call 25 other functions, one per room, and have it work, but I really just want one function that will treat each room the same when the player is in it, read that room for its attributes, and displaying the corresponding messages that all together make up the room description.

A randomizer system that generates simple rooms that are not all the same every time.


It is already working, at least to generate the attributes, with "player.parent" (* about a thousand). Should I paste game.pov over every iteration of player.patent? I will if it will affect gameplay or something.
I just don't want more work badly.
I think I would leave it to the end, make it the last thing, or second to last, that I do, if there is enough reason to not not.


You can replace player.parent with game.pov.parent - or leave it if the code is already written. Using game.pov to refer to the player is a good habit to get into, but probably not worth changing a lot of code that's already written.

As far as displaying the room description, you can just call the function ShowRoomDescription - the same one that the core code uses to display the description when the player moves to a new room.


I am still trying to find a code that will read the room's integer type attributes and display the messages I assign to each.


The function I have already set up isn't doing anything. It doesn't seem to know what player.parent.someattribute means. The script that assigned the attribute integers in the first place used player.parent as soon as I realized that would work. Before that, I was replacing player.parent with the room names, but it worked both ways.
I can put a script anywhere to ask for a specific rooms attributes, but it would be a lot to add to the timer if player is in room1 run function Room1Function, not that I would call it that, times 25.


I will just make 25 functions plus the one to direct the game to a specific function for each room, for now. That may be all I can do, and at least I think that will work well enough.
Or not.
I have them working. I couldn't figure out how to use a single function. I think it's probably got more string than it should, but it is nice it works at all.
I will soon be adding that other script. At least one of my scripts will save memory. ;)


It doesn't seem to know what player.parent.someattribute means.

It really should work (as long as player is the correct name of the player).

If it isn't working, could you show us the game? It's very hard to figure out the problem without seeing the actual code in context.


These are one of the twentyfive functions plus one, that I did not believe I could make the game without, because the script to call the function I had corrected to game.pov.parent from player.parent, which I believed was under my homemade clock and after clear the screen, because I swear that is where I put it, was actually up above both those scripts. Dont ask me how I made that mistake. I am still in awe of it.

The first twentyfive are all almost exactly the same. So you really can just skip them.
  
  
This is the function that I finally replaced all those functions with and tested once, just now, and it works fine.
  


My den of twenty seven vipers is empty. Where have they all gone?


Log in to post a reply.

Support

Forums