Silver wrote:Yes... I think... (you can certainly move objects with a script) but then the object wouldn't show up in your inventory list. Or at least I don't know how to do that.
The Pixie wrote:What benefit does it bring to your game to have the inventory track what is actually in the bag and what is not?
// this code will move every object (except the knapsack) from the inventory to the knapsack, every turn.
// if you only want to move specified Objects, then let me know, and I'll give code for that. Example of specified Objects (instead of all Objects): only moving 'arrow' type of Objects into your 'quiver' Object, as a 'quiver' holds 'arrows' for archery, and not anything else.
<game name="xxx">
<attr name="turn" type="int">0</attr>
</game>
<object name="room">
<object name="player">
<object name="knapsack">
</object>
</object>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x.name = "knapsack") {
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
game.turn = game.turn + 1
</script>
</turnscript>
Silver wrote:Well then surely the easiest way about it is to have the player start the game with a knapsack that can't be dropped and to change the inventory response to "you are carrying a knapsack which contains..."
game.turn = game.turn + 1
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x = knapsack) {
object_x.parent = knapsack
}
}
</script>
</turnscript>
<game name="xxx">
<attr name="turn" type="int">0</attr>
</game>
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x.name = "knapsack") {
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
game.turn = game.turn + 1
</script>
</turnscript>
// blah, the rest of your entire game code
<function name="RunTurnScripts">
if (IsGameRunning()) {
if (game.menucallback = null) {
foreach (turnscript, AllTurnScripts()) {
if (GetBoolean(turnscript, "enabled")) {
inscope = false
if (turnscript.parent = game or turnscript.parent = null) {
inscope = true
} else {
if (Contains(turnscript.parent, game.pov)) {
inscope = true
}
}
if (inscope) {
do (turnscript, "script")
}
}
}
}
}
</function>
<function name="FinishTurn">
RunTurnScripts
UpdateStatusAttributes
CheckDarkness
UpdateObjectLinks
</function>
jaynabonne wrote:
Just create a turnscript object, and put the script in there (using the GUI or whatever). Or just copy and paste this into code view, inserting just before the closing "</aslx>" tag:<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x = knapsack) {
object_x.parent = knapsack
}
}
</script>
</turnscript>
If you have any trouble, it can easily be dropped into a library to be included.
<asl version="550">
// the above is the very top of your game file
//(mass of rest of your code)
// the below is the very bottom of your game file
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x.name = "knapsack") {
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
</script>
</turnscript>
</asl>
<asl version="550">
// the above is the very top of your game file
//(mass of rest of your code)
// the below is the very bottom of your game file
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
// below is the area you'll want to work with in adding~changing what scripts you want, if you need help, if you just~only want to exclude more Objects, then I'll help you how to do that, or if you want to do other stuff, I can help too, but I need to know what you want done, to help you.
if (not object_x.name = "knapsack") {
// above is the area you'll want to work with in adding~changing what scripts you want, if you need help, if you just~only want to exclude more Objects, then I'll help you how to do that, or if you want to do other stuff, I can help too, but I need to know what you want done, to help you.
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
</script>
</turnscript>
</asl>
jaynabonne wrote:Verbs, commands, etc cause commands to be executed, just as if you had input them from the keyboard. So they cause turnscripts to fire as well.What you sayin', like?
I just meant, "This is a tangent with some code unrelated to your question, so don't worry about it."
HegemonKhan wrote:// below is the area you'll want to work with in adding~changing what scripts you want, if you need help, if you just~only want to exclude more Objects, then I'll help you how to do that, or if you want to do other stuff, I can help too, but I need to know what you want done, to help you.
<asl version="550">
// the above is the very top of your game file
//(mass of rest of your code)
// the below is the very bottom of your game file
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x.name = "knapsack" and not object_x.name = "your object1's name: ?gun?" and not object_x.name = "your object2's name: cigerette?") {
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
</script>
</turnscript>
</asl>
<asl version="550">
// the above is the very top of your game file
//(mass of rest of your code)
// the below is the very bottom of your game file
<turnscript name="global_turnscript">
<enabled />
<script>
foreach (object_x, ScopeInventory () ) {
if (not object_x.name = "knapsack" and not object_x.your_group_setting_Attribute_name = Value_depends_upon_Attribute_Type and not object_x.your_group_setting_Attribute_name and not object_x.your_group_setting_Attribute_name and not object_x.your_group_setting_Attribute_name and not object_x.your_group_setting_Attribute_name________etc_etc_etc) {
object_x.parent = knapsack // or: MoveObject (object_x, knapsack)
}
}
</script>
</turnscript>
</asl>