Skip to content

Instantly share code, notes, and snippets.

@csprance
Last active May 6, 2016 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csprance/05a63cae34f6212288d887377a0aa907 to your computer and use it in GitHub Desktop.
Save csprance/05a63cae34f6212288d887377a0aa907 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
################################################################################
#
# explosivo_class.py
# Description: The class used for toggling a mesh morph from 100% to -100%
# Usage:
# Explosivo.toggle - toggles the explode map on the selected meshes
# Explosivo.toggle other_explode_morph_name - toggles the explode on the selected meshes
# but uses a custom named morph map
# (if nothing selected everything is selected)
# Author: Chris Sprance Entrada Interactive
#
################################################################################
import lx
import lxifc
import lxu.command
class ExplosivoToggle(lxu.command.BasicCommand):
def __init__(self):
lxu.command.BasicCommand.__init__(self)
self.dyna_Add('explode_name', lx.symbol.sTYPE_STRING)
self.basic_SetFlags(0, lx.symbol.fCMDARG_OPTIONAL)
self.morph_name = str()
def cmd_Flags(self):
return lx.symbol.fCMD_MODEL | lx.symbol.fCMD_UNDO
def basic_Enable(self, msg):
return True
def cmd_Interact(self):
pass
def basic_Execute(self, msg, flags):
self.morph_name = self.dyna_String(0, 'Explode')
lx.out(self.morph_name)
def cmd_Query(self, index, vaQuery):
lx.notimpl()
lx.bless(ExplosivoToggle, "Explosivo.toggle")
@csprance
Copy link
Author

csprance commented May 5, 2016

So with a python kit command
Eplosivo.toggle

I know how to pass an argument so it works like
Explosivo.toggle name

but what if I want to substitute a default value if no argument is given? Like this:
Explosivo.toggle

then the code sees that and sets morph_name to Explode

Right now it always asks me for a value

@csprance
Copy link
Author

csprance commented May 6, 2016

Solved it update the Gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment