Page 1 of 1
Random Colour code
Posted: Mon Aug 29, 2016 8:51 am
by Jarngron
While making 'a piece of saltwater taffy' I had the idea of using a single random colour code for 'taffy' to help describe the many colors that all tasted the same.
When I checked, I didn't see any functions to do this. Used sparingly this can be fun, used too much it's an eyesore - but I could say the same of colour codes in general.
Can anyone else think of fun ways to use a random colour code?
Re: Random Colour code
Posted: Mon Aug 29, 2016 10:05 am
by Larethiel
Are You looking at using a rand_prog or just General ideas?
Re: Random Colour code
Posted: Mon Aug 29, 2016 1:06 pm
by Harroghty
There are several candy objects in the game which are styled as bags of candy, and a PC can use a command (e.g. get taffy bag) to produce a finite number of edible pieces (the total count can be governed, if desired, by value5). In this case, one could include an if rand check in the intercept program to vary colors.
Code: Select all
>intercept_prog get~
if stringprefix($2) == bag
if stringprefix($1) == taffy
if objval5($o) > 1
mpoload 1234
if rand(50)
mposet i1234 short {90}a piece of taffy
else
mposet i1234 short {A0}a piece of taffy
endif
mpgive i1234 $n
mpoadd on $n $o value5 -1
else
mpechoat $n {90}The bag is empty.
endif
else
mpunintercept
endif
else
mpunintercept
endif
~
|
Alternatively, you could junk the bag on the last candy by adding a little check at the end.
Code: Select all
if objval5($o) == 1
mpechoat $n You finish a bag of candy.
mpechoaround $n @N finishes a bag of candy.
mpjunk $o
endif
Re: Random Colour code
Posted: Mon Aug 29, 2016 6:45 pm
by Jarngron
I really like the way you think, Harroghty. Thank you very much for the assist.
Well Larathiel, I was just thinking I could use a regular ansi colour code that would randomly return a color, that the average end user could also potentially use - and I don't know if that -is- the best idea given how gaudy those random colors can look in many cases. Either way, this will suit me just fine, I planned on having players pull a piece from a box with an intercept to cut down on unnecessary nesting.
Re: Random Colour code
Posted: Tue Oct 04, 2016 12:46 pm
by Aysa
I am not a programmer. I try to avoid programming at all costs; however, if you are worried about gawdy colors in your randomized programming... could you not just run the randomizer, assigned the result to a value.
If value < 20 ... then color is super cool looking blue color
If 21 < value < 40 ... then color is super cool looking red color
... and so on.
Again, I might be barking up the wrong tree or might be creating needless routines just so someone can randomly pull a butterscotch flavored candy one time and then a cinnamon flavored candy the next.
Do not mind me. I will go back to OCDing on color schemes in my outfits.
Re: Random Colour code
Posted: Tue Oct 04, 2016 2:23 pm
by Areia
Aysa wrote: ... could you not just run the randomizer, assigned the result to a value.
If value < 20 ... then color is super cool looking blue color
If 21 < value < 40 ... then color is super cool looking red color
... and so on.
Assuming I read and understand your idea correctly, that is essentially what Harroghty proposed above, just in simpler terms (because coding out even the simplest problems in most any scripting or programming language just has to look waaaayyy more complicated than necessary
. The largest difference being that your example stores a random value in a variable and then makes various if-checks on that variable, whereas Harroghty's is pretty much just cutting out the variable middle man (area code cannot make use of variables). But yeah, both would end up with the same effect.