Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *comment here's our simple inventory:
- *temp inv_slot_1 "Steel sword"
- *temp inv_slot_2 "Wooden shield"
- *temp inv_slot_3 "Magic potion"
- *temp inv_slot_4 "Health potion"
- *temp inv_slot_5 "Rope"
- *temp inv_slot_6 "nothing"
- *temp inv_slot_7 "nothing"
- *temp inv_slot_8 "nothing"
- *temp inv_slot_9 "nothing"
- *temp inv_slot_10 "nothing"
- *comment here's a basic and pretty standard way of displaying what's in our inventory:
- 1st Method #1
- *line_break
- *line_break
- *if (inv_slot_1 != "nothing")
- ${inv_slot_1},
- *if (inv_slot_2 != "nothing")
- ${inv_slot_2},
- *if (inv_slot_3 != "nothing")
- ${inv_slot_3},
- *if (inv_slot_4 != "nothing")
- ${inv_slot_4},
- *if (inv_slot_5 != "nothing")
- ${inv_slot_5},
- *if (inv_slot_6 != "nothing")
- ${inv_slot_6},
- *if (inv_slot_7 != "nothing")
- ${inv_slot_7},
- *if (inv_slot_8 != "nothing")
- ${inv_slot_8},
- *if (inv_slot_9 != "nothing")
- ${inv_slot_9},
- *if (inv_slot_10 != "nothing")
- ${inv_slot_10},
- *comment here's another way that uses a loop:
- *page_break
- 2nd Method #1
- *line_break
- *line_break
- *label print_inventory
- *temp n 0
- *temp current_inv_item
- *label print_inventory_loop
- *set n + 1
- *set current_inv_item {"inv_slot_"&n}
- *if (current_inv_item != "nothing")
- ${current_inv_item},
- *if (n < 10)
- *goto print_inventory_loop
- *comment both produce exactly the same result, so which do you think is better?
- *comment in this particular case, it's fair to say neither is overly advantageous
- *comment But wait! Let's try that again with 50 item slots...
- *temp inv_slot_1 "Steel sword"
- *temp inv_slot_2 "Wooden shield"
- *temp inv_slot_3 "Magic potion"
- *temp inv_slot_4 "Health potion"
- *temp inv_slot_5 "Rope"
- *temp inv_slot_6 "Wizard Staff"
- *temp inv_slot_7 "Glowing Orb"
- *temp inv_slot_8 "Dragon Egg"
- *temp inv_slot_9 "55 Gold Pieces"
- *temp inv_slot_10 "Gold Locket"
- *temp inv_slot_11 "Blunt Axe"
- *temp inv_slot_12 "Sharp Dagger"
- *temp inv_slot_13 "Boots of Speed"
- *temp inv_slot_14 "Etc..."
- *temp inv_slot_15 "nothing"
- *temp inv_slot_16 "nothing"
- *temp inv_slot_17 "nothing"
- *temp inv_slot_18 "nothing"
- *temp inv_slot_19 "nothing"
- *temp inv_slot_20 "nothing"
- *temp inv_slot_21 "nothing"
- *temp inv_slot_22 "nothing"
- *temp inv_slot_23 "nothing"
- *temp inv_slot_24 "nothing"
- *temp inv_slot_25 "nothing"
- *temp inv_slot_26 "nothing"
- *temp inv_slot_27 "nothing"
- *temp inv_slot_28 "nothing"
- *temp inv_slot_29 "nothing"
- *temp inv_slot_30 "nothing"
- *temp inv_slot_31 "nothing"
- *temp inv_slot_32 "nothing"
- *temp inv_slot_33 "nothing"
- *temp inv_slot_34 "nothing"
- *temp inv_slot_35 "nothing"
- *temp inv_slot_36 "nothing"
- *temp inv_slot_37 "nothing"
- *temp inv_slot_38 "nothing"
- *temp inv_slot_39 "nothing"
- *temp inv_slot_40 "nothing"
- *temp inv_slot_41 "nothing"
- *temp inv_slot_42 "nothing"
- *temp inv_slot_43 "nothing"
- *temp inv_slot_44 "nothing"
- *temp inv_slot_45 "nothing"
- *temp inv_slot_46 "nothing"
- *temp inv_slot_47 "nothing"
- *temp inv_slot_48 "nothing"
- *temp inv_slot_49 "nothing"
- *temp inv_slot_50 "nothing"
- *comment here's the ammended code for our first method:
- *page_break
- 1st Method #2
- *line_break
- *line_break
- *if (inv_slot_1 != "nothing")
- ${inv_slot_1},
- *if (inv_slot_2 != "nothing")
- ${inv_slot_2},
- *if (inv_slot_3 != "nothing")
- ${inv_slot_3},
- *if (inv_slot_4 != "nothing")
- ${inv_slot_4},
- *if (inv_slot_5 != "nothing")
- ${inv_slot_5},
- *if (inv_slot_6 != "nothing")
- ${inv_slot_6},
- *if (inv_slot_7 != "nothing")
- ${inv_slot_7},
- *if (inv_slot_8 != "nothing")
- ${inv_slot_8},
- *if (inv_slot_9 != "nothing")
- ${inv_slot_9},
- *if (inv_slot_10 != "nothing")
- ${inv_slot_10},
- *if (inv_slot_11 != "nothing")
- ${inv_slot_11},
- *if (inv_slot_12 != "nothing")
- ${inv_slot_12},
- *if (inv_slot_13 != "nothing")
- ${inv_slot_13},
- *if (inv_slot_14 != "nothing")
- ${inv_slot_14},
- *if (inv_slot_15 != "nothing")
- ${inv_slot_15},
- *if (inv_slot_16 != "nothing")
- ${inv_slot_16},
- *if (inv_slot_17 != "nothing")
- ${inv_slot_17},
- *if (inv_slot_18 != "nothing")
- ${inv_slot_18},
- *if (inv_slot_19 != "nothing")
- ${inv_slot_19},
- *if (inv_slot_20 != "nothing")
- ${inv_slot_20},
- *if (inv_slot_21 != "nothing")
- ${inv_slot_21},
- *if (inv_slot_22 != "nothing")
- ${inv_slot_22},
- *if (inv_slot_23 != "nothing")
- ${inv_slot_23},
- *if (inv_slot_24 != "nothing")
- ${inv_slot_24},
- *if (inv_slot_25 != "nothing")
- ${inv_slot_25},
- *if (inv_slot_26 != "nothing")
- ${inv_slot_26},
- *if (inv_slot_27 != "nothing")
- ${inv_slot_27},
- *if (inv_slot_28 != "nothing")
- ${inv_slot_28},
- *if (inv_slot_29 != "nothing")
- ${inv_slot_29},
- *if (inv_slot_30 != "nothing")
- ${inv_slot_30},
- *if (inv_slot_31 != "nothing")
- ${inv_slot_31},
- *if (inv_slot_32 != "nothing")
- ${inv_slot_32},
- *if (inv_slot_33 != "nothing")
- ${inv_slot_33},
- *if (inv_slot_34 != "nothing")
- ${inv_slot_34},
- *if (inv_slot_35 != "nothing")
- ${inv_slot_35},
- *if (inv_slot_36 != "nothing")
- ${inv_slot_36},
- *if (inv_slot_37 != "nothing")
- ${inv_slot_37},
- *if (inv_slot_38 != "nothing")
- ${inv_slot_38},
- *if (inv_slot_39 != "nothing")
- ${inv_slot_39},
- *if (inv_slot_40 != "nothing")
- ${inv_slot_40},
- *if (inv_slot_41 != "nothing")
- ${inv_slot_41},
- *if (inv_slot_42 != "nothing")
- ${inv_slot_42},
- *if (inv_slot_43 != "nothing")
- ${inv_slot_43},
- *if (inv_slot_44 != "nothing")
- ${inv_slot_44},
- *if (inv_slot_45 != "nothing")
- ${inv_slot_45},
- *if (inv_slot_46 != "nothing")
- ${inv_slot_46},
- *if (inv_slot_47 != "nothing")
- ${inv_slot_47},
- *if (inv_slot_48 != "nothing")
- ${inv_slot_48},
- *if (inv_slot_49 != "nothing")
- ${inv_slot_49},
- *if (inv_slot_50 != "nothing")
- ${inv_slot_50},
- *comment painful, right? Check out the ammended code for our second (loop utilizing) method:
- *page_break
- 2nd Method #2
- *line_break
- *line_break
- *label print_inventory_2
- *temp n 0
- *temp current_inv_item
- *label print_inventory_loop_2
- *set n + 1
- *set current_inv_item {"inv_slot_"&n}
- *if (current_inv_item != "nothing")
- ${current_inv_item},
- *if (n < 50)
- *goto print_inventory_loop_2
- *finish
- *comment so, which one do you think scales better? :)
- *comment note that the only reason we needed to change the labels of this 2nd method this time round
- *comment was due to them already existing from the first time round - we would actually only need to
- *comment ever change the (n < 50) bit to however many slots we have, that's it!
- *comment we could even swap '50' out for a variable stored value like "item_count" if we wanted.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement