"Lumberjack": type: assignment default constants: logs: oak_log|birch_log|spruce_log leaves: leaves|birch_leaves|spruce_leaves initialRange: 10 interact scripts: - 10 Lumberjack life actions: on assignment: - trigger name:click toggle:true - trigger name:proximity toggle:true range:5 - flag npc ready_to_cut:! - flag npc actualRange:<cons:initialRange> - anchor add <npc.location> "id:startPosition" on complete navigation: - if <npc.flag[ready_to_cut]> { - run "defineTree" } } on cancel navigation: - queue clear "Lumberjack Life": Requirements: Mode: ALL type: interact steps: 1: proximity trigger: entry: script: - lookclose <npc> state:true - run "Greetings" click trigger: script: - run "lookForTrees" "Greetings": type: task script: - chat targets:[email protected]<player.name> "Hello there <player.name>!" "lookForTrees": type: task script: - flag npc found_trees:! - foreach <npc.location.find.blocks[<cons:logs>].within[<npc.flag[actualRange]>].as_list> { - if <proc[isTreeHump].context[%value%]> { - flag npc found_trees:|:%value% } } - if <npc.flag[found_trees].size.as_int> == 0 { - narrate targets:[email protected]<player.name> "There is no trees in range of <npc.flag[actualRange]> blocks." - flag npc actualRange:++:10 - narrate targets:[email protected]<player.name> "Looking for trees in range of <npc.flag[actualRange]> blocks." - run "lookForTrees" } else { - flag npc current_tree:1 - lookclose <npc> state:false - walkto <npc> <npc.flag[found_trees].get[<npc.flag[current_tree].as_int>]> - flag npc ready_to_cut:true - queue clear } "defineTree": type: task script: - look <npc> <npc.flag[found_trees].get[<npc.flag[current_tree].as_int>]> - flag npc tree_elems:! - flag npc tree_elems:|:<npc.flag[found_trees].get[<npc.flag[current_tree].as_int>]> - flag npc current_elem:1 - run "checkBlockAbove" "checkBlockAbove": type: task script: - define currentBlock <npc.flag[tree_elems].get[<npc.flag[current_elem].as_int>]> - if <proc[isLogAbove].context[%currentBlock%]> { - animate <npc> animation:arm_swing - flag npc tree_elems:|:<%currentBlock%.above> - flag npc current_elem:++ - run "checkBlockAbove" } else { - run "lookForLeaves" } "lookForLeaves": type: task script: - define topBlock <npc.flag[tree_elems].get[<npc.flag[tree_elems].size.as_int>]> - foreach <%topBlock%.find.blocks[<cons:leaves>].within[3].as_list> { - flag npc tree_elems:|:%value% } - run "cutTree" "cutTree": type: task script: - foreach <npc.flag[tree_elems].as_list> { - modifyblock %value% 0 } - modifyblock <npc.flag[found_trees].get[<npc.flag[current_tree].as_int>]> 6 - flag npc current_tree:++ - if <proc[wasLast].context[<npc.flag[current_tree].as_int>|<npc.flag[found_trees].size.as_int>]> { - run "goToStart" } else { - walkto <npc> <npc.flag[found_trees].get[<npc.flag[current_tree].as_int>]> } "isLogAbove": type: procedure debug: false definitions: block script: - if <%block%.above.material.id> == <%block%.material.id> { - ^determine true } else { - ^determine false } "isTreeHump": type: procedure debug: false definitions: block script: - ^if <%block%.below.material.id> == 3 || <%block%.below.material.id> == 1 { - if <%block%.above.material.id> == <%block%.material.id> { - ^determine true } else { - ^determine false } } else { - ^determine false } "wasLast": type: procedure debug: false definitions: index|total script: - if %index% > %total% { - ^determine true } else { - ^determine false } "goToStart": type: task script: - flag npc ready_to_cut:! - flag npc actualRange:<cons:initialRange> - walkto <npc> <npc.anchor[startPosition]>
Beautiful script.
Hi, I love the idea of this script! I tested it out on my server, and I realized I needed to modify the type of sapling the NPC plants after cutting the tree. Could you please tell me which part to modify? I can't find it in your script .. Moreover, the interaction with players doesn't seem to work, any ideas on that? Thanks