Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / syntax problem? rollouts?
  RSS 2.0 ATOM  

syntax problem? rollouts?
Rate this thread
 
3761
 
Permlink of this thread  
avatar
  • Total Posts: 1
  • Joined: 12 April 2007 04:12 PM

i imagine this is real basic, but why does this script not work?

rollout ttsmt "smt" width:162 height:300
    
(
         
foo "abc"
         
print foo
    
)
if 
ttsmtfloater != undefined do
    (
         
closerolloutfloater ttsmtfloater
    
)        
CreateDialog  ttsmt width:162 height:300

i get the error

-- Error occurred in anonymous codeblock; filename: \\stuff\art\Common\jjacobson\scripts\; position: 49
-- Syntax error: at (, expected <rollout clause>
-- In line:  (

if i take out all the rollout code i can set and print the variable fine

foo "abc"
print foo

like i said i know this is a simple problem, ive just never learned it or had it explained to me. and to complicate things it seems that sometimes i can define variables in rollouts with no problems. 

i’m guessing this all boils down to a simple problem, just cant find it in, or figure it out from the maxscript help.

thanks



Replies: 0
avatar
  • Stokes
  • Posted: 23 January 2008 06:05 PM
  • Location: Boston Area, Massachusetts
  • Total Posts: 198
  • Joined: 22 August 2006 03:52 PM
  • Permlink of this post

You can’t execute code directly within a rollout. You need to define functions or event handlers, then put the code in it. You’ll also have to explicitly state that the new variables are either local or global.

rollout ttsmt "smt" width:162 height:300
(
      
local foo "abc"

      
on ttsmt open do
      (
               print 
foo
      
)
 )

Also, the bit to close the floater won’t work: you haven’t defined a rollout floater. The rollout will stay defined whether or not it’s open, anyway. You could try this:

try (destroyDialog ttsmt) catch ()

If you are going to evaluate the entire script every time you create the dialog, you’ll want to put that line before the rollout’s definition. If the rollout is open and then redefined, the destroyDialog will try to operate on the new definition, which hasn’t yet been opened as a dialog. The old one will stay open. (It took me a while to figure out that one.)



David “Stokes” Stokes
Senior Technical Artist, Blue Fang Games

Replies: 0
avatar

Stokes 24 January 2008 02:05 AM

You can’t execute code directly within a rollout.

THANK YOU!  You have no idea how long I’ve been trying to nut out why I’m getting this error.



Replies: 0