ID:2969727
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Seeking a way to get the last value from a /generator that was obtained by
generator_instance.Rand()


This would be helpful to do things with that value, in case you're in a context where you can't assign variables (like already being in a variable assignment).

This also might be handy for certain methods of a generator being shared between different functions in series.

I know this is a bit strange of a suggestion, but I encountered it.

Maybe something like

generator_instance.last_value
This might help. Extends native generators. see var/_last
It'll be a bit buggy with values that aren't numbers, but generators will only return one of: number, vector2, vector3, text (colour) or list (colour matrix).
generator
var/_type // the generator type
var/_a // extreme a
var/_b // extreme b
var/_upper // the upper extreme
var/_lower // the lower extreme
var/_rand // the rand type
var/_highest // the highest value generated
var/_lowest // the lowest value generated
var/_last // the last value generated

New(t, a, b, r)
.=..(t,a,b,r)
_type = t
_rand = r
_a = a
_b = b
if(a > b)
_upper = a
_lower = b
else
_upper = b
_lower = a

if(_type != "color")
_highest = (_upper + _lower) / 2
_lowest = _highest

Rand()
.=..()
if(isnum(.))
_highest = max(., _highest)
_lowest = min(., _lowest)
_last = .

Login to reply.