Jump to content

How do I script random changes to a cell?


chaospearl

Recommended Posts

Edited for length, clarity, and because I change my mind every twenty minutes.

 

As the title says. I'm just getting into scripting (read: I have no idea what I'm doing). The only programming I've done aside from HTML and CSS -- which don't really count -- was in a proprietary language for a MMORPG company. When I was learning that language I found that I tend to learn best by looking at examples of how something works.

 

So... what I'm looking for is an example of a cell with objects that change randomly depending on circumstances. I'm making an art gallery and I want the paintings to change every week.

 

Let's say that there will always be 10 paintings hanging and they'll always be in the same place on the walls. I'm trying to set it up so that 10 different paintings hang each week; the gallery closes on Sundas and the next day, a new set of paintings is there for the week.

 

I can't think of anything in the game that does something similar so I can look at the scripting. Anyone have suggestions? It doesn't need to be exactly the same; I just need a general idea of what the code looks like and I can modify and polish from there to suit my exact requirements. If I could see a code snippet for something in the game that changes which item appears depending on predefined circumstances, and a snippet for something that's random, anything at all that ISN'T a leveled list... that would be a huge help.

 

Edit: After several hours of poking through the CS Wiki, it seems that the best (only?) way to accomplish this is by putting all the paintings into the cell to begin with, stacked on top of one another, and set to initially disabled. Then enable a different set of paintings with each reset. Now the problem is how to accomplish the resets so that they happen once a week on a particular day, but only once.

Edited by chaospearl
Link to comment
Share on other sites

Thats a tall order.

 

you would need a variable to controll each painting

 

if haywain == 0 && getdayofweek == 1 ; 1 is monday

HayWainRef.enable

set haywain to 1

endif

 

if haywain == 1 && getdayofweek == 2 ; 2 is tuesday

HayWainRef.disable

set haywain to 2 ( or 0 if you want it back next week )

endif

 

you would need to do this for each painting, here's the numeric value for each day for you.

 

sun = 0

mon = 1

tue = 2

wed = 3

thur = 4

fri = 5

sat = 6

 

hope that helps.

Link to comment
Share on other sites

Very helpful, thank you. I didn't realize I could get the script to recognize the day of the week, heh. I looked at the list of global variables (which there are for the day of the month, the year, even the hour, but not the day of the week) but for some reason didn't think to check if there was a function for it. I just assumed there wouldn't be since there was no global. D'oh.

 

Edit: Is there a reason I can't just daisy-chain each set of paintings to a parent ref and then enable\disable the parents instead of doing it individually for each painting?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...