Page 1 of 1

Random ODFs?

Posted: Mon Nov 20, 2006 9:55 am
by Rekubot
I'm going to be as specific as I can here, but I still don't think it's gonna come out properly. :)

Basically what I want to do is use LUA scripting (maybe it can be done with ODF editing, I don't know) to make a character have a different ODF each time. For example, I find it hard to believe that a clone trooper can carry a DC-15S blaster carbine and a big, bulky DC-15A blaster rifle at the same time. So through LUA scripting, when you select a unit class from the unit selection screen you will either get a DC-15A or a DC-15S; it's totally randomized. Hopefully that makes some sense. Whether this is possible or not I don't know, probably not. But I'm sure it can be done to a certain extent. But I thought it'd be worth asking in case any of you LUA scripters know how to do something like that. Any ideas? Thanks in advance!

RE: Random ODFs?

Posted: Mon Nov 20, 2006 1:07 pm
by [RDH]Zerted
You would need to do it through the Lua. Use OnCharacterSpawn and lookup SetProperity(). Lua uses math.random() to generate random numbers. Look up how it works in Lua's documentation online.

RE: Random ODFs?

Posted: Mon Nov 20, 2006 2:35 pm
by Rekubot
When you say 'LUA's documentation online', can I assume you mean this thing? Meh. I knew I'd have to learn LUA at some point. Guess I'll start reading the SWBFII documentations. :roll:

RE: Random ODFs?

Posted: Mon Nov 20, 2006 11:23 pm
by [RDH]Zerted
That book would work. If you want something shorter, I would recommend http://lua-users.org/wiki/MathLibraryTutorial . You mainly just need the part on math.random().

RE: Random ODFs?

Posted: Mon Nov 20, 2006 11:27 pm
by fat_walrus
How would that look in SWBFII LUA? You can only use integers if I am not mistakin.

RE: Random ODFs?

Posted: Tue Nov 21, 2006 5:12 pm
by [RDH]Zerted
math.random is used in the Holocron game mode: http://zerted.rh.rit.edu:8088/swbf2/fil ... locron.lua

There is no restriction on the type of numbers you can use.

Posted: Tue Nov 21, 2006 5:58 pm
by Ace_Azzameen_5
So, for example, you could use this Math.Random to generate a random number between 0 and 1 and then have
a variable have something like
randomword = X --X is whatever you do to make it refer the random math generated number
and then have
the Oncharacterspawn look like this:

Code: Select all

OnCharacterSpawn(
function(post)
if randomword = 1 then
SetProperty(ALL THE ODF JIBBILIE to make you get the D-15s
AND THE STUFF THAT TELLS LUA WHAT UNIT TO DO IT TO 
end
)
else
SetProperty(ALL THE ODF JIBBILIE to make you get the D-15a
AND THE STUFF THAT TELLS LUA WHAT UNIT TO DO IT TO
end
) 
something like that, right? Just hoping to show Rekubot that it's probably not that hard. Feel free to fill in my . . . .Jibblie where'd I here that