ORMtnMan Posted May 31, 2015 Share Posted May 31, 2015 All, Quick question, is it possible to postpone a recipe from changing an item until after the script that is triggered with it completes? For example, I have a recipe script which Will "convert" a .357 revolver to use .38 special. I have got it to the point that it will unload the .357 rounds however, the gun is already changed to a .38, so if I run or otherwise interrupt the action the remainder of the ammo is lost (for no reason). So I am trying to see if there is a way via the recipe hook to wait until the .357 version is fully unloaded before making the conversion. Thanks, if not I'll think of another way to do it. The recipe way is such an easy way to start... Link to comment Share on other sites More sharing options...
EnigmaGrey Posted May 31, 2015 Share Posted May 31, 2015 Take a look at the TimedActions used for farming and that. Link to comment Share on other sites More sharing options...
ORMtnMan Posted May 31, 2015 Author Share Posted May 31, 2015 Well, I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook? Link to comment Share on other sites More sharing options...
Fuji Posted May 31, 2015 Share Posted May 31, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script? Link to comment Share on other sites More sharing options...
ORMtnMan Posted May 31, 2015 Author Share Posted May 31, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script? That is what I have, if I select the conversion recipe on the context menu it will unload the gun but what happens is as follows:Have Gun with loaded roundsConvert to another caliberUnload process startsCorrectly gives back ammoHowever, gun itself is already gone and replaced by converted gun with no ammoUnload process continues until the correct amount of ammo is replaced even though it is "gone".However, if unloading is interrupted in any way, it will not start up again and converted gun has no ammo,because the original gun with the ammo is gone, the remaining ammo is lost forever Which is why I am wondering if it is possible to delay the actual conversion process until the loading part of the lua script is done.That way it won't switch out the guns into the original is empty Link to comment Share on other sites More sharing options...
Fuji Posted May 31, 2015 Share Posted May 31, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script?That is what I have, if I select the conversion recipe on the context menu it will unload the gun but what happens is as follows:Have Gun with loaded roundsConvert to another caliberUnload process startsCorrectly gives back ammoHowever, gun itself is already gone and replaced by converted gun with no ammoUnload process continues until the correct amount of ammo is replaced even though it is "gone".However, if unloading is interrupted in any way, it will not start up again and converted gun has no ammo,because the original gun with the ammo is gone, the remaining ammo is lost foreverWhich is why I am wondering if it is possible to delay the actual conversion process until the loading part of the lua script is done.That way it won't switch out the guns into the original is emptyYeah, I realized that :/ I'm trying to work out a conversion script that first gives you an exact copy of the gun, runs the unloading, deletes the gun, then gives you a new one. Link to comment Share on other sites More sharing options...
ORMtnMan Posted May 31, 2015 Author Share Posted May 31, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script?That is what I have, if I select the conversion recipe on the context menu it will unload the gun but what happens is as follows:Have Gun with loaded roundsConvert to another caliberUnload process startsCorrectly gives back ammoHowever, gun itself is already gone and replaced by converted gun with no ammoUnload process continues until the correct amount of ammo is replaced even though it is "gone".However, if unloading is interrupted in any way, it will not start up again and converted gun has no ammo,because the original gun with the ammo is gone, the remaining ammo is lost foreverWhich is why I am wondering if it is possible to delay the actual conversion process until the loading part of the lua script is done.That way it won't switch out the guns into the original is emptyYeah, I realized that :/ I'm trying to work out a conversion script that first gives you an exact copy of the gun, runs the unloading, deletes the gun, then gives you a new one. Also, I have been getting a problem with the clipData not changing to the new gun's type...Here is what the block looks like so far:function CaliberConvert_OnCreate(items, result, player) for i=0,items:size()-1 do local item = items:get(i) ORGMUnloadManager:startUnloadFromUi(item) local modData = result:getModData() for k,v in pairs(item:getModData()) do modData[k] = v end result:attachWeaponPart(item:getScope()) result:attachWeaponPart(item:getClip()) result:attachWeaponPart(item:getSling()) result:attachWeaponPart(item:getCanon()) result:attachWeaponPart(item:getStock()) result:attachWeaponPart(item:getRecoilpad()) return endend It is also having the problem of copying over the current ammo and clipdata, which I can't seem to make it stop doing unless I remove the "for k,v" part of the code, but then that has the side effect of not transferring if the clip has been ejected or not... I tried various things with trying to copy the containsClip from the item to the result but none of the combinations I tried seem to work... Link to comment Share on other sites More sharing options...
Fuji Posted May 31, 2015 Share Posted May 31, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script?That is what I have, if I select the conversion recipe on the context menu it will unload the gun but what happens is as follows:Have Gun with loaded roundsConvert to another caliberUnload process startsCorrectly gives back ammoHowever, gun itself is already gone and replaced by converted gun with no ammoUnload process continues until the correct amount of ammo is replaced even though it is "gone".However, if unloading is interrupted in any way, it will not start up again and converted gun has no ammo,because the original gun with the ammo is gone, the remaining ammo is lost foreverWhich is why I am wondering if it is possible to delay the actual conversion process until the loading part of the lua script is done.That way it won't switch out the guns into the original is emptyYeah, I realized that :/ I'm trying to work out a conversion script that first gives you an exact copy of the gun, runs the unloading, deletes the gun, then gives you a new one.Also, I have been getting a problem with the clipData not changing to the new gun's type...Here is what the block looks like so far:function CaliberConvert_OnCreate(items, result, player) for i=0,items:size()-1 do local item = items:get(i) ORGMUnloadManager:startUnloadFromUi(item) local modData = result:getModData() for k,v in pairs(item:getModData()) do modData[k] = v end result:attachWeaponPart(item:getScope()) result:attachWeaponPart(item:getClip()) result:attachWeaponPart(item:getSling()) result:attachWeaponPart(item:getCanon()) result:attachWeaponPart(item:getStock()) result:attachWeaponPart(item:getRecoilpad()) return endendIt is also having the problem of copying over the current ammo and clipdata, which I can't seem to make it stop doing unless I remove the "for k,v" part of the code, but then that has the side effect of not transferring if the clip has been ejected or not... I tried various things with trying to copy the containsClip from the item to the result but none of the combinations I tried seem to work...Where are you getting the get() methods from? I don't see them referenced anywhere else. Link to comment Share on other sites More sharing options...
ORMtnMan Posted June 1, 2015 Author Share Posted June 1, 2015 Well,I have it doing the timed action for the unloading part of it, however, will a recipe tagged script be able to interrupt the recipe until it is finished or do I have to do a separate recipe hook?Unless I'm mistaken, can't you just tie the recipe to a lua script like recipes which give XP, or multiple items, and have it unload the gun during that script?That is what I have, if I select the conversion recipe on the context menu it will unload the gun but what happens is as follows:Have Gun with loaded roundsConvert to another caliberUnload process startsCorrectly gives back ammoHowever, gun itself is already gone and replaced by converted gun with no ammoUnload process continues until the correct amount of ammo is replaced even though it is "gone".However, if unloading is interrupted in any way, it will not start up again and converted gun has no ammo,because the original gun with the ammo is gone, the remaining ammo is lost foreverWhich is why I am wondering if it is possible to delay the actual conversion process until the loading part of the lua script is done.That way it won't switch out the guns into the original is emptyYeah, I realized that :/ I'm trying to work out a conversion script that first gives you an exact copy of the gun, runs the unloading, deletes the gun, then gives you a new one.Also, I have been getting a problem with the clipData not changing to the new gun's type...Here is what the block looks like so far:function CaliberConvert_OnCreate(items, result, player)for i=0,items:size()-1 dolocal item = items:get(i)ORGMUnloadManager:startUnloadFromUi(item)local modData = result:getModData()for k,v in pairs(item:getModData()) domodData[k] = vendresult:attachWeaponPart(item:getScope())result:attachWeaponPart(item:getClip())result:attachWeaponPart(item:getSling())result:attachWeaponPart(item:getCanon())result:attachWeaponPart(item:getStock())result:attachWeaponPart(item:getRecoilpad())returnendendIt is also having the problem of copying over the current ammo and clipdata, which I can't seem to make it stop doing unless I remove the "for k,v" part of the code, but then that has the side effect of not transferring if the clip has been ejected or not... I tried various things with trying to copy the containsClip from the item to the result but none of the combinations I tried seem to work...Where are you getting the get() methods from? I don't see them referenced anywhere else. The getModData() is a function that ties back to the java I think that pulls all the variables currently written to a game object. It allows for writing to and from the object. The get(insert mod type) also ties back to the java and returns the modification attached in that slot. I learned that one from the shotgun sawn-off script, it transfers those items over to the new object. If you are referring to the item = items:get(i) I have no idea where it links back to (again presumably the java) but I know it isolates each item in a list as far as I can tell. Unfortunately I have not jumped into the java code aside from the models part you pointed out. Link to comment Share on other sites More sharing options...
Fuji Posted June 1, 2015 Share Posted June 1, 2015 -megasnip-...I got the recipe to unload the gun and do nothing if there's ammo in it, or complete the conversion if empty, if that's any consolation.Edit: Sort of. I can't seem to delete the original gun, but can delete a temp gun I made. Link to comment Share on other sites More sharing options...
ORMtnMan Posted June 1, 2015 Author Share Posted June 1, 2015 -megasnip-...I got the recipe to unload the gun and do nothing if there's ammo in it, or complete the conversion if empty, if that's any consolation.Edit: Sort of. I can't seem to delete the original gun, but can delete a temp gun I made. The player:getInventory():Remove(insertitemhere);orplayer:getInventory():RemoveOneOf(insertitemhere); doesn't work? Either way, let me see, maybe with our powers combined... Link to comment Share on other sites More sharing options...
Fuji Posted June 1, 2015 Share Posted June 1, 2015 -megasnip-...I got the recipe to unload the gun and do nothing if there's ammo in it, or complete the conversion if empty, if that's any consolation.Edit: Sort of. I can't seem to delete the original gun, but can delete a temp gun I made.The player:getInventory():Remove(insertitemhere);orplayer:getInventory():RemoveOneOf(insertitemhere);doesn't work?Either way, let me see, maybe with our powers combined...My horrible pasta script isn't going to help much, but I think I have a solution.Have the recipe create a temporary item, but still keep the original. Then delete the temp item (because recipes do bad things with no result defined), add the unload timed action to the action queue, and then add in a new timed action to the end of the queue that removes the original gun and adds the conversion. Link to comment Share on other sites More sharing options...
ORMtnMan Posted June 1, 2015 Author Share Posted June 1, 2015 clippedMy horrible pasta script isn't going to help much, but I think I have a solution.Have the recipe create a temporary item, but still keep the original. Then delete the temp item (because recipes do bad things with no result defined), add the unload timed action to the action queue, and then add in a new timed action to the end of the queue that removes the original gun and adds the conversion. That is a good idea and I may go down that route, but that means I would have to create a copy of the recipe code for each gun conversion because they would all have different outputs... In any case, if we can remove the new temp item why couldn't we remove the recipe result? Or possibly I am majorly confused, but I currently and running some tests along the same line as your original thought because it seems to be a good possibility... I will keep trying it for a bit more before I give up on it. Link to comment Share on other sites More sharing options...
Fuji Posted June 1, 2015 Share Posted June 1, 2015 clippedMy horrible pasta script isn't going to help much, but I think I have a solution.Have the recipe create a temporary item, but still keep the original. Then delete the temp item (because recipes do bad things with no result defined), add the unload timed action to the action queue, and then add in a new timed action to the end of the queue that removes the original gun and adds the conversion.That is a good idea and I may go down that route, but that means I would have to create a copy of the recipe code for each gun conversion because they would all have different outputs...In any case, if we can remove the new temp item why couldn't we remove the recipe result?Or possibly I am majorly confused, but I currently and running some tests along the same line as your original thought because it seems to be a good possibility... I will keep trying it for a bit more before I give up on it.I tried both removing the result and leaving it blank, both broke the recipe in some way.Edit: Also, with clever string manipulation, you might not have to make separate scripts.Concatenate or clip the "38" or whatever from the input item name and then pass that string through Link to comment Share on other sites More sharing options...
ORMtnMan Posted June 1, 2015 Author Share Posted June 1, 2015 clippedMy horrible pasta script isn't going to help much, but I think I have a solution.Have the recipe create a temporary item, but still keep the original. Then delete the temp item (because recipes do bad things with no result defined), add the unload timed action to the action queue, and then add in a new timed action to the end of the queue that removes the original gun and adds the conversion.That is a good idea and I may go down that route, but that means I would have to create a copy of the recipe code for each gun conversion because they would all have different outputs...In any case, if we can remove the new temp item why couldn't we remove the recipe result?Or possibly I am majorly confused, but I currently and running some tests along the same line as your original thought because it seems to be a good possibility... I will keep trying it for a bit more before I give up on it.I tried both removing the result and leaving it blank, both broke the recipe in some way.Edit: Also, with clever string manipulation, you might not have to make separate scripts.Concatenate or clip the "38" or whatever from the input item name and then pass that string through Okay, Interesting point, the resulting item is added AFTER the lua runs down to the return. I found this out because I added in a static remove a specific gun to see if it was possible. and it didn't remove it the first time but it removed it the second time... So I had an AR-10Hit convert, it have me an AR-10 and a .308 AR-10. Hit convert again on the original AR-10, and it stayed AR-10 and .308 AR-10 instead of getting 2 .308 AR-10s Will test some more Link to comment Share on other sites More sharing options...
ORMtnMan Posted June 1, 2015 Author Share Posted June 1, 2015 Marking this one solved because I am going to ask the question differently. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now