Can't clamp a variable value through Lua script in node
Posted: Wed Mar 14, 2018 2:58 pm
Hi there,
I'm trying to make this work as a script in a node...:
However, it is throwing me this error output...:
I understand it is a somewhat complex call, but I need it working to save me from a world of pain...
Now, after some research I've found out that math.clamp is not really a function that exists in Lua scripting (?)
I know there are two functions called .ceil and .floor, but as I'll get negative numbers that should always be converted to zero, I don't think they're useful to me. In fact, I'm extremely surprised that math.clamp is not a standard function in Lua.
So... I'm wondering if there's some way to implement it manually so I can use it in DS node scripts...?
Thanks!
Edit: just realized that I already asked something very similar in the past.
I guess I could add an intermediate step to "process" the number in question with an FSM component (waiting for a "done" message before continuing), but... don't you think a built in clamp function would be useful to have in DS?
I'm trying to make this work as a script in a node...:
Code: Select all
Variable["Lust"] = Variable["Lust"] + math.clamp((Variable["MaxLustCenvirHJ"]-Variable["Lust"]),0,Variable["LustAddCenvirHJ"])
Code: Select all
Dialogue System: Lua code 'Variable["Lust"] = Variable["Lust"] + math.clamp((Variable["MaxLustCenvirHJ"]-Variable["Lust"]),0,Variable["LustAddCenvirHJ"])' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua?'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry, Boolean, Boolean, Boolean)
PixelCrushers.DialogueSystem.ConversationModel:GetState(DialogueEntry)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle()
PixelCrushers.DialogueSystem.ConversationView:HandleContinueButtonClick()
PixelCrushers.DialogueSystem.ConversationView:OnConversationContinue(IDialogueUI)
UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinueConversation()
PixelCrushers.DialogueSystem.AbstractDialogueUI:OnContinue()
UnityEngine.EventSystems.EventSystem:Update()
Now, after some research I've found out that math.clamp is not really a function that exists in Lua scripting (?)
I know there are two functions called .ceil and .floor, but as I'll get negative numbers that should always be converted to zero, I don't think they're useful to me. In fact, I'm extremely surprised that math.clamp is not a standard function in Lua.
So... I'm wondering if there's some way to implement it manually so I can use it in DS node scripts...?
Thanks!
Edit: just realized that I already asked something very similar in the past.
I guess I could add an intermediate step to "process" the number in question with an FSM component (waiting for a "done" message before continuing), but... don't you think a built in clamp function would be useful to have in DS?