Difference between revisions of "Talk:Cast Reference"
Jump to navigation
Jump to search
imported>Egocarib |
imported>Rasikko m (Undo revision 51725 by Rasikko (talk) was testing something.. seems like some pages are blocked from editing.) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 3: | Line 3: | ||
--[[User:Zoe S17|Zoe S17]] ([[User talk:Zoe S17|talk]]) 2014-12-11T02:54:48 (EST) | --[[User:Zoe S17|Zoe S17]] ([[User talk:Zoe S17|talk]]) 2014-12-11T02:54:48 (EST) | ||
:Papyrus doesn't have short type variables, only [[Literals_Reference#Integer_Literals|int]]. It also isn't possible to cast a literal (bool or int) to a object-type variable (like GlobalVariable), | :Papyrus doesn't have short type variables, only [[Literals_Reference#Integer_Literals|int]]. It also isn't possible to cast a literal (bool or int) to a object-type variable (like GlobalVariable). If you just mean you want to assign a boolean value to a GlobalVariable, you can do it like this: | ||
<source lang="papyrus"> | |||
;assign bool to global: | |||
SomeGlobalVariable.SetValueInt(yourBool as Int) ;casting bool to int results in 1 if the bool is true, and 0 if the bool is false | |||
;assign global back to bool | |||
yourBool = SomeGlobalVariable.GetValueInt() ;yourBool will be true if the global value has any non-zero value (positive or negative). | |||
;yourBool will be false if the global equals 0 | |||
</source> | |||
:--[[User:Egocarib|egocarib]] ([[User talk:Egocarib|talk]]) 2014-12-12T20:55:07 (EST) | :--[[User:Egocarib|egocarib]] ([[User talk:Egocarib|talk]]) 2014-12-12T20:55:07 (EST) | ||
::Thank you that solved my problem and you just showed me how to cast a literal into a [[GlobalVariable_Script|GlobalVariable]] but it's only possible because of the functions SetValueInt() and GetValueInt() in the [[GlobalVariable_Script|GlobalVariable Script]] | |||
::--[[User:Zoe S17|Zoe S17]] ([[User talk:Zoe S17|talk]]) 2014-12-12T21:43:17 (EST) |
Latest revision as of 09:23, 1 April 2018
What is the best(both cheap in memory and soucre code space) way to cast a bool into a short so one could use it as a link through(cast) to a GlobalVar.
--Zoe S17 (talk) 2014-12-11T02:54:48 (EST)
- Papyrus doesn't have short type variables, only int. It also isn't possible to cast a literal (bool or int) to a object-type variable (like GlobalVariable). If you just mean you want to assign a boolean value to a GlobalVariable, you can do it like this:
;assign bool to global:
SomeGlobalVariable.SetValueInt(yourBool as Int) ;casting bool to int results in 1 if the bool is true, and 0 if the bool is false
;assign global back to bool
yourBool = SomeGlobalVariable.GetValueInt() ;yourBool will be true if the global value has any non-zero value (positive or negative).
;yourBool will be false if the global equals 0
- Thank you that solved my problem and you just showed me how to cast a literal into a GlobalVariable but it's only possible because of the functions SetValueInt() and GetValueInt() in the GlobalVariable Script
- --Zoe S17 (talk) 2014-12-12T21:43:17 (EST)