Sorry, it's my fault to write a small typo in the "getlocalvar" command, like the log says.OpenBorLog.7z
drive.google.com
I applied the script, but the game crashes.
spawn Shermie-L1
@script
void main()
{
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(getlocalvar("self"), "map", palette); //APPLY THE PALETTE
}
@end_script
coords -20 174
at 400
You can use the following script during the spawn.C:spawn Lynn-L1 map 1 coords -320 190 at 0
This is part of the stage setup.
I would like to have the palette applied randomly when the character spawns.
There are 10 colors.
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(self, "map", palette); //APPLY THE PALETTE
You can use the following script during the spawn.
C:int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9 if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE changeentityproperty(self, "map", palette); //APPLY THE PALETTE
spawn Shermie-L1
map
@script
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(self, "map", palette); //APPLY THE PALETTE
@end_script
coords -20 174
at 400
In case you are adding directly in the level file, try this way.C:spawn Shermie-L1 map @script int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9 if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE changeentityproperty(self, "map", palette); //APPLY THE PALETTE @end_script coords -20 174 at 400
Can I apply the script like this?
spawn Shermie-L1
@script
void main()
{
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(getlovalvar("self"), "map", palette); //APPLY THE PALETTE
}
@end_script
coords -20 174
at 400
In case you are adding directly in the level file, try this way.
C:spawn Shermie-L1 @script void main() { int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9 if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE changeentityproperty(getlovalvar("self"), "map", palette); //APPLY THE PALETTE } @end_script coords -20 174 at 400
Sorry, it's my fault to write a small typo in the "getlocalvar" command, like the log says.OpenBorLog.7z
drive.google.com
I applied the script, but the game crashes.
spawn Shermie-L1
@script
void main()
{
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(getlocalvar("self"), "map", palette); //APPLY THE PALETTE
}
@end_script
coords -20 174
at 400
Sorry, it's my fault to write a small typo in the "getlocalvar" command, like the log says.
C:spawn Shermie-L1 @script void main() { int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9 if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE changeentityproperty(getlocalvar("self"), "map", palette); //APPLY THE PALETTE } @end_script coords -20 174 at 400
void main()
{
int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9
if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE
changeentityproperty(getlocalvar("self"), "map", palette); //APPLY THE PALETTE
}
spawn Shermie-L1
spawnscript data/scripts/randpal.c
coords -20 174
at 400
Thank you. The script has been organized nicely.Nice. If you don't want your script tags to be redundant with the same scripts, you can use spawnscript for spawning entities in levels. I just renamed this spawnscript file into "randpal.c" for avoiding script redundancy. But for spawning specifics, I use script tags without depending on spawnscript line.
randpal.c:
C:void main() { int palette = (rand()%10); //RANDOM NUMBER FROM 9 TO -9, NOTE THAT 10 MEANS 0 TO 9 if(palette < 0){palette = palette*(-1);} //CONVERT ALL NEGATIVE NUMBERS TO POSITIVE changeentityproperty(getlocalvar("self"), "map", palette); //APPLY THE PALETTE }
Example:
Code:spawn Shermie-L1 spawnscript data/scripts/randpal.c coords -20 174 at 400