View Full Version : Cycler
Xarxus
November 2nd, 2023, 18:27
Can anyone tell me where I can find an example of a cycler to use outside the options?
Thanks in advance
LordEntrails
November 2nd, 2023, 20:05
I put one in a custom ruleset I'm still developing. But I used RulesetWizard to create it. I use it for toggling through damage types associated with weapons and defenses. I can pull out the code if you want to see it.
Xarxus
November 2nd, 2023, 21:35
Sure, you'd make me happy, if it's not too much trouble.
I would like it very much.
rhagelstrom
November 2nd, 2023, 21:50
There are a couple in the combat tracker for each effect
LordEntrails
November 2nd, 2023, 23:47
Here's the snippet
<button_stringcycler name="protectionType">
<frame>
<name>fielddark</name>
<offset>0,0,0,0</offset>
</frame>
<bounds>300,31,32,25</bounds>
<parameters>
<defaultlabelres>sub_item_defense_protectionType_DefaultLabel</defaultlabelres>
<labelsres>sub_item_defense_protectionType_Label_B|sub_item_d efense_protectionType_Label_E|sub_item_defense_pro tectionType_Label_S</labelsres>
<values>beam|electric|sonic</values>
</parameters>
</button_stringcycler>
I attached the complete xml file it is used it too.
Xarxus
November 3rd, 2023, 11:50
Really ty LordEntrails!
LordEntrails
November 3rd, 2023, 16:47
Really ty LordEntrails!
Of course. This is one of the few code examples I can help with since I'm normally just look at code as magic!
Xarxus
November 4th, 2023, 11:26
However you have been of great help to me, believe me
;)
Xarxus
December 5th, 2023, 21:35
Is there a way to not use tags for initialization, leaving the task to the code?
Xarxus
December 5th, 2023, 21:53
Ok, nevermind. I've found this in CoreRPG
<button_stringcycler name="cycler">
<anchored width="100">
<top offset="5" />
<left anchor="right" offset="-117" />
</anchored>
<font>optionbody</font>
<sourceless />
<script>
function onDragStart(button, x, y, draginfo)
return window.onDragStart(draginfo);
end
function onValueChanged()
window.onValueChanged();
end
</script>
</button_stringcycler>
AnD this
...
cycler.initialize(aCustom.labels, aCustom.values, aCustom.baselabel);
...
cycler.setStringValue(sValue);
...
Xarxus
May 4th, 2024, 11:24
OK, now what I would like to do is to have a button_stringcycler whose value is saved on the DB. There must always be a value on a field of the DB. I declared it wirhout the sourceles tag.
<button_stringcycler name="mycycler">
<anchored width="60">
<left parent="mylabel" anchor="right" offset="10"/>
<top parent="mylabel" />
</anchored>
</button_stringcycler>
In the LUA code, I initialized the values and labels in the same way:
myValues="one|two|three|four|five"
Now I can initialize mycycler passing labels, values, empty value and default value.
mycycler.initialize(myValues, myValues);
or
mycycler.initialize(myValues, myValues, nil);
or
mycycler.initialize(myValues, myValues, "");
or
mycycler.initialize(myValues, myValues, nil, "one");
or
mycycler.initialize(myValues, myValues, "", "one");
or
mycycler.initialize(myValues, myValues, "one");
The is no way to:
have the value initialized with the db value ("one") - I've already tried to use
mycycler.setStringValue("one") hide the empty value
A can remove "one" from the intial values/labels, but I still have no good result.
Xarxus
May 4th, 2024, 11:37
I get an initial good result using
mycycler.initialize(myValues, myValues, "one", "one");
But if I close and reopen the window, mycycler is empty.
Xarxus
May 4th, 2024, 14:05
Ok, here is my solution. In this way I always have a field (and a value) on DB and I've no empty string shown.
Template
<template name="mybutton_stringcycler">
<button_stringcycler>
<script file="common/scripts/mybutton_stringcycler.lua" />
<sourceless/>
</button_stringcycler>
</template>
mybutton_stringcycler.lua
local _nodeRecord;
function onInit()
_nodeRecord = window.getDatabaseNode();
if super and super.onInit() then
super.onInit();
end
end
function onValueChanged()
DB.setValue(_nodeRecord, self.getName(), "string", self.getValue());
end
window class
<mybutton_stringcycler name="mycycler">
<anchored width="60">
<left parent="mylabel" anchor="right" offset="10"/>
<top parent="mylabel" />
</anchored>
</mybutton_stringcycler>
window code
local _nodeRecord;
function onInit()
_nodeRecord = window.getDatabaseNode();
myValues="two|three|four|five";
mycycler.initialize(myValues, myValues, "one");
mycycler.setStringValue(DB.getValue(_nodeRecord, "mycycler", "one");
end
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.