I've got another question (and this one might seem silly):
What is CommonData, what is it used for and how is it used?
I'm trying to learn aspects of Danmakufu and this one feels important to learn, but the wiki isn't helping me on the subject.
CommonData is a function which allows you to communicate across scripts (mainly) or tasks/functions which aren't included/related directly in ph3. Normally you would need to include scripts to call variables from there (if global). CommonData is stored in the "memory" during the entire "play" and is active once it is called/set.
SetCommonData(<string>,<value>); is your starting point for example. The string parameter is the commondata identifier. The value can be a bool, int or string. The value can be called by using
GetCommonData(<string>,defaultvalue>); The default value is always returned if the CommonData could not find a valid value from the SetcommonData.
A good example which was "common" in 0.12m was setting menu difficulty. Let us say you want to set the difficulty and call this value regardless of which script is running/closed. CommonData would be most useful here.
SetCommonData("difficulty","easy"); next, in some other script where you call enemy patterns, you want to know what the difficulty setting is:
if(GetCommonData("difficulty","easy") == "normal") { } <- will check if the commondata "difficulty" equals "normal". The defaultvalue is only retrieved if the commondata was "invalid", but since it has a value it will not return easy. You could also make it return something else like 'false'. But the default value might be useful in some cases.
Another example would be player power:
SetCommonData("playerPower",100);
// player picks up a P.
let power = GetCommonData("playerPower",0);
power++;
SetCommonData("playerPower",power);
Above example summons a commondata named playerPower with starting value of 100. In some P-pickup event, I retrieve the value and store it inside temp variable called: power (for easier calc). Next, the powervar is incremented once. So the value of power = 101. The power var is then stored again in the commondata under the same name. The old value will be overwritten and thus if you check your logwindow, you will notice playerpower became 101.
If playerpower was never set, like it didn't exist then the default value retrieved would be 0. Thus power would be 0 and incremented once becoming 1. So the new commondata would be 1. Simple as that.
Regular CommonData is also cleared from the "memory" when your running game/script is closed (i.e unloading back to menu in ph3). In the CommonData tab in Logwindow (activate it if you don't have it) you can see the results.
Logically there is more too it like saving your commondata and such, but baby steps are advised. Ph3 also empowers the use of CommonData by allowing you to use
commondata areas, which is basically categorizing your commondata more efficiently. But that is one another step next. Try to fiddle around with the above first.
Edit quick questionHas anybody ever fiddled with INFO_IS_DURABLE_SPELL ? This:
@Event {
alternative(GetEventType())
case(EV_REQUEST_IS_DURABLE_SPELL) {
SetScriptResult(true);
}
}
Does not return 'true' when I check ObjEnemyBossScene_GetInfo(bossObj,INFO_IS_DURABLE_SPELL) with text object. Am I missing something?