LISTS AND CODE!
Shmabz
22 May 2014, 17:06Hey umm in my script i made it so i have a list with 10 objects. I have made the game get a random Int between 0 and the listLength - 1, but i want to remove EVERY object in the list from the first up until to the random Int generated, how is that possible or is it possible?
Shmabz
22 May 2014, 17:07Also, in the code is there a way to make it do a function a specified amount of times?:))
HegemonKhan
22 May 2014, 19:161A. for an object list:
(look up 'for' in the quest wiki, to see the correct syntax, as I don't remember it)
('foreach' is to act upon EVERY~ALL items in your list)
('for' is to act upon a specific range of items in your list)
for (item_x, min_of_range, max_of_range, String_or_Object_List)
for (item_x, 0, ListCount (name_of_your_Object.name_of_your_object_list) - 1, name_of_your_Object.name_of_your_object_list) {
-> item_x.parent = name_of_your_destination_object_that_you're_moving_list_items_to
-> // or, if you want to specifically 'remove' or 'delete' them, see the code syntax for that (use the quest wiki to see how it's done)
}
~OR~
1B. if you just have a string list (or an object list too), then simply create a new (which will be empty) string (or object) list, with the exact same name:
name_of_your_string_list = NewStringList ()
name_of_your_object_list = NewObjectList ()
2. simply make a 'counting' Attribute and then 'check' (via an 'if' Script) it:
Object.Attribute = Value
if (Object.Attribute = Value) {
-> // your scripts
}
for (a quick) example:
<game name="blah">
-> // blah code lines
-> <attr name="fight_orc_count_integer" type="int">0</attr>
-> // blah code lines
</game>
<function name="fight_orc_function"><![CDATA[
-> if (game.fight_orc_count_integer = 10) {
->-> game.pov.cash = game.pov.cash + orc.cash
->-> orc.cash = 0
->-> msg ("You killed the orc, and loot its gold.")
-> } else if (game.fight_orc_count_integer < 10) {
->-> game.fight_orc_count_integer = game.fight_orc_count_integer + 1
->-> msg ("You attack the orc, wounding it, and with enough hits, it'll die.")
-> }
]]></function>
(look up 'for' in the quest wiki, to see the correct syntax, as I don't remember it)
('foreach' is to act upon EVERY~ALL items in your list)
('for' is to act upon a specific range of items in your list)
for (item_x, min_of_range, max_of_range, String_or_Object_List)
for (item_x, 0, ListCount (name_of_your_Object.name_of_your_object_list) - 1, name_of_your_Object.name_of_your_object_list) {
-> item_x.parent = name_of_your_destination_object_that_you're_moving_list_items_to
-> // or, if you want to specifically 'remove' or 'delete' them, see the code syntax for that (use the quest wiki to see how it's done)
}
~OR~
1B. if you just have a string list (or an object list too), then simply create a new (which will be empty) string (or object) list, with the exact same name:
name_of_your_string_list = NewStringList ()
name_of_your_object_list = NewObjectList ()
2. simply make a 'counting' Attribute and then 'check' (via an 'if' Script) it:
Object.Attribute = Value
if (Object.Attribute = Value) {
-> // your scripts
}
for (a quick) example:
<game name="blah">
-> // blah code lines
-> <attr name="fight_orc_count_integer" type="int">0</attr>
-> // blah code lines
</game>
<function name="fight_orc_function"><![CDATA[
-> if (game.fight_orc_count_integer = 10) {
->-> game.pov.cash = game.pov.cash + orc.cash
->-> orc.cash = 0
->-> msg ("You killed the orc, and loot its gold.")
-> } else if (game.fight_orc_count_integer < 10) {
->-> game.fight_orc_count_integer = game.fight_orc_count_integer + 1
->-> msg ("You attack the orc, wounding it, and with enough hits, it'll die.")
-> }
]]></function>
Shmabz
22 May 2014, 20:39Thanks :')