I'm afraid Tricxta is right. I don't think you can toweapons from within a weapon (can't toweapons inside of something that was added with toweapons). Here is the closest thing you could do: you could require an empty bottle to get a red potion, then you could remove the empty bottle when you receive the red potion, and delete the red potion when it's been used, but you cannot replace it with an empty bottle using offline GS1.
I've written a quick example for you.
Empty Bottle:
PHP Code:
if (playerenters) {
setimg eman_water_potion.png;
show;
}
if (playertouchsme) {
toweapons Empty Bottle;
hide;
}
if (destroy) {
destroy;
}
Red Potion:
PHP Code:
if (playerenters) {
setimg eman_red_potion.png;
show;
}
if (playertouchsme) {
if (hasweapon(Empty Bottle)) {
toweapons Red Potion;
removeEmptyBottle();
hide;
}else {
say2 You need an empty bottle.;
}
}
function removeEmptyBottle() {
for (i = 0; i < weaponscount; i ++) {
if (strequals(#w(i),Empty Bottle)) {
callweapon i,destroy;
break;
}
}
}
if (weaponfired) {
playerhearts = playerfullhearts;
setplayerprop #c, *gulp*;
destroy;
}
You'll also notice that the use of timeout was not needed due to callweapon.
The -best- alternative I can offer you is have a listening NPC to add the empty bottle after the red potion has been used. But unfortunately, that'll only provide a solution in that level because offline GS1 doesn't support with(levelname) stuff. Here's what I mean:
Random NPC:
PHP Code:
if (created) {
x = 0;
y = 0;
setshape 1,32,32;
dontblock;
}
if (actionaddemptybottle) {
setimg eman_water_potion.png;
toweapons Empty Bottle;
hide;
}
if (destroy) {
destroy;
}
Empty Bottle:
PHP Code:
if (playerenters) {
show;
setimg eman_water_potion.png;
}
if (playertouchsme) {
toweapons Empty Bottle;
hide;
}
if (destroy) {
destroy;
}
Red Potion:
PHP Code:
if (playerenters) {
setimg eman_red_potion.png;
show;
}
if (playertouchsme) {
if (hasweapon(Empty Bottle)) {
toweapons Red Potion;
removeEmptyBottle();
hide;
}else {
say2 You need an empty bottle.;
}
}
function removeEmptyBottle() {
for (i = 0; i < weaponscount; i ++) {
if (strequals(#w(i),Empty Bottle)) {
callweapon i,destroy;
break;
}
}
}
if (weaponfired) {
playerhearts = playerfullhearts;
setplayerprop #c, *gulp*;
triggeraction 0,0,addemptybottle,0;
destroy;
}
Those three scripts WILL actually do what you want, but like I said, it'll only work in that level.
I was also thinking that in the red potion you could do something dumb like this:
PHP Code:
if (created) {
setstring this.origin,#L;
}
...
if (weaponfired) {
playerhearts = playerfullhearts;
setplayerprop #c, *gulp*;
setstring this.oldlevel,#L,#v(playerx),#v(playery);
setlevel #s(this.origin);
triggeraction 0,0,addemptybottle,0;
setlevel2 #I(this.oldlevel,0), strtofloat(#I(this.oldlevel,1)), strtofloat(#I(this.oldlevel,2));
destroy;
}
But I think the execution thread stops when setlevel happens, so it probably wouldn't work.