Community
SCI Programming => SCI Syntax Help => Topic started by: Adam on November 20, 2013, 06:47:06 PM
-
I am trying to rearrange and decentralize my code, and was about to update the ego instance with automatic view setting based on outfit and animation.
Here is what I added to the ego code:
(method (outfit newOutfit)
(var oldOutfit)
= oldOutfit gEgoOutfit
= gEgoOutfit newOutfit
Print("change") //Debug
(self:setView())
return(oldOutfit)
)
(method (animation newAnimation)
(var oldAnimation )
= oldAnimation gEgoAnimation
= gEgoAnimation newAnimation
Print("change!!") //Debug
(self:setView())
return(oldAnimation)
)
(method (setView)
(switch (gEgoOutfit)
(case (OUTFIT_CLOTHES)
= view 100
)
(default
(switch (gEgoAnimation)
(case (ANIMATION_EAT) = view 8)
(default = view 0)
)
)
)
)
I try to call it like this from the room:
(if (== (send gEgo:outfit) OUTFIT_CLOTHES) Print("You are already clothed."))
(else
(if(theChest:inControlArea)
(if (== gRoom1ChestStatus DOOR_OPEN) (send gEgo:outfit(OUTFIT_CLOTHES)))
(else Print("Your adventuring outfit must be in the closed chest before you."))
)
(else Print("Your adventuring outfit should be in your chest."))
)
But sadly it does not even go into the outfit method. Any ideas why?
-
I tested this out, it seems like it works fine. Here's the code I used, a very simplified version using the template game:
In the User.sc script:
(method (outfit newOutfit)
(var oldOutfit)
Print("change") //Debug
return(oldOutfit)
)
And in the room:
(instance RoomScript of Script
(properties)
(method (handleEvent pEvent)
(super:handleEvent(pEvent))
/*****************************************
* Handle the possible said phrases here *
*****************************************/
(if(Said('look'))
Print("You are in an empty room")
(send gEgo:outfit(800))
)
)
)
It does go through the outfit method & I get the 'change' debug message to pop up. Maybe there is something wrong with the preceding conditions in the 'if' statement?
-
Thanks for the reply. It turned out I messed up a level under the ego instance. I forgot that I made an outfit property for the Ego class, and it catched the gEgo:outfit, not calling the outfit method of the instance.