Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (degenerate_762, AndrewAMD), 877 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
random skin not working #450697
04/20/15 23:04
04/20/15 23:04
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Why doesn't this work?

Code:
random_seed(0);
value = integer(random(6));
my.skin += value;



I read what I could in the manual about this particular 'thing' and came up with nothing more than more confusion as to why this doesnt work........


Last edited by DLively; 04/20/15 23:04.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: random skin not working [Re: DLively] #450698
04/20/15 23:36
04/20/15 23:36
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
just off the top of my head,
I think
Code:
value = integer(random(6));


should be
Code:
var value = integer(random(6));


unless you already defined value earlier.

Re: random skin not working [Re: DLively] #450699
04/20/15 23:37
04/20/15 23:37

M
Malice
Unregistered
Malice
Unregistered
M



try

Code:
random_seed(0);
value = integer(random(6)+1);
my.skin += value;


Re: random skin not working [Re: ] #450700
04/20/15 23:56
04/20/15 23:56
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Sorry I was a bit vague.

This action is used on 50+ models.
If I remove the random_seed(0); I get the same result each time (their skins will randomize, but always be the same random value [as the manual says it would]).

with the random_seed(0) all skins stay the same color.


@xbox: yes, its been defined wink

@malice: I tried your idea, but it didnt work smirk

I've done this before in the past and it worked fine. Strange how such a thing can happen..


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: random skin not working [Re: DLively] #450701
04/20/15 23:59
04/20/15 23:59

M
Malice
Unregistered
Malice
Unregistered
M



How about running random_seed(0) once in the main function fallowed by a wait and remove it here

Also debug_var the value of "value" lol

also debug skin to see if it chages or exceeds the number of skins
i=my.skin;
debug_var(i);

http://www.conitec.net/beta/macros.htm

Last edited by Malice; 04/21/15 00:21.
Re: random skin not working [Re: ] #450703
04/21/15 01:36
04/21/15 01:36
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
I put the random_seed in the main function... but I think the issue was because they were created and built with WED. I created some more models at runtime and their skins changed randomly..


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: random skin not working [Re: DLively] #450713
04/21/15 05:52
04/21/15 05:52
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Just do this:
Code:
var rndSkin = 0;
rndSkin = integer(random(6));
my.skin = rndSkin + 1;

Also note that random(6) will create value between 0-5, so thats why I add 1 to the skin at th end. I'm not sure about using 'random_seed' over and over again, it works great for me if I add it once in the main function.

greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: random skin not working [Re: 3run] #450721
04/21/15 10:29
04/21/15 10:29
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Random number generators always follow the same pattern, which means that when the last generated value is known you can always predict the next one, it's a machine after all.
Let's say you have such a function
int random_base(int seed);
which outputs a value between 0 and 65000, then your default random(var range) will be calculated somewhat as follows if I'm not mistaken:
Code:
var random(var range)
{
  var value;

  seed = random_base(seed);
  value = seed/65000.0*range;

  return value;
}


where seed is some global integer. You can change the seed number by calling random_seed(int num), and when you call the latter with num = 0, I assume the computer will take some additional information like the system's time (at game start) or something like that.
If you call random_seed() over and over you mess with the random(_base) pattern and in the worst case just get the same number over and over.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1