Noobish questions, mostly about scripting
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
Noobish questions, mostly about scripting
thank you for taking a look at my questions.
1: Is there a way to freeze a players movements? can i use cut sequences to freeze a player? can i make the cut sequense's camera determined by the location of the player instead of a particular coordinate on the island? could someone provide an example of a script that would allow this?
2: can the script increase or decrease a player's playervar rather than manually setting each number? if so, what would be the command for that?
ill think of more later... sorry have to go now
1: Is there a way to freeze a players movements? can i use cut sequences to freeze a player? can i make the cut sequense's camera determined by the location of the player instead of a particular coordinate on the island? could someone provide an example of a script that would allow this?
2: can the script increase or decrease a player's playervar rather than manually setting each number? if so, what would be the command for that?
ill think of more later... sorry have to go now
for number 2:
$gPlayerVar#=$gPlayerVar# - / + #
As an example:
After clicking the OSD button to run the above script (it's part of setting a sale price for a building), the script lowers $gPlayerVar25 by 1000. It then checks to see if the value is 0 and resets it to 0 if it is (can't have buildings selling for negative prices, lol)
All other vars can be changed the same way as well
$gPlayerVar#=$gPlayerVar# - / + #
As an example:
Code: Select all
Event( "OSDSelect", "b44o:b44osaled1000" )
{
$gPlayervar25=$gPlayervar25-1000
if ($gPlayerVar25<0)
{
$gPlayerVar25=0
}
CustomEvent("b44osale")
}
All other vars can be changed the same way as well
Code: Select all
Event( "OSDSelect", "b44o:b44oai1000" )
{
*grantcash %player% -1000
$gBuildingVar6=$gBuildingVar6+1000
CustomEvent("b44oinvest")
}
- MasterNiCron
- Posts: 582
- Joined: Wed Feb 17, 2010 10:57 pm
- Location: Frost
(1) not shure
(2)
the + # or - # can be what ever u need it to be
(2)
Code: Select all
$gPlayerVar[1] = $gPlayerVar[1] + 1 (to add to player ver)
$gPlayerVar[1] = $gPlayerVar[1] - 1 (to subtract from player ver)
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
question 3, can the script determine if a person's playervar is greater or less than a value? or do i have to program it to check for each possible playervar #?
ANSWERED!
example
ANSWERED!
example
Code: Select all
Event( "Custom", "example" )
{
If ( $playervar1 > 0 )
{
*msg %player%'s playervar1 is greater than 0.
}
else
{
*msg %player%'s playervar1 is not greater than 0.
}
}
Last edited by flametard on Fri Feb 08, 2013 2:12 am, edited 2 times in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
question 4: buildingvar?! buildings can have var's too? is the building var the same for each player who accesses it, or does the building var change for one player only? im assuming the former.
Last edited by flametard on Thu Sep 27, 2012 2:51 pm, edited 1 time in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
question 5:
I would like to get the script to draw a random number between 1 and say... 5. and be able to set outcomes for each number. can someone provide an example of how I would do this?
ANSWERED
example:
I would like to get the script to draw a random number between 1 and say... 5. and be able to set outcomes for each number. can someone provide an example of how I would do this?
ANSWERED
example:
Code: Select all
Event ("Useitem","Dice")
{
$myVar = sysRand(6)
If ( $myVar = 1 )
{
*say %player% rolled a one.
}
else If ( $myVar = 2 )
{
*say %player% rolled a two.
}
else If ( $myVar = 3 )
{
*say %player% rolled a three.
}
Else If ( $myVar = 4 )
{
*say %player% rolled a four.
}
else If ( $myVar = 5 )
{
*say %player% rolled a five.
}
else
{
*say %player% rolled a six.
}
}
Last edited by flametard on Fri Feb 08, 2013 2:16 am, edited 2 times in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
question 6:
say at the end of an event script, I'd like it to automatically start a different event script, is that possible?
ANSWERED
example
say at the end of an event script, I'd like it to automatically start a different event script, is that possible?
ANSWERED
example
Code: Select all
Event( "Custom", "first" )
{
*msg %player% check one
CustomEvent("checktwo")
}
Event( "Custom", "checktwo" )
{
*msg %player% check two.
}
Last edited by flametard on Fri Feb 08, 2013 2:20 am, edited 1 time in total.
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
question 7:
what is the event called when a player clicks on another player's name when theyre close enough to barter/ challenge? can someone provide me an example for that script?
ANSWERED
example
to reset the button name, type into your world's chatbox, something like:
*scriptedoption 4, Follow
what is the event called when a player clicks on another player's name when theyre close enough to barter/ challenge? can someone provide me an example for that script?
ANSWERED
example
to reset the button name, type into your world's chatbox, something like:
*scriptedoption 4, Follow
Code: Select all
Event( "MenuOption", "4" )
{
*msg %player% you have become a follower of %target%.
*msg %target% %player% has chosen to become your follower.
*setfollowerid %player% $gTargetID
}
Last edited by flametard on Fri Feb 08, 2013 2:25 am, edited 2 times in total.
- morbydvisns
- Posts: 1889
- Joined: Sun Jan 30, 2005 12:51 am
3: if ($playervar1 < 3)
{
}
4: each building has its own set of vars, up to 16 i think, and it's building specific, will be the same for each player. Tho they are specific to each building instance.
5: $var = SysRand(5) i BELIEVE is what it is now.... and the 5 would be the random number max value..... ie. pickes a number from 0 to 5.
6: There are a couple ways to do this, depending on the type of script event you are working with.... custom even script, or building/osd style. I don't really have the time to outline all that now.
7: This is not scripted, as far as I'm aware. It's hardcoded to the GUI.
{
}
4: each building has its own set of vars, up to 16 i think, and it's building specific, will be the same for each player. Tho they are specific to each building instance.
5: $var = SysRand(5) i BELIEVE is what it is now.... and the 5 would be the random number max value..... ie. pickes a number from 0 to 5.
6: There are a couple ways to do this, depending on the type of script event you are working with.... custom even script, or building/osd style. I don't really have the time to outline all that now.
7: This is not scripted, as far as I'm aware. It's hardcoded to the GUI.
Last edited by morbydvisns on Fri Sep 28, 2012 11:10 am, edited 2 times in total.
Make sure to read through the scripting overview and reference pages at http://theuniversal.net/worldmanual for details of many of the functions and processes involved in the new scripting systems.
coupla wee corrections and additions..
4) You assumption and Morb's answer are correct except that there are now 128 gBuildingVars per building (and 32 gBuildingTimeVars).
5) $var = sysRand(5) actually returns a value from 1 to 5, not 0 to 5.
6) You can trigger a separate event using the 'CustomEvent' function, or by using *event [NAME] [Event_name] or *eventallonline [Event_name].. with the latter triggering the event for everyone currently connected to your world.
You can also add and call your own functions (which gives you the options to pass parameters to the function and return values from it). Using functions is often vital for any complex scripting.
For details on all these things, check out the scripting section in the worldmanual :
http://theuniversal.net/worldmanual/dok ... s_overview
7) These do call an event through which you can intercept the normal GUI behaviour.
When someone selects someone else to barter with the 'BarterRequest' event is triggered. When they select challenge the 'InitChallenge' event is triggered. Once accepted the client handles the GUI for the standard challenges etc, but in both cases they can be interrupted with the 'CancelTransaction()' command.
So if you wanted to implement your own barter system you'd script something like..
Its on the list to add a configurable option to the player targetting menu so you can add a button with a custom name and receive an event when its used.
coupla wee corrections and additions..
4) You assumption and Morb's answer are correct except that there are now 128 gBuildingVars per building (and 32 gBuildingTimeVars).
5) $var = sysRand(5) actually returns a value from 1 to 5, not 0 to 5.
6) You can trigger a separate event using the 'CustomEvent' function, or by using *event [NAME] [Event_name] or *eventallonline [Event_name].. with the latter triggering the event for everyone currently connected to your world.
You can also add and call your own functions (which gives you the options to pass parameters to the function and return values from it). Using functions is often vital for any complex scripting.
For details on all these things, check out the scripting section in the worldmanual :
http://theuniversal.net/worldmanual/dok ... s_overview
7) These do call an event through which you can intercept the normal GUI behaviour.
When someone selects someone else to barter with the 'BarterRequest' event is triggered. When they select challenge the 'InitChallenge' event is triggered. Once accepted the client handles the GUI for the standard challenges etc, but in both cases they can be interrupted with the 'CancelTransaction()' command.
So if you wanted to implement your own barter system you'd script something like..
Code: Select all
Event( "BarterRequest", "" )
{
// Cancel the standard barter system
CancelTransaction()
// Trigger events for both players to do your own thang
*event %PLAYER% MyCustomBarterOSD
*event %TARGET% MyCustomBarterTargetOSD
}
mit, are Functions basically just snippits of script that any script can call to to get something done or get info as a method of consolidating things that would otherwise be repeated several times in a script?
If so, then I'm guessing the script that calls it doesn't get stopped at all and one could have, for example, 4 different scripts calling the same function and nothing would get confused, right?
If so, then I'm guessing the script that calls it doesn't get stopped at all and one could have, for example, 4 different scripts calling the same function and nothing would get confused, right?
- flametard
- Posts: 1245
- Joined: Sun Apr 01, 2007 2:05 am
- Location: Join NR! faction name: 'NR new recruits' password: 'Truth'
- Contact:
thank you very much, I'm armed with stuff to read and test, now.
kept bartering, my 3 ideas so far are:
pickpocketing:
I did it
casting spells:
changed it to the follow button
intimacy and procreation:
did it.
again, thanks for the information, thank you again.
kept bartering, my 3 ideas so far are:
pickpocketing:
I did it
casting spells:
changed it to the follow button
intimacy and procreation:
did it.
again, thanks for the information, thank you again.
Last edited by flametard on Fri Feb 08, 2013 2:29 am, edited 1 time in total.
- morbydvisns
- Posts: 1889
- Joined: Sun Jan 30, 2005 12:51 am
Done for 0.63.3. 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.Its on the list to add a configurable option to the player targetting menu so you can add a button with a custom name and receive an event when its used.
I'll extend this further so that all/most of the default menu buttons in the game can be replaced with script as needed.