Icon representing a recipe

Recipe: Rav3n_pl LUA v1 in v2

created by Rav3n_pl

Profile


Name
Rav3n_pl LUA v1 in v2
ID
31012
Shared with
Public
Parent
None
Children
Created on
August 12, 2011 at 15:35 PM UTC
Updated on
August 12, 2011 at 15:35 PM UTC
Description

Library that allows use 99% v1 scripts in dev v2 update w/o any chnage. Just add it at front of your v1 code and paste into v2 script. Now you can use v1 and v2 commands v2 script.

Best for


Code


-- "lua v1 in v2" library by rav3n_pl --just add it in front of your v1 code and use v2 and v1 code in v2 scripts :) -- print(arg1[,...,argN]) no change :) function are_conditions_met() return current.AreConditionsMet() end function band_add_segment_segment(sgi1, sgi2) band.AddBetweenSegments(sgi1, sgi2) end function band_delete(bndIdx) if bndIdx~= nil then band.Delete(bndIdx) else band.DeleteAll() end end function band_disable(bndIdx) if bndIdx~=nil then band.Disable(bndIdx) else band.DisableAll() end end function band_enable(bndIdx) if bndIdx~=nil then band.Enable(bndIdx) else band.EnableAll() end end function band_set_length(bndIdx, len) band.SetGoalLength(bndIdx, len) end function band_set_strength(bndIdx, str) band.SetStrength(bndIdx, str) end function get_band_count() return band.GetCount() end function deselect_all() selection.DeselectAll() end function deselect_index(sgn) selection.Deselect(sgn) end function select_all() selection.SelectAll() end function select_index(sgn) selection.Select(sgn) end function select_index_range(sg1,sg2) selection.SelectRange(sg1,sg2) end function do_freeze(bbone,schain) freeze.FreezeSelected(bbone,schain) end function do_unfreeze_all() freeze.UnfreezeAll() end function do_global_wiggle_all(iters) structure.WiggleAll(iters,true,true) end function do_global_wiggle_backbone(iters) structure.WiggleAll(iters, true,false) end function do_global_wiggle_sidechains(iters) structure.WiggleAll(iters,false,true) end function do_local_rebuild(iters) structure.RebuildSelected(iters) end function do_local_wiggle(iters) structure.LocalWiggleSelected(iters,true,true) end function do_mutate(iters) structure.MutateSidechainsSelected(iters) end function do_shake(iters) structure.ShakeSidechainsSelected(iters) end function do_sidechain_snap(sgn, snap) rotamer.SetRotamer(sgn, snap) end function get_sidechain_snap_count(sgn) return rotamer.GetCount(sgn) end function load_structure() save.LoadSecondaryStructure() end function save_structure() save.SaveSecondaryStructure() end function quickload(slot) save.Quickload(slot) end function quicksave(slot) save.Quicksave(slot) end function get_exploration_score() return current.GetExplorationMultiplier() end function get_ranked_score() return current.GetScore() end function get_score() return current.GetEnergyScore() end function get_segment_distance(sg1,sg2) return structure.GetDistance(sg1,sg2) end function get_aa(sn) return structure.GetAminoAcid(sn) end function get_segment_count() return structure.GetCount() end function get_ss(sn) return structure.GetSecondaryStructure(sn) end function is_hydrophobic(sn) return structure.IsHydrophobic(sn) end function replace_aa(aa) for i=1,structure.GetCount() do if selection.IsSelected(i) then structure.SetAminoAcid(i, aa) end end end function replace_ss(ss) for i=1,structure.GetCount() do if selection.IsSelected(i) then structure.SetSecondaryStructure(i,ss) end end end function get_segment_score(sg) return current.GetSegmentEnergyScore(sg) end function get_segment_score_part(score_part,sg) return current.GetSegmentEnergySubscore(sg,score_part) end function reset_puzzle() puzzle.StartOver() end function restore_abs_best() absolutebest.Restore() end function restore_credit_best() creditbest.Restore() end function reset_recent_best() recentbest.Save() end function restore_recent_best() recentbest.Restore() end function set_behavior_clash_importance(ci) behavior.SetClashImportance(ci) end -- end of library

Comments


Rav3n_pl Lv 1

This recipe DOES NOTHING!
It is only translation library.
If you not making LUA scripts by yourself it is USELESS for you!

tyler0911 Lv 1

Works great, except for the replace_ss(ss) function. I always get an error at the line that says structure.SetSecondaryStructure(i, ss). The error is
bad argument #2 to 'SetSecondaryStructure' (string expected, got nil)

I also got this error when i attempted to make an all loops function for one of my own scripts, so i don't know what the problem could be…

Rav3n_pl Lv 1

ss code you want change to.

select_index(x)
replace_ss("L")

or use new code instead, like

for i=ss,se do
structure.SetSecondaryStructure(i,"L")
end

This library is temporary solution anyway :)

Crashguard303 Lv 1

Yeah, as I was afraid of.
Those functions, which have just another name but the same number (and order) of parameters, renaming is simple.
It get's tricky if there are more parameters.

Crashguard303 Lv 1

I also considered using this library, but this does lengthen the code, so I rather replace it.

But nice workaround, thanks for your work!

GaryForbis Lv 1

Thanks for the helpful script.

function replace_aa(aa)
for i=1,structure.GetCount() do
if selection.IsSelected(i) then
structure.SetAminoAcid(i, aa)
end
end
end
function replace_ss(ss)
for i=1,structure.GetCount() do
if selection.IsSelected(i) then
structure.SetSecondaryStructure(i,ss)
end
end
end

can be replaced with:

function replace_aa(aa)
structure.SetAminoAcidSelected(aa)
end
function replace_ss(ss)
structure.SetSecondaryStructureSelected(ss)
end