|
16 | 16 | # Just create a shorthand reference to the kitchen object
|
17 | 17 | kitchen = df.ui.kitchen
|
18 | 18 |
|
19 |
| -# Store our list of banned items in the dictionary/hash table, along with their index number |
20 |
| -# -- index number storage was added from the original script so as to assist in addressing |
21 |
| -# the specific kitchen array entry directly later in the script, rather than search through it again. |
| 19 | +# Store our list of banned items in the dictionary/hash table |
22 | 20 | kitchen.item_types.length.times { |i|
|
23 |
| - already_banned[[kitchen.mat_types[i], kitchen.mat_indices[i], kitchen.item_types[i], kitchen.item_subtypes[i]]] = [ kitchen.exc_types[i] & 1, i ] |
| 21 | + if kitchen.exc_types[i] == :Cook |
| 22 | + already_banned[[kitchen.mat_types[i], kitchen.mat_indices[i], kitchen.item_types[i], kitchen.item_subtypes[i]]] = true |
| 23 | + end |
24 | 24 | }
|
25 | 25 |
|
26 | 26 | # The function for actually banning cooking of an item.
|
|
35 | 35 | key = [mat_type, mat_index, type, subtype]
|
36 | 36 | # Skip adding a new entry further below, if the item is already banned.
|
37 | 37 | if already_banned[key]
|
38 |
| - # Get our stored index kitchen arrays' index value |
39 |
| - index = already_banned[key][1] |
40 |
| - # Check that the banned flag is set. |
41 |
| - return if already_banned[key][0] == 1 |
42 |
| - # Added a check here to ensure that the exc_types array entry had something at the index entry |
43 |
| - # as the original script didn't check for :EDIBLE_COOKED before banning certain plants, so that |
44 |
| - # lead to mismatched array lengths, and a crash possibly due to memory corruption. |
45 |
| - if kitchen.exc_types[index] |
46 |
| - # Or's the value of the exc_type to turn the first bit of the byte on. |
47 |
| - puts(print_name + ' has been banned!') |
48 |
| - kitchen.exc_types[index] |= 1 |
49 |
| - end |
50 |
| - # Record in the dictionary/hash table that the item is now cooking banned. |
51 |
| - already_banned[key][0] = 1 |
52 | 38 | return
|
53 | 39 | end
|
54 | 40 | # The item hasn't already been banned, so we do that here by appending its values to the various arrays
|
|
59 | 45 | df.ui.kitchen.mat_indices << mat_index
|
60 | 46 | df.ui.kitchen.item_types << type
|
61 | 47 | df.ui.kitchen.item_subtypes << subtype
|
62 |
| - df.ui.kitchen.exc_types << 1 |
63 |
| - already_banned[key] = [ 1, length ] |
| 48 | + df.ui.kitchen.exc_types << :Cook |
| 49 | + already_banned[key] = true |
64 | 50 | }
|
65 | 51 |
|
66 | 52 | $script_args.each do |arg|
|
|
354 | 340 | # There's no entry for this item in our calculated list of cookable items. So, it's not a plant, alcohol, tallow, or milk. It's likely that it's a meat that has been banned.
|
355 | 341 | output += '|"' + key.inspect + ' unknown banned material type (meat?) " ' + '|item type: "' + b[0][2].inspect + '"|item subtype: "' + b[0][3].inspect
|
356 | 342 | end
|
357 |
| - output += '|exc type: "' + kitchen.exc_types[b[1][1]].inspect + '"' |
358 | 343 | puts output
|
359 | 344 | end
|
360 |
| - |
361 |
| - # prints out the data structures for several different plants and one animal so that their data structure can be examined/understood |
362 |
| - when 'potato' |
363 |
| - df.world.raws.plants.all.each_with_index do |p, i| |
364 |
| - if p.name.include?('potato') |
365 |
| - puts(p.inspect) |
366 |
| - end |
367 |
| - end |
368 |
| - |
369 |
| - when 'pig' |
370 |
| - df.world.raws.plants.all.each_with_index do |p, i| |
371 |
| - if p.name.include?('pig tail') |
372 |
| - puts(p.inspect) |
373 |
| - end |
374 |
| - end |
375 |
| - |
376 |
| - when 'cherry' |
377 |
| - df.world.raws.plants.all.each_with_index do |p, i| |
378 |
| - if p.name.include?('cherry') |
379 |
| - puts(p.inspect) |
380 |
| - end |
381 |
| - end |
382 |
| - |
383 |
| - # an example of both milling and thread in one plant |
384 |
| - when 'hemp' |
385 |
| - df.world.raws.plants.all.each_with_index do |p, i| |
386 |
| - if p.name.include?('hemp') |
387 |
| - puts(p.inspect) |
388 |
| - end |
389 |
| - end |
390 |
| - |
391 |
| - when 'cow' |
392 |
| - df.world.raws.creatures.all.each_with_index do |c, i| |
393 |
| - # can't just do "cow", as that would print reindeer cow, yak cow, and cow |
394 |
| - if c.name.include?('yak') |
395 |
| - # c.inspect truncates output too early to get to the materials we want to view |
396 |
| - c.material.each_with_index do |m, j| |
397 |
| - puts(m.inspect) |
398 |
| - end |
399 |
| - end |
400 |
| - end |
401 |
| - |
402 | 345 | else
|
403 | 346 | puts "ban-cooking booze - bans cooking of drinks"
|
404 | 347 | puts "ban-cooking honey - bans cooking of honey bee honey"
|
|
0 commit comments