PDA

View Full Version : array


ikkenik
04-29-2008, 06:29 PM
hello,
this is my first time on this forum and the first time I'm trying to write a script.
And I have already some problems, so I hope you gays can help me.
First I you have all my apologies, for the mistakes in my english.
I'm from Belgium and normaly speeks Dutch.

In my script I try to writ something like the command array in max, just to learn the basics.
First I wanted to do it with arrays, but that didn't work.
The second possibility worked better, but now I'd loved to know what I did wrong whith the arrays.
Probably I'm making some basic mistakes, but I just can't find it.
the mistake is somewhere in the bold area.
At the back I've also placed the script witch work fine, but maybe there can be some finetuning...
So here is are the scripts:



Utility meerdere "kopieren"
(
Rollout rechtdr "rechtdoor"
(
local gekozen, KopieObj
local verzameling = #()
local verzamelingy = #()

pickbutton source "object" width:100

spinner aantalx "aantal x-as" type:#integer range:[0,10000,0]
spinner aantaly "aantal y-as" type:#integer range:[0,10000,0]
spinner aantalz "aantal z-as" type:#integer range:[0,10000,0]

spinner afstandx "afstand x-as" type:#worldunits range:[-10000,10000,0]
spinner afstandy "afstand y-as" type:#worldunits
spinner afstandz "afstand z-as" type:#worldunits

Button Start "kopie" width:100

on source picked obj do
if obj != undefined do
(
gekozen = obj
source.text = obj.name
)

on start pressed do
if gekozen == undefined then
messagebox "selecteer eerst een object" title: "object"

else
if isdeleted gekozen then
messagebox "het geselecteerde object is verwijderd" title:"verwijderd"

else
(
append verzameling gekozen
if aantalx.value > 0 do
for t=1 to aantalx.value do
(
KopieObj = copy gekozen
move KopieObj [afstandy.value * t ,0,0]
append verzameling KopieObj
)


if aantaly.value > 0 do
(
verzamelingy = deepcopy verzameling
for i=1 to verzamelingy.count do
for t=1 to aantaly.value do
(
KopieObj = verzamelingy [i]
move KopieObj [0, afstandy.value * t ,0]
append verzameling KopieObj
)
)
)
)
on meerdere open do
addrollout rechtdr
on meerdere close do
removerollout rechtdr
)








SCRIPT 2

Utility meerdere "kopieren"
(
Rollout rechtdr "rechtdoor"
(
local gekozen, KopieObj

pickbutton source "object" width:100

spinner aantalx "aantal x-as" type:#integer range:[0,10000,0]
spinner aantaly "aantal y-as" type:#integer range:[0,10000,0]
spinner aantalz "aantal z-as" type:#integer range:[0,10000,0]

spinner afstandx "afstand x-as" type:#worldunits
spinner afstandy "afstand y-as" type:#worldunits
spinner afstandz "afstand z-as" type:#worldunits

Button Start "kopie" width:100

on source picked obj do
if obj != undefined do
(
gekozen = obj
source.text = obj.name)


on start pressed do
if gekozen == undefined then
messagebox "selecteer eerst een object" title: "object"

else
if isdeleted gekozen then
messagebox "het geselecteerde object is verwijderd" title:"verwijderd"

else

if aantalx.value > 0 do
for u=1 to aantalx.value+1 do
if aantaly.value > 0 do
for v=1 to aantaly.value+1 do
if aantalz.value > 0 do
for w=1 to aantalz.value+1 do
if not (u==1 and v==1 and w==1) do
(KopieObj = copy gekozen
move KopieObj [afstandx.value * (u-1) ,afstandy.value * (v-1),afstandz.value * (w-1)]
)

)
on meerdere open do
addrollout rechtdr
on meerdere close do
removerollout rechtdr

CGTalk Moderation
04-29-2008, 06:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.