Skip to content

Instantly share code, notes, and snippets.

@blurymind
Last active November 1, 2020 16:27
Show Gist options
  • Save blurymind/047fea6375ce258743bac655bea0ab2d to your computer and use it in GitHub Desktop.
Save blurymind/047fea6375ce258743bac655bea0ab2d to your computer and use it in GitHub Desktop.
Ags reusable methods
//// This is ags script, not javascript - C like, but not quite
//////////// walk to and pick //////////////////
/// https://adventuregamestudio.github.io/ags-manual/Object.html
function walkToAndPick(this Object*, InventoryItem* addObject ,const string say){
player.Walk(this.X, this.Y, eBlock, eWalkableAreas);
String toSay = "";
if (String.Format("%d",say) =="0") {
toSay = String.Format("Found a %s", addObject.Name);
}
else {
toSay = say;
}
player.Say(toSay);
player.AddInventory(addObject);
this.Visible = false;
}
function walkToAndLook(this Object* ,const string say){
player.Walk(this.X, this.Y, eBlock, eWalkableAreas);
String toSay = "";
if (String.Format("%d",say) =="0") {
toSay = this.GetTextProperty("Description"); // add this to Object schema
}
else {
toSay = say;
}
player.Say(toSay);
}
import function walkToAndPick(this Object*, InventoryItem* addObject, String say=0);
import function walkToAndLook(this Object*, String say=0);
//then use on objects
function cup_PickUp()
{
// cup.walkToAndPick();
cup.walkToAndLook();
}
///////////////////////////
@blurymind
Copy link
Author

walkstudy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment