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!
Random ODFs?
Moderator: Moderators
-
Rekubot
- Jedi

- Posts: 1080
- Joined: Wed Apr 05, 2006 12:34 pm
- Projects :: No Mod project currently.
- xbox live or psn: Rekubot
- Location: UK
Random ODFs?
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!
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!
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
RE: Random ODFs?
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.
-
Rekubot
- Jedi

- Posts: 1080
- Joined: Wed Apr 05, 2006 12:34 pm
- Projects :: No Mod project currently.
- xbox live or psn: Rekubot
- Location: UK
RE: Random ODFs?
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. 
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
RE: Random ODFs?
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().
-
fat_walrus
RE: Random ODFs?
How would that look in SWBFII LUA? You can only use integers if I am not mistakin.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
RE: Random ODFs?
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.
There is no restriction on the type of numbers you can use.
-
Ace_Azzameen_5
- Jedi

- Posts: 1119
- Joined: Sat Apr 23, 2005 8:52 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
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:
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
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
)
