Page 2 of 7

Posted: Thu Oct 04, 2012 10:57 pm
by zaroba
Any way to edit item stats yet?
Like hunger/thirst/health gain/loss?

Although using a script for them all would allow this pretty easily. Wasn't there a setting where *all* items provided a 'use item' option and triggered a script and thus disabled the normal Eat/Drink inventory options?

Posted: Fri Oct 05, 2012 9:41 am
by Mit
Ah um, you've been able to edit items for ages.. method is just a bit clunky and was supposed to be replaced by a world ed UI which i haven't finished yet. (That's probably why you don't know about it). Meanwhile..

Code: Select all

*setitemuse ItemName,[UseVal][|Size]
*setitemnutrition ItemName,[Primary]|[Health]|[MaxHealth]
*setitemadvancednutrition ItemName,[Val1]|[Val2]|...|[Val6]
Advanced nutrition isn't used anywhere yet. The main values for the 'UseVal' for *setitemuse are:

Code: Select all

0 - None
1 - Food
2 - Drink
3 - Misc
12 - Scripted
13 - Combination
You can now add custom named options to the main menu displays, and override each of the buttons in the player popup display, all of which trigger a 'MenuOption' event which your script can do what it likes with.
Just for reference, the 0.63.3 process is:
manually override the buttons you want to using:

Code: Select all

*scriptedoption [OPTION_NUM],[TEXT]
Valid [OPTION_NUM]s right now are :
1- F9 option on the mini menu
2 - 1st option on the player popup menu (replaces barter)
3 - 2nd option on the player popup menu (replaces challenge)
4 - 3rd option on the player popup menu
5 - 4th option on the player popup menu
(more to follow..)
e.g. Doing

Code: Select all

*scriptoption 2,Attack
Means that when you click a player's name, instead of "Barter with" being the top option, "Attack" is instead. When selected by the user, the server triggers a MenuOption event instead of the Barter one. e.g.

Code: Select all

Event( "MenuOption", "2" )
{
	*msg %PLAYER% You selected option 1 on player %TARGET%	
}

Posted: Fri Oct 05, 2012 4:53 pm
by flametard
:D

so just to be noobish,
the designation %target% will apply even in the event script thats triggered after the barterrequest?

ANSWER

CUSTOM EVENTS REMEMBER WHO THE TARGET IS!!

Code: Select all

Event( "Custom", "sayhi" ) 
{
SetContext( $gTargetID )
CustomEvent("hi")
RestoreContext()
sleep (1)
CustomEvent("hello")
}
Event( "Custom", "hi" ) 
{
*msg %player% HI %player%!!!
}
Event( "Custom", "hello" ) 
{
*msg %player% youre saying hi to %target%
*msg %target% %player% said hi to you
}


Posted: Fri Oct 05, 2012 10:53 pm
by MasterNiCron
how would target verables work then any thing like this??

---------------------------------------------------

Code: Select all

Event( "MenuOption", "2" ) 
 {
   IF (%TARGET% PLAYERVAR[#] = #)
    {
      someting here
    }
  ELSE
    {
     something else here
    }
 }
or is this not evan close?

Posted: Sat Oct 06, 2012 9:52 pm
by Mit
We're in to quite 'Intermediate level' territory here now :)

Firstly, the target variables will only apply within the event (and any events/functions called from it).. each event has a different 'context' - so, for instance, when you access a building the $gBuildingID field is valid, but in other cases (like a & command for instance) theres no building involved so the field wouldn't be relevant... $gTargetID (and %TARGET%) are relevant in events like those menu selections and other things like 'RobocrowKill'. etc.

%TARGET% (like %PLAYER%) is just a quick way of doing :

Code: Select all

$targetName = sysGetPlayerName( $gTargetID )
though theres nothing wrong with that either.

To get details of the target's playerVars (for instance), you need to get to grips with 'SetContext' and 'RestoreContext'. Setting the context allows you to choose who the 'current player' is. For example :

Code: Select all

$myKudos = $gPlayerKudos
SetContext( $gTargetID )
$targetKudos = $gPlayerKudos
RestoreContext()
*msg %PLAYER% Your kudos is $myKudos. %TARGET%'s kudos is $targetKudos
There are various ways you could keep the target player's info around for later events - you could save it in a playerVar, or pass it as a param via events, timers and osd buttons.

Heres a quick example of a targetted MenuOption event that brings up an OSD with a param to pass in a targetID when the button is pressed.

Code: Select all

Event( "MenuOption", "2" )
{
   OSDCreate( OSDWINDOW, "TargetOSD", "Challenge %TARGET%" )
   OSDAddItem( OSDBUTTON, "Button|$gTargetID", "Press here to challenge %TARGET%" )
   OSDActivate()
}

Event( "OSDSelect", "TargetOSD:Button" )
{
   $paramTargetID = $gParam[1]
   $targetName = sysGetPlayerName( $paramTargetID )
   *msg %PLAYER% You selected to challenge $targetName
}
Keep those questions coming.. this'll be a handy thread to know what sorta questions other folks will have and will help form better documentation when its all written up.

Posted: Sun Oct 07, 2012 12:42 am
by Omni
A new generation of coders is coming up, and that's a good thing for the game.

Posted: Sun Oct 07, 2012 4:28 pm
by flametard
back to a noobish question:

I tried to add more stuff like:
Event( "AccessBuilding", "40" )
{
*msg %player% A castle belonging to %buildingowner%.
}
(i've tried all sorts of stuff and nothing works, so i've fallen back to test script)

I'm running all my programs, notepad, buildings editor, Server, Client, as administrator and on the latest patches and I don't understand why things arent working. Weridly, one of my old building trigger scripts still works, and I copied the exact script to another building in the script and no script popped up. So i know my scripts are working, the new trigger buildings just arent reading them for some reason.

HELP!! :cry:

Posted: Sun Oct 07, 2012 5:51 pm
by Mit
can you check your output in the script window of the server and see whether anything at all happens when you access the building.
this sorta thing (in my own experience) is usually something like forgetting to include a file, or having duplicate entries or something like that..

Posted: Sun Oct 07, 2012 6:02 pm
by MasterNiCron
ok being that did not anser the question let me refraze it
im makeing a player 2 player battle script and dont know how to compare %player% playervar to the %target% playervar such as.

Code: Select all

EVENT("MenuOption", "2")
{
 IF ([[%player%]] $gplayervar[1] >  [[%target%]] $gplayervar[1])
   {
    DO THIS
    }
 ELSE
    {
    DO THIS
    }
 }

Posted: Sun Oct 07, 2012 6:17 pm
by Mit
forget about %TARGET% and stuff in statements like that.. they're just for getting the name text for commands like '*say The Winner was %TARGET%'

To do the stuff you want you need to use SetContext, as described above.
Or to re-do your example :

Code: Select all

Event( "MenuOption", "2" )
{
  // Get the player's var 1
   $myVar = $gPlayerVar[1]

   // Get the target's var 1
   SetContext( $gTargetID )
   $targetVar = $gPlayerVar[1]
   RestoreContext()

   if ( $myVar > $targetVar )
   {
        DO THIS
   }
   else
   {
        DO THIS
   }
}

Posted: Sun Oct 07, 2012 6:25 pm
by MasterNiCron
was just useing the %player% and %target% to indecate the diferant players each playervar wes for :)

and thanks i understude that a lot better than the first 1 u had showed

Posted: Sun Oct 07, 2012 6:52 pm
by morbydvisns
wes was for none of that.

Posted: Sun Oct 07, 2012 6:57 pm
by MasterNiCron
i add it now world keeps crashing it take it out of script and world works fine is that stuff not active in game yet or something??

Posted: Sun Oct 07, 2012 7:09 pm
by Mit
menuoption is 0.63.3

Posted: Sun Oct 07, 2012 8:23 pm
by flametard
ok, i put the computer down, did the dishes, some sweeping, got dog food, pork chops, beer, and a headlight for the car, came back to the surprise that the problem had somehow fixed itself (i just KNEW i did everything right) so we'll never know what that funny business was actually about.

Posted: Sun Oct 07, 2012 9:42 pm
by zaroba
maybe you had forgotten to do a *reloadscript :p

Posted: Sun Oct 07, 2012 10:06 pm
by MasterNiCron
Mit wrote:menuoption is 0.63.3
OK I can wate then with that idea :)

Posted: Sun Oct 07, 2012 10:18 pm
by Mit
*reloadscript?
You still do that? Not F11?

Posted: Mon Oct 08, 2012 12:02 am
by zaroba
ooo, that's neat.

It doesn't seem to work with menu mode 2 though (been using that for the simplicity of setting up the world, building, map editing, etc)

Posted: Mon Oct 08, 2012 12:19 am
by flametard
I was turning the world on and off to reload the script and relogging.