i'm using the mi2 template for v2.70 and, after some tweaking, it works on v2.71.
now i'm trying to use ONLY object based scripting, and i'm stuck at this point:
function UsedInvMode(int mode, int item){
// It's used for checking if the template inventory mode passed as parameter 'mode'
// was used with the inventory item passed as parameter 'item'.
return (UsedMode(mode) && Tmode[mode].AGSmode==4 && character[EGO].activeinv==item);
it should become
return blablablablablabla && character[EGO].ActiveInventory == item.
well... "item" is an int, and character[].ActiveInventory's type is *InventoryItem.
how can i let it work? any ideas?? ??? (sorry for my bad english, but i'm veeeeeery tired)
maybe i need to rewrite the whole template? :o :o
let me know...
You could try adding a .ID somewhere, maybe like this?
return blablablablablabla && character[EGO].ActiveInventory.ID == item
I'm not sure about this, mind - someone else who is coming along might be a lot more help - but it can't hurt to try.
Yes, the ID member will give you the integer value of an InventoryItem. Alternatively, he could replace 'item' with 'inventory[item]'. They would both achieve the same effect.
Or rewrite it to use the iThing values properly.
But if he does that, he might as well rewrite the whole template. Which seems to be undesirable, from his emoticons, and I can't say I blame him.
thanks to everyone! :D
Quote from: Elliott Hird on Wed 21/12/2005 10:23:43
Or rewrite it to use the iThing values properly.
errr.... what do youexactly mean? any examples? ::)
well it's iScriptName. There's different functions to get them instead of an int, poke around the manual a bit if you desire.
He's talking about making the function return an *InventoryItem instead of an int. But I advise against it - who knows what sort of repercussions that might have, and how much code you may have to end up rewriting.
For generic purpose, returning the ID of an Object is enough already.
Also for generic purposes, would it not be better to use player.ActiveInventory? (Obviously, if Federikazzo only has EGO as the player character, character[EGO], or cEgo will work).
I think Elliott meant change the function to something like:
function UsedInvMode(int mode, InventoryItem *UsedItem){
// It's used for checking if the template inventory mode passed as parameter 'mode'
// was used with the inventory item passed as parameter 'UsedItem'.
return (UsedMode(mode) && Tmode[mode].AGSmode==4 && player.ActiveInventory == UsedItem);
}
If you were planning on rewritting the whole template for release, that would probably be the better way to go (along with using pointers for characters, GUIs, objects, etc instead of ints).
Since it looks like you're just trying to get it to work for you, the ID property is fine, or player.ActiveInventory == inventory[item].
And just for the record, it's a InventoryItem*, not *InventoryItem. The asterik can be attached to the variable type or the variable name, but it should never proceed the type.
thanks to you all!
i think i'm going to rewrite the whole template btw, cos it doesn't work properly at the moment.
ok, maybe i've made some mistakes with the new code, but i don't mind.
i'll try to make a working template so that anyone can use it with the newer versions of ags.
...i just hope i can make it! :o